|
|
@@ -29,30 +29,7 @@ function microtime_float()
|
|
|
$result = array();
|
|
|
$result["error"]="";
|
|
|
|
|
|
-switch($op){
|
|
|
- case "pre"://预查询
|
|
|
- {
|
|
|
- $time_start = microtime_float();
|
|
|
-
|
|
|
- $searching=$arrWordList[count($arrWordList)-1];
|
|
|
- $dbfile = _FILE_DB_WORD_INDEX_;
|
|
|
- PDO_Connect("sqlite:".$dbfile);
|
|
|
-
|
|
|
- if(count($arrWordList)>1){
|
|
|
- //echo "<div>";
|
|
|
- foreach($arrWordList as $oneword){
|
|
|
- //echo $oneword."+";
|
|
|
- }
|
|
|
- //echo "</div>";
|
|
|
- }
|
|
|
|
|
|
- $query = "SELECT word,count,bold FROM wordindex WHERE word_en like ? OR word like ? limit 0,20";
|
|
|
- $Fetch = PDO_FetchAll($query,array("{$searching}%","{$searching}%"));
|
|
|
- echo json_encode($Fetch,JSON_UNESCAPED_UNICODE);
|
|
|
- break;
|
|
|
- }
|
|
|
- case "search":
|
|
|
- {
|
|
|
$_pagesize = 20;
|
|
|
if(isset($_GET["page"])){
|
|
|
$_page = (int)$_GET["page"];
|
|
|
@@ -67,8 +44,20 @@ switch($op){
|
|
|
# 首先精确匹配
|
|
|
$words = implode(" ",$arrWordList);
|
|
|
$query = "SELECT book,paragraph, text FROM pali_text WHERE text like ? LIMIT ? , ?";
|
|
|
- $Fetch = PDO_FetchAll($query,array("%{$words}%",$_page*$_pagesize,$_pagesize));
|
|
|
- #然后查不精确的
|
|
|
+ $Fetch1 = PDO_FetchAll($query,array("%{$words}%",$_page*$_pagesize,$_pagesize));
|
|
|
+
|
|
|
+ foreach ($Fetch1 as $key => $value) {
|
|
|
+ # code...
|
|
|
+ $newRecode["title"]="title";
|
|
|
+ $newRecode["path"] = _get_para_path($value["book"],$value["paragraph"]);
|
|
|
+ $newRecode["book"] = $value["book"];
|
|
|
+ $newRecode["para"] = $value["paragraph"];
|
|
|
+ $newRecode["palitext"] = $value["text"];
|
|
|
+ $newRecode["keyword"] = $arrWordList;
|
|
|
+ $newRecode["wt"] = 0;
|
|
|
+ $out_data[] = $newRecode;
|
|
|
+ }
|
|
|
+ #然后查分散的
|
|
|
$strQuery="";
|
|
|
foreach($arrWordList as $oneword){
|
|
|
$strQuery.="\"text\" like \"% {$oneword} %\" AND";
|
|
|
@@ -76,19 +65,23 @@ switch($op){
|
|
|
$strQuery = substr($strQuery,0,-3);
|
|
|
|
|
|
$query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery} LIMIT 0,20";
|
|
|
- $Fetch = PDO_FetchAll($query);
|
|
|
+ $Fetch2 = PDO_FetchAll($query);
|
|
|
|
|
|
- $iFetch=count($Fetch);
|
|
|
- foreach($Fetch as $row){
|
|
|
- $html = $row["html"];
|
|
|
- foreach($arrWordList as $oneword){
|
|
|
- $html=str_replace($oneword,"<hl>{$oneword}</hl>",$html);
|
|
|
- }
|
|
|
- //echo "<div class='dict_word'>{$html}</div>";
|
|
|
+ foreach ($Fetch2 as $key => $value) {
|
|
|
+ # code...
|
|
|
+ $newRecode["title"]="title";
|
|
|
+ $newRecode["path"] = _get_para_path($value["book"],$value["paragraph"]);
|
|
|
+ $newRecode["book"] = $value["book"];
|
|
|
+ $newRecode["para"] = $value["paragraph"];
|
|
|
+ $newRecode["palitext"] = $value["text"];
|
|
|
+ $newRecode["keyword"] = $arrWordList;
|
|
|
+ $newRecode["wt"] = 0;
|
|
|
+ $out_data[] = $newRecode;
|
|
|
}
|
|
|
-
|
|
|
+ $result["data"] = $out_data;
|
|
|
+ echo json_encode($result,JSON_UNESCAPED_UNICODE);
|
|
|
# 然后查特别不精确的
|
|
|
- return;
|
|
|
+ exit;
|
|
|
}
|
|
|
|
|
|
//计算某词在三藏中出现的次数
|
|
|
@@ -277,117 +270,14 @@ switch($op){
|
|
|
$newRecode["book"] = $book;
|
|
|
$newRecode["para"] = $paragraph;
|
|
|
$newRecode["palitext"] = $FetchPaliText[0]["html"];
|
|
|
- $newRecode["keyword"] = $paliword;
|
|
|
- $newRecode["wt"] = $Fetch[$i]["wt"];
|
|
|
-// echo "<div class='mean' style='font-size:120%'><a href='../reader/?view=para&book={$book}¶={$paragraph}' target='_blank'>$path</a></div>";
|
|
|
-
|
|
|
+ $newRecode["keyword"] = array($paliword);
|
|
|
+ $newRecode["wt"] = $Fetch[$i]["wt"];
|
|
|
$out_data[] = $newRecode;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- $queryTime=(microtime_float()-$time_start)*1000;
|
|
|
$result["data"] = $out_data;
|
|
|
echo json_encode($result,JSON_UNESCAPED_UNICODE);
|
|
|
- break;
|
|
|
- }
|
|
|
- case "update":
|
|
|
- $target=$_GET["target"];
|
|
|
- switch($target){
|
|
|
- case "bold";
|
|
|
- $wordlist=$_GET["wordlist"];
|
|
|
- $booklist=$_GET["booklist"];
|
|
|
- $aBookList=ltrim($booklist,"(");
|
|
|
- $aBookList=rtrim($aBookList,")");
|
|
|
- $aBookList=str_replace("'","",$aBookList);
|
|
|
- $aBookList=str_getcsv($aBookList);
|
|
|
- $arrBookType=json_decode(file_get_contents("../public/book_name/booktype.json"));
|
|
|
- //查找这些词出现在哪些书中
|
|
|
- $newBookList=render_book_list($wordlist,$aBookList);
|
|
|
-
|
|
|
- //前20条记录
|
|
|
- $time_start=microtime_float();
|
|
|
- $dictFileName=_FILE_DB_PALI_INDEX_;
|
|
|
- PDO_Connect("sqlite:$dictFileName");
|
|
|
-
|
|
|
- $query = "select * from word where \"wordindex\" in $wordlist and \"book\" in $booklist group by book,paragraph limit 0,20";
|
|
|
- $Fetch = PDO_FetchAll($query);
|
|
|
- $queryTime=(microtime_float()-$time_start)*1000;
|
|
|
- //echo "<div >搜索时间:$queryTime </div>";
|
|
|
- if($booklist=="()"){
|
|
|
- echo "<div >请选择书名</div>";
|
|
|
- }
|
|
|
- $iFetch=count($Fetch);
|
|
|
- if($iFetch>0){
|
|
|
- $dictFileName=_FILE_DB_PALITEXT_;
|
|
|
- PDO_Connect("sqlite:$dictFileName");
|
|
|
- for($i=0;$i<$iFetch;$i++){
|
|
|
- $paliword=$Fetch[$i]["wordindex"];
|
|
|
- //$paliword=$wordlist["{$paliwordid}"];
|
|
|
-
|
|
|
- $book=$Fetch[$i]["book"];
|
|
|
- $bookInfo = _get_book_info($book);
|
|
|
- $bookname=$bookInfo->title;
|
|
|
- $c1=$bookInfo->c1;
|
|
|
- $c2=$bookInfo->c2;
|
|
|
- $c3=$bookInfo->c3;
|
|
|
- $paragraph=$Fetch[$i]["paragraph"];
|
|
|
-
|
|
|
- $path_1 = $c1.">";
|
|
|
- if($c2 !== ""){
|
|
|
- $path_1=$path_1.$c2.">";
|
|
|
- }
|
|
|
- if($c3 !== ""){
|
|
|
- $path_1=$path_1.$c3.">";
|
|
|
- }
|
|
|
- $path_1=$path_1."《{$bookname}》>";
|
|
|
-
|
|
|
- echo "<div class='dict_word'>";
|
|
|
- echo "<div class='book' ><span style='font-size:110%;font-weight:700;'>《{$bookname}》</span> <tag>$c1</tag> <tag>$c2</tag> </div>";
|
|
|
- echo "<div class='mean'>$paliword</div>";
|
|
|
-
|
|
|
- $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
|
|
|
- $FetchPaliText = PDO_FetchAll($query);
|
|
|
- $countPaliText=count($FetchPaliText);
|
|
|
- if($countPaliText>0){
|
|
|
- for($iPali=0;$iPali<$countPaliText;$iPali++){
|
|
|
- $path="";
|
|
|
- $parent = $FetchPaliText[0]["parent"];
|
|
|
- $deep=0;
|
|
|
- $sFirstParentTitle="";
|
|
|
- while($parent>-1){
|
|
|
- $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
|
|
|
- $FetParent = PDO_FetchAll($query);
|
|
|
- if($sFirstParentTitle==""){
|
|
|
- $sFirstParentTitle = $FetParent[0]["toc"];
|
|
|
- }
|
|
|
- $path="{$FetParent[0]["toc"]}>{$path}";
|
|
|
- $parent = $FetParent[0]["parent"];
|
|
|
- $deep++;
|
|
|
- if($deep>5){
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- $path=$path."No. ".$paragraph;
|
|
|
- echo "<div class='mean' style='font-size:120%;'><a href='../reader/?view=para&book={$book}¶={$paragraph}' target='_blank' >$path</a></div>";
|
|
|
-
|
|
|
- if(substr($paliword,-1)=="n"){
|
|
|
- $paliword=substr($paliword,0,-1);
|
|
|
- }
|
|
|
- $light_text=str_replace($paliword,"<hl>{$paliword}</hl>",$FetchPaliText[$iPali]["html"]);
|
|
|
- echo "<div class='wizard_par_div'>{$light_text}</div>";
|
|
|
- echo "<div class='search_para_tools'></div>";
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- echo "</div>";
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- break;
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
?>
|