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