首页 > 织梦禁止会员发布带超链接文章内容

织梦禁止会员发布带超链接文章内容

织梦CMS会员中心发布文章自动过滤外部外部链接,保留本站站内链接。这个织梦CMS默认后台本身带有这样的功能的,只是会员模块里没有而已。
织梦CMS禁止会员发布文章内容带超链接

织梦CMS禁止会员发布文章内容带超链接
我们可以把功能嫁接到会员模块里去使用,实现自动过滤外部链接。
打开“/member/inc/inc_archives_functions.php”,在文件的最后面加上:

/**
 *  删除非站内链接
 *
 * @access    public
 * @param     string  $body  内容
 * @param     array  $allow_urls  允许的超链接
 * @return    string
 */
function Replace_Links( &$body, $allow_urls=array()  )
{
    $host_rule = join('|', $allow_urls);
    $host_rule = preg_replace("#[/-/n/-/r]#", '', $host_rule);
    $host_rule = str_replace('.', "/-//-/.", $host_rule);
    $host_rule = str_replace('/', "/-//-//", $host_rule);
    $arr = '';
    preg_match_all("#<a([^>]*)>(.*)</-//a>#iU", $body, $arr);
    if( is_array($arr[0]) )
    {
        $rparr = array();
        $tgarr = array();
        foreach($arr[0] as $i=>$v)
        {
            if( $host_rule != '' && preg_match('#'.$host_rule.'#i', $arr[1][$i]) )
            {
                continue;
            } else {
                $rparr[] = $v;
                $tgarr[] = $arr[2][$i];
            }
        }
        if( !empty($rparr) )
        {
            $body = str_replace($rparr, $tgarr, $body);
        }
    }
    $arr = $rparr = $tgarr = '';
    return $body;
}

继续在这个文件中找到,大概在329行,
//自动摘要
在它上面加入

//删除非站内链接
$allow_urls = array($_SERVER['HTTP_HOST']);
//读取允许的超链接设置
if(file_exists(dedeDATA."/admin/allowurl.txt"))
{
 $allow_urls = array_merge($allow_urls, file(dedeDATA."/admin/allowurl.txt"));
}
$body = Replace_Links($body, $allow_urls);

织梦CMS禁止会员发布文章内容带超链接

DedeCMS推荐
织梦采集https链接时却生成http协...
织梦后台登录出现500错误解决方案
织梦首页调用自定义表单内容方法
织梦自定义表单地区联动类型不可用的解决办...
织梦模板文档关键词维护中频率详解
织梦后台栏目显示的文档数与实际文档数不一...