Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

Discuz! X2 RC实现URL跳转,屏蔽外部链接

[复制链接]
指点江山007 发表于 2011-12-20 15:33:56 | 显示全部楼层 |阅读模式
       Discuz X2自动实现外部链接跳转,防止灌水。
       找到source\function\function_discuzcode.php文件
       修改函数function parseurl($url, $text, $scheme){....}为
function parseurl($url, $text, $scheme) {
global $_G;
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
  $url = $matches[0];
  $length = 65;
  if(strlen($url) > $length) {
   $text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
  }
  $url = substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url;
} else {
  $url = substr($url, 1);
  if(substr(strtolower($url), 0, 4) == 'www.') {
   $url = 'http://'.$url;
  }
  $url = !$scheme ? $_G['siteurl'].$url : $url;
}
preg_match("/^http:\/\/[^\/]+/",$url,$matchs);
$allowURL = array(".com");//这个是允许的域名
if(!in_array(substr($matchs[0],7),$allowURL)){
  $url = "http://haodehui.com/goto.php?url=".base64_encode($url);//这个是跳转后的网址,
//url使用的base64_encode加密方式,用base64_decode解密就行
}
return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
}

原文地址:http://yijun.sinaapp.com/post-5.html
zhudecheng 发表于 2011-12-20 18:04:24 | 显示全部楼层
回复

使用道具 举报

苍海浮尘 发表于 2011-12-20 18:22:29 | 显示全部楼层
全屏了也不好、提示就好
回复

使用道具 举报

carmov 发表于 2011-12-20 18:24:04 | 显示全部楼层
顶了!!!!!:'(:'(
回复

使用道具 举报

rlbnm 发表于 2011-12-21 03:05:56 | 显示全部楼层
为了什么要?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-4 21:19 , Processed in 0.107145 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表