您的位置:首页 > 编程语言

有效防止外链广告!!!修改discuz的URL代码

2009-08-06 08:57 477 查看
教你有效防止外链广告!!!修改discuz的URL代码

我把论坛里的URL自带 discuz代码改了.

当会员发贴时,内容里有URL则全都改内嵌模式的,这样搜索引擎就不会认为是外链了

演示地址请点这个,然后查看二楼和三楼的链接
http://www.qhdok.com/thread-1448-1-1.html

2009年3月18日修改:把所有非站内URL都改成内嵌的了

http://www.qhdok.com/home/link.php?url=http://www.baidu.com
http://www.qhdok.com/home/link.php?url=http://www.baidu.com
复制代码

2009年3月18日修改:把所有非站内URL都改成内嵌的了

是修改include/discuzcode.func.php里的东西,当然,要把里面的qhdok.com改成自己的网址

function parseurl($url, $text) {

if(!$url &&
preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:////|www/.)[^/[/"']+/i",
trim($text), $matches)) {

$url = $matches[0];

$returnval="";

$length = 65;

if(strlen($url) > $length) {

$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));

}

$temp=$url;

$temp=str_replace("www.","",str_replace("http://","",$temp));

if(substr($temp,0,9)=="qhdok.com"){

if(substr($url,0,4)!="http"){

$url="http://".$url;

}

$returnval="<a href=".$url." target=_blank>".$text."</a>";

}else{

$returnval='<a
href="http://www.qhdok.com/home/link.php?url='.(substr(strtolower($url),
0, 4) == 'www.' ? 'http://'.$url : $url).'"
target="_blank">'.$text.'</a>';/*改了这里URL内嵌*/

}

return $returnval;

} else {

if(substr($url,0,1)=="="){

$url = substr($url, 1);

}

if(substr(strtolower($url), 0, 4) == 'www.') {

$url = 'http://'.$url;

}

$returnval="";

$temp=$url;

$temp=str_replace("www.","",str_replace("http://","",$temp));

if(substr($temp,0,9)=="qhdok.com"){

$returnval="<a href=".$url." target=_blank>".$text."</a>";

}else{

$returnval='<a
href="http://www.qhdok.com/home/link.php?url='.$url.'"
target="_blank">'.$text.'</a>';/*改了这里URL内嵌*/

}

return $returnval;

}

}

复制代码

.

还要修改一下home/link.php文件中的//游客直接跳转下面加//

if(empty($space)) {

//游客直接跳转

//showmessage('do_success', $url, 0);

}

复制代码

.

找到home/template/default/iframe.htm文件.

.

<td height="26" class="link_td">

<img src="image/icon/profile.gif"
align="absmiddle"> <a target="_blank"
href="http://www.qhdok.com/home/">返回我的空间</a> <span
class="pipe">|</span>

<img src="image/icon/share.gif"
align="absmiddle"> <a target="_blank"
href="http://www.qhdok.com/">秦皇岛论坛</a> <span
class="pipe">|</span>

<img src="image/icon/network.gif"
align="absmiddle"> <a target="_blank"
href="http://www.qhdok.com/qinhuangdaoditu.htm">秦皇岛地图</a>
<span class="pipe">|</span>

<img src="image/icon/profile.gif"
align="absmiddle"> <a href="javascript:;"
onClick="javascript:setCopy('http://www.qhdok.com/home/link.php?url=$url');return
false;">点击分享给朋友</a>

</td>

复制代码

OK!!!全改完了,别忘了更新缓存哦~!

转自:http://www.qhdok.com/thread-1448-1-1.html

教你有效防止外链广告!!!修改discuz的URL代码 - 秦皇岛论坛事务 - 秦皇岛论坛
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: