織夢(mèng)DEDECMS在PHP版本高于5.5的情況下無(wú)法使用關(guān)鍵詞內(nèi)鏈的解決方法

織夢(mèng)DEDECMS在PHP版本高于5.5的情況下無(wú)法使用關(guān)鍵詞內(nèi)鏈的解決方法:

打開(kāi)/include/arc.archives.class.php 找到 找到:

$body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body);

替換成:

global $cfg_replace_num;
if($cfg_replace_num > 0)
{
    $query = "SELECT * FROM #@__keywords WHERE rpurl<>'' ORDER BY rank DESC";
    $this->dsql->SetQuery($query);
    $this->dsql->Execute();
    while($row = $this->dsql->GetArray())
    {
        $key = trim($row['keyword']);
        $key_url=trim($row['rpurl']);
        $body = str_replace_limit($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body, $cfg_replace_num);
    }

}
else
{
    $query = "SELECT * FROM #@__keywords WHERE rpurl<>'' ORDER BY rank DESC";
    $this->dsql->SetQuery($query);
    $this->dsql->Execute();
    while($row = $this->dsql->GetArray())
    {
        $key = trim($row['keyword']);
        $key_url=trim($row['rpurl']);
        $body = str_replace($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body);
    }
}

搜索

//高亮專用

在它上面添加

//指定替換次數(shù)功能
function str_replace_limit($search, $replace, $subject, $limit)
{
    if(is_array($search))
    {
        foreach($search as $k=>$v)
        {
            $search[$k] = '`'. preg_quote($search[$k], '`'). '`';
        }
    }
    else
    {
        $search = '`'. preg_quote($search, '`'). '`';
    }
    return preg_replace($search, $replace, $subject, $limit);
}

 

THE END
亚洲中文色欧另类欧美,久久久久久久激情,亚洲 日韩 欧美 另类 国产,中文字幕高清无码男人的天堂 www.sucaiwu.net