Discuz教程网

[已解决]请问X2.0怎么做到:外链本窗口打开? 谢谢

[复制链接]
authicon leung 发表于 2012-2-24 15:07:44 | 显示全部楼层 |阅读模式
请问X2.0怎么做到:外链本窗口打开?
谢谢
最佳答案
avatar
2012-2-24 20:28:40
source\function\function_discuzcode.php
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));
                }
                return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
        } else {
                $url = substr($url, 1);
                if(substr(strtolower($url), 0, 4) == 'www.') {
                        $url = 'http://'.$url;
                }
                $url = !$scheme ? $_G['siteurl'].$url : $url;
                return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
        }
}

把红色的删了



上一篇:怎么能把帖子转自改成在下在帖子下边呢
下一篇:回帖过滤词后台搜索与删除
authicon dly 发表于 2012-2-24 20:28:40 | 显示全部楼层    本楼为最佳答案   
source\function\function_discuzcode.php
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));
                }
                return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
        } else {
                $url = substr($url, 1);
                if(substr(strtolower($url), 0, 4) == 'www.') {
                        $url = 'http://'.$url;
                }
                $url = !$scheme ? $_G['siteurl'].$url : $url;
                return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
        }
}

把红色的删了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 14:28

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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