1 頁 (共 1 頁)

[建議] 解決PHPBB 2.0.6發表時出現錯誤的問題

發表於 : 2003-11-28 23:11
ecap
●架設主機作業系統:Window 2000 Pro/Server
●安裝程式:IIS 5.0 + PHP 4.3.4 + PHPBB 2.0.6 + SQL Server 2000

PHPBB 2.0.6

page: functions_search.php
function: clean_words($mode, &$entry, &$stopword_list, &$synonym_list)
line: 50

發生問題原因:
程式直接使用 str_replace 函式 做字串取代,
使得中文字低階字元中含有 clean_words 定義取代的字元被取代成空字串\r
造成資料錯誤, 且存入資料庫時 SQL 語法也會出錯\r

以下為修改方式 (已測試)

修改前:
//
// Filter out strange characters like ^, $, &, change "it's" to "its"
//
for($i = 0; $i < count($drop_char_match); $i++)
{
$entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
}

修改後:
//
// Filter out strange characters like ^, $, &, change "it's" to "its"
//
$big5chrAry = array('@','[','\\\',']','^','_','`','{','|','~','}'); // Big5 低位元會用到的字碼\r
$entrytmp = substr($entry,0,1);
for ($j = 1; $j< strlen($entry);$j++)
{
$hightbig5 = Ord(substr($entry,$j-1,1));
$lowbig5 = substr($entry,$j,1);
$lowbig5tmp = $lowbig5;

foreach ($big5chrAry as $big5chr)
{
if (!($lowbig5tmp==$lowbig5 && $lowbig5 == $big5chr && $hightbig5 > 161 && $hightbig5 <= 255))
{
//當判定不是 Big5 字元時
for($i = 0; $i < count($drop_char_match); $i++)
{
if ($lowbig5 == $drop_char_match[$i])
{
$lowbig5tmp = $drop_char_replace[$i];
}
}
}
}
$entrytmp .= $lowbig5;
}
$entry = $entrytmp;

//This program writed by William Liu