优晟seo笔记

您现在的位置是:首页 > CMS教程 > 帝国cms > 正文

帝国cms

帝国cms关键字替换修改

佚名 2023-12-08帝国cms
帝国cms在关键字替换的时候遇到乱码的情况,例如图片alt标签被替换;字母替换出现问题等情况。按照一下配置修改即可。 修改位置:/e/class/functions.php //替换关键字 start function ReplaceKey($newstext,$classid=0)……
帝国cms在关键字替换的时候遇到乱码的情况,例如图片alt标签被替换;字母替换出现问题等情况。按照一下配置修改即可。

修改位置:/e/class/functions.php

//替换关键字 start
function ReplaceKey($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[^>](.*)a>|<img[^>](.*)>|<pre[^>](.*)pre>|<h[^>](.*)h>|<video[^>](.*)video>|<dt[^>](.*)dt>|<th[^>](.*)th>|<script[^>](.*)script>|<!--[^>](.*)-->|<em[^>](.*)em>|<strong[^>](.*)strong>|<i[^>](.*)i>|<font[^>](.*)font>|<form[^>](.*)form>/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],'<a href="'.$r[keyurl].'" target="_blank" class="infotextkey">'.$r[keyname].'</a>',$newstext):preg_replace('/'.$r[keyname].'(?!([^<]*>)|([^<]*<a="">))/i','<a href="'.$r[keyurl].'" target="_blank" class="infotextkey">'.$r[keyname].'</a>',$newstext,$public_r[repkeynum]);
        }else{
            $newstext=empty($public_r[repkeynum])?str_replace($r[keyname],'<a href="'.$r[keyurl].'" target="_blank" class="infotextkey">'.$r[keyname].'</a>',$newstext):preg_replace('/'.$r[keyname].'(?!([^<]*>)|([^<]*<a="">))/i','<a href="'.$r[keyurl].'" target="_blank" class="infotextkey">'.$r[keyname].'</a>',$newstext,$public_r[repkeynum]);
        }
    }
    if($rs[0]){foreach($rs[0] as $k=>$v){$newstext=str_replace("[!--{$k}--]",$v,$newstext);}}
    return $newstext;
}
//替换关键字 end