織夢ドキュメントキーワードメンテナンスで単語が重なるとエラーが発生する修正方法を設定します

2799 ワード

織夢システムのドキュメントキーワードメンテナンスを使用して、2つのキーワードを「織夢」と「織夢さん」に追加すると、文章に「織夢さん」という言葉が出てくると、アンカーテキストHTMLがエラーになり、phpバージョンが5.5を超えるとエラーになります.2つの関数を変更する必要があります.同じファイル(include/arc.archives.class.php)で、1つはクラスArchivesのReplaceKeyword()関数で、もう1つはファイルの最後尾の_highlight()関数.
 /**
     *       ,   alt title        
     *
     * @param string $kw
     * @param string $body
     * @return string
     */
    function ReplaceKeyword($kw,&$body)
    {
        global $cfg_cmspath;
        $maxkey = 5;
        $kws = explode(",",trim($kw));    //       
        $i=0;
        $karr = $kaarr = $GLOBALS['replaced'] = array();

        //       
        $body = preg_replace("#()(.*)()#isU", '\\1-]-\\4-[-\\6', $body);
// $query = "SELECT * FROM #@__keywords WHERE rpurl<>'' ORDER BY rank DESC"; // オリジナル
$query="SELECT * FROM `#@__keywords` WHERE rpurl<>'' and sta=1 ORDER BY length(keyword) DESC"; //      キーワードの  
$this->dsql->SetQuery($query);
$this->dsql->Execute();
while($row = $this->dsql->GetArray())
{
$key = trim($row['keyword']);
$key_url=trim($row['rpurl']);
$karr[] = $key;
$kaarr[] = "$key"; //        ,  class  
        }

        //         
        // $body = @preg_replace("#(^|>)([^ $word)
		{  
			$body = preg_replace("/(^|>)([^";  
			//       
			$body = preg_replace("/()/isU", '\\1>\\3)(.*)()/isU", '\\1-]-\\4-[-\\6', $body);  
}
//ハイパーリンクの  
$body = preg_replace("#()#isU", '\\1>\\3
//    ,               
function _highlight($string, $words, $result, $pre)
{
    global $cfg_replace_num;
    $string = str_replace('\"', '"', $string);
	if($GLOBALS['replaced'][$words] == 1){
		return $pre.$string;
	}
    if($cfg_replace_num > 0)
    {
        // foreach ($words as $key => $word)
        // {
        //     if($GLOBALS['replaced'][$word] == 1)
        //     {
        //         continue;
        //     }
            //$string = preg_replace("#".preg_quote($key)."#", $result[$key], $string, $cfg_replace_num);
            $string = preg_replace("#".preg_quote($words)."#", $result, $string, $cfg_replace_num);  //    
            if(strpos($string, $words) !== FALSE)
            {
                $GLOBALS['replaced'][$words] = 1;
            }
        // }
    }
    else
    {
        $string = str_replace($words, $result, $string);
    }
    return $pre.$string;
}