有效防止外鏈廣告!!!修改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代碼 - 秦皇島論壇事務 -  秦皇島論壇

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章