齊博CMS文章關(guān)鍵字加亮?xí)r圖片alt文字被替換的解決方法

字號:


    使用齊博CMS建站的時(shí)候會出現(xiàn)這樣一個(gè)問題,在后臺選擇內(nèi)容頁關(guān)鍵字加亮顯示的情況下,如果文中有圖片,并且圖片有alt描述,一旦描述中包含關(guān)鍵字的話,描述中的關(guān)鍵字會存在被替換。
    這一問題的解決方法如下:
    打開inc目錄下的artic_function.php文件,找到如下代碼中相應(yīng)的兩個(gè)函數(shù),替換成如下代碼即可:
    復(fù)制代碼代碼如下:function show_keyword($content){
    global $Key_word,$webdb,$pre,$db;
    if(!$webdb[ifShowKeyword]){
    return $content;
    }
    require_once(ROOT_PATH."data/keyword.php");
    //把圖片描述去掉
    //$content=preg_replace("/ alt=([^ >]+)/is","",$content);
    foreach( $Key_word AS $key=>$value){
    if(!$value){
    $value="$webdb[www_url]/do/search.php?type=title&keyword=".urlencode($key);
    }
    $search[]=$key;
    $replace[]="<a href=$value style=text-decoration:underline;font-size:14px;color:{$webdb[ShowKeywordColor]}; target=_blank>$key</a>";
    }
    $content=str_replace_limit($search,$replace,$content,2);
    return $content;
    }
    function str_replace_limit($search, $replace, $subject, $limit=-1) {
    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);
    }
    至此,問題得到解決。