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

教你有效防止外链广告!!!修改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

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

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

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

  1. function parseurl($url, $text) {
  2.         if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:|www/.)[^/[/"']+/i", trim($text), $matches)) {
  3.                 $url = $matches[0];
  4.                 $returnval="";
  5.                 $length = 65;
  6.                 if(strlen($url) > $length) {
  7.                         $text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
  8.                 }
  9.                 $temp=$url;
  10.                 $temp=str_replace("www.","",str_replace("http://","",$temp));
  11.                
  12.                 if(substr($temp,0,9)=="qhdok.com"){
  13.                         if(substr($url,0,4)!="http"){
  14.                                 $url="http://".$url;
  15.                         }
  16.                         $returnval="<a href=".$url." target=_blank>".$text."</a>";
  17.                 }else{
  18.                         $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内嵌*/
  19.                 }
  20.                 return $returnval;
  21.         } else {
  22.                 if(substr($url,0,1)=="="){
  23.                         $url = substr($url, 1);
  24.                 }
  25.                 if(substr(strtolower($url), 0, 4) == 'www.') {
  26.                         $url = 'http://'.$url;
  27.                 }
  28.                 $returnval="";
  29.                 $temp=$url;
  30.                 $temp=str_replace("www.","",str_replace("http://","",$temp));
  31.                 if(substr($temp,0,9)=="qhdok.com"){
  32.                         $returnval="<a href=".$url." target=_blank>".$text."</a>";
  33.                 }else{
  34.                         $returnval='<a href="http://www.qhdok.com/home/link.php?url='.$url.'" target="_blank">'.$text.'</a>';/*改了这里URL内嵌*/
  35.                 }
  36.                 return $returnval;
  37.         }
  38. }
复制代码

.

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

  1. if(empty($space)) {
  2.         //游客直接跳转
  3.         //showmessage('do_success', $url, 0);
  4. }
复制代码

.

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

.

  1. <td height="26" class="link_td">
  2.                         <img src="image/icon/profile.gif" align="absmiddle"> <a target="_blank" href="http://www.qhdok.com/home/">返回我的空间</a> <span class="pipe">|</span>
  3.                         <img src="image/icon/share.gif" align="absmiddle"> <a target="_blank" href="http://www.qhdok.com/">秦皇岛论坛</a> <span class="pipe">|</span>
  4.                         <img src="image/icon/network.gif" align="absmiddle"> <a target="_blank" href="http://www.qhdok.com/qinhuangdaoditu.htm">秦皇岛地图</a> <span class="pipe">|</span>
  5.                         <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>
  6.                 </td>
复制代码

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

转自:http://www.qhdok.com/thread-1448-1-1.html
教你有效防止外链广告!!!修改discuz的URL代码 - 秦皇岛论坛事务 -  秦皇岛论坛

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值