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