解决帝国CMS设置关键词与内容图片链接冲突问题

由于前期整理文章没有进行格式化信息处理,导致有些包含代码修改的信息,根式混乱看不清楚。如果发现有此类问题,请在下方评论留言,墨鱼第一时间进行格式化整理!感谢配合

以下是解决方法,已测试!

在e/class/functions.php中,查找代码:“ function ReplaceKey( n e w s t e x t , newstext, newstext,classid=0)” 或 “//替换关键字”(有时打开为utf-8时中文显示为乱码)

把这一大段大部分(即:“//替换关键字”部分)替换为以下代码:


//替换关键字

function ReplaceKey( n e w s t e x t , newstext, newstext,classid=0){

global $empire,$dbtbpre,$public_r,$class_r;

if(empty($newstext)||$class_r[$classid]['keycid']==-1)

{return $newstext;}

$where='';

if(!empty($class_r[$classid]['keycid']))

{

    $where=" where cid='".$class_r[$classid]['keycid']."'";

}

$newstext=stripslashes($newstext);

preg_match_all('/](.*)a>|](.*)>/isU',stripslashes($newstext),$rs);



if($rs[0]){

    foreach($rs[0] as $k=>$v){

        $newstext=str_replace($v,"[!--{$k}--]",$newstext); 

    }

}

$sql=$empire->query("select keyname,keyurl from {$dbtbpre}enewskey".$where);

while($r=$empire->fetch($sql))

{

    if(STR_IREPLACE)

    {

        $newstext=empty($public_r[repkeynum])?str_ireplace($r[keyname],''.$r[keyname].'',$newstext):preg_replace('/'.$r[keyname].'/i',''.$r[keyname].'',$newstext,$public_r[repkeynum]);

    }

    else

    {

        $newstext=empty($public_r[repkeynum])?str_replace($r[keyname],''.$r[keyname].'',$newstext):preg_replace('/'.$r[keyname].'/i',''.$r[keyname].'',$newstext,$public_r[repkeynum]);

    }

}

if($rs[0]){

    foreach($rs[0] as $k=>$v){

        $newstext=str_replace("[!--{$k}--]",$v,$newstext); 

    }

}

return $newstext;

}

示例链接:
http://www.gufengba.com/content/2036.html
http://www.gufengba.com/content/2037.html
http://www.gufengba.com/content/2038.html
http://www.gufengba.com/content/2039.html
http://www.gufengba.com/content/2040.html
http://www.gufengba.com/content/2041.html
http://www.gufengba.com/content/2042.html
http://www.gufengba.com/content/2043.html
http://www.gufengba.com/content/2044.html
http://www.gufengba.com/content/2045.html
http://www.gufengba.com/content/2046.html
http://www.gufengba.com/content/2047.html
http://www.gufengba.com/content/2048.html
http://www.gufengba.com/content/2049.html
http://www.gufengba.com/content/2050.html
http://www.gufengba.com/content/2051.html
http://www.gufengba.com/content/2052.html
http://www.gufengba.com/content/2053.html
http://www.gufengba.com/content/2054.html
http://www.gufengba.com/content/2055.html

你可能感兴趣的:(解决帝国CMS设置关键词与内容图片链接冲突问题)