header("Content-Type: text/html; charset=GB2312");
?>
//header("Content-Type: text/html; charset=gb2312");
$zh = $_GET["q"];
//echo $zh;
//echo "缩略输入:".pinyin($zh)."
"; //不用缩略词查询,太多重复
$txt3 = $zh;//pinyin($zh);
if (strlen($txt3) > 2)//如果大于 0,则与数据数组一一匹配
{
$hint="";
$list = count(file('tm.db'));//数据量
$txt11=file('tm.db');//题目数据
$txt22=file('dm.db');//代码数据
$txt33=file('da.db');//答案数据
$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
// 如果未找到提示,则把输出设置为 "no suggestion"
// 否则设置为正确的值
if ($hint == "")
{
$response="
抱歉,该问题的答案暂时未被收录到本答题库中
目前已添加的题库有 bilibili答题,寻仙答题,爱宠国答题,忘仙答题,梦想世界答题,魔域答题,问道答题,女神联盟答题,新仙剑答题
当前正在更新的题库是:QQ网吧答题闯关题库
其他题库正在努力收录中
如果你有相应的题目和答案添加可点击帮助页面联系
";
}elseif(strlen($hint)>5000){
$response="注意:搜索到匹配结果过多,只显示部分结果 共搜索到 ".$texthang." 条数据
".substr($hint,0,5000);
}
else
{
$response=$hint;
}
//输出响应
echo $response;
/////////////////////////////////////////////////////
$list = count(file('tm.db'));
// "累计题库数量:".$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;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
?>