header("Content-Type: text/html; charset=GB2312");
?>
//header("Content-Type: text/html; charset=gb2312");
$zh = $_GET["q"];
//echo $zh;
//echo "縮略輸入:".pinyin($zh)."
"; //不用縮略詞查詢,太多重復(fù)
$txt3 = $zh;//pinyin($zh);
if (strlen($txt3) > 2)//如果大于 0,則與數(shù)據(jù)數(shù)組一一匹配
{
$hint="";
$list = count(file('tm.db'));//數(shù)據(jù)量
$txt11=file('tm.db');//題目數(shù)據(jù)
$txt22=file('dm.db');//代碼數(shù)據(jù)
$txt33=file('da.db');//答案數(shù)據(jù)
$textlength=0;
$texthang=0;
while($textlength<$list){
if (stristr($txt11[$textlength],$txt3) != false){
$hint = $hint."
"."題目:".$txt11[$textlength].""." ?答案:".$txt33[$textlength]."";
$texthang=$texthang+1;
}//if end
$textlength=$textlength+1;
}//while end
}//if end
// 如果未找到提示,則把輸出設(shè)置為 "no suggestion"
// 否則設(shè)置為正確的值
if ($hint == "")
{
$response="
抱歉昔脯,該問題的答案暫時(shí)未被收錄到本答題庫中
目前已添加的題庫有 bilibili答題鳍咱,尋仙答題级零,愛寵國答題富纸,忘仙答題集畅,夢(mèng)想世界答題能真,魔域答題,問道答題赁严,女神聯(lián)盟答題,新仙劍答題
當(dāng)前正在更新的題庫是:QQ網(wǎng)吧答題闖關(guān)題庫
其他題庫正在努力收錄中
如果你有相應(yīng)的題目和答案添加可點(diǎn)擊幫助頁面聯(lián)系
";
}elseif(strlen($hint)>5000){
$response="注意:搜索到匹配結(jié)果過多粉铐,只顯示部分結(jié)果 共搜索到 ".$texthang." 條數(shù)據(jù)
".substr($hint,0,5000);
}
else
{
$response=$hint;
}
//輸出響應(yīng)
echo $response;
/////////////////////////////////////////////////////
$list = count(file('tm.db'));
// "累計(jì)題庫數(shù)量:".$list."條
";
echo "
最新寫入題庫的是:";
$txt=file('tm.db'); echo "題目\"".$txt[$list-1]."\" - ";
$txt=file('da.db'); echo "答案\"".$txt[$list-1]."\"
";
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* PHP獲取中文漢字首字母方法 有部分漢字的首字母不正確
* $Id: getPinyin.php $
* $Author: WebArch $
* $Date: 2011-12-01 $
*/
function getFirstLetter($str){
$fchar = ord($str{0});
if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($str{0});
$s1 = iconv("UTF-8","gb2312", $str);
$s2 = iconv("gb2312","UTF-8", $s1);
if($s2 == $str){$s = $s1;}
else{$s = $str;}
$asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
if($asc >= -20319 and $asc <= -20284) return "A";
if($asc >= -20283 and $asc <= -19776) return "B";
if($asc >= -19775 and $asc <= -19219) return "C";
if($asc >= -19218 and $asc <= -18711) return "D";
if($asc >= -18710 and $asc <= -18527) return "E";
if($asc >= -18526 and $asc <= -18240) return "F";
if($asc >= -18239 and $asc <= -17923) return "G";
if($asc >= -17922 and $asc <= -17418) return "H";
if($asc >= -17417 and $asc <= -16475) return "J";
if($asc >= -16474 and $asc <= -16213) return "K";
if($asc >= -16212 and $asc <= -15641) return "L";
if($asc >= -15640 and $asc <= -15166) return "M";
if($asc >= -15165 and $asc <= -14923) return "N";
if($asc >= -14922 and $asc <= -14915) return "O";
if($asc >= -14914 and $asc <= -14631) return "P";
if($asc >= -14630 and $asc <= -14150) return "Q";
if($asc >= -14149 and $asc <= -14091) return "R";
if($asc >= -14090 and $asc <= -13319) return "S";
if($asc >= -13318 and $asc <= -12839) return "T";
if($asc >= -12838 and $asc <= -12557) return "W";
if($asc >= -12556 and $asc <= -11848) return "X";
if($asc >= -11847 and $asc <= -11056) return "Y";
if($asc >= -11055 and $asc <= -10247) return "Z";
return null;
}
function pinyin($zh){
$ret = "";
$s1 = iconv("UTF-8","gb2312", $zh);
$s2 = iconv("gb2312","UTF-8", $s1);
if($s2 == $zh){$zh = $s1;}
for($i = 0; $i < strlen($zh); $i++){
$s1 = substr($zh,$i,1);
$p = ord($s1);
if($p > 160){
$s2 = substr($zh,$i++,2);
$ret .= getFirstLetter($s2);
}else{
$ret .= $s1;
}
}
return $ret;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
?>