quote($word.'%')." OR \"word\" like ".$PDO->quote($word.'%')." group by word limit 0,10"; $Fetch = PDO_FetchAll($query); if(count($Fetch)<5){ $query = "select word,meaning from term where \"eword\" like ".$PDO->quote('%'.$word.'%')." OR \"word\" like ".$PDO->quote('%'.$word.'%')." group by word limit 0,10"; $Fetch2 = PDO_FetchAll($query); //去掉重复的 foreach($Fetch2 as $onerow){ $found=false; foreach($Fetch as $oldArray){ if($onerow["word"]==$oldArray["word"]){ $found=true; break; } } if($found==false){ array_push($Fetch,$onerow); } } if(count($Fetch)<8){ $query = "select word,meaning from term where \"meaning\" like ".$PDO->quote($word.'%')." OR \"other_meaning\" like ".$PDO->quote($word.'%')." group by word limit 0,10"; $Fetch3 = PDO_FetchAll($query); $Fetch = array_merge($Fetch,$Fetch3); if(count($Fetch)<8){ $query = "select word,meaning from term where \"meaning\" like ".$PDO->quote('%'.$word.'%')." OR \"other_meaning\" like ".$PDO->quote('%'.$word.'%')." group by word limit 0,10"; $Fetch4 = PDO_FetchAll($query); //去掉重复的 foreach($Fetch4 as $onerow){ $found=false; foreach($Fetch as $oldArray){ if($onerow["word"]==$oldArray["word"]){ $found=true; break; } } if($found==false){ array_push($Fetch,$onerow); } } } } } echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); break; } case "my": { $query = "select guid,word,meaning,other_meaning from term where owner= ".$PDO->quote($username); $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); if($iFetch>0){ echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); } break; } case "allpali": { $query = "select word from term where 1 group by word"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); if($iFetch>0){ echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); } break; } case "allmean": { $query = "select meaning from term where \"word\" = ".$PDO->quote($word)." group by meaning"; $Fetch = PDO_FetchAll($query); foreach($Fetch as $one){ echo "".$one["meaning"]." "; } //echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); break; } case "load_id": { if(isset($_GET["id"])){ $id=$_GET["id"]; $query = "select * from term where \"guid\" = ".$PDO->quote($id); $Fetch = PDO_FetchAll($query); echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); } else{ echo json_encode(array(), JSON_UNESCAPED_UNICODE); } break; } case "search": { if(!isset($word)){ return; } if(trim($word)==""){ return; } echo"
{$word}
"; //查本人数据 echo "
";//My Term $query = "select * from term where \"word\" = ".$PDO->quote($word)." AND \"owner\"= ".$PDO->quote($username)." limit 0,30"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); $count_return+=$iFetch; if($iFetch>0){ for($i=0;$i<$iFetch;$i++){ $mean=$Fetch[$i]["meaning"]; $guid=$Fetch[$i]["guid"]; $dict_list[$guid]=$Fetch[$i]["owner"]; echo "
"; echo ""; echo "
"; echo "
Your
"; echo "
{$Fetch[$i]["tag"]}
"; echo "
".$mean."
"; echo "
".$Fetch[$i]["other_meaning"]."
"; echo "
".$Fetch[$i]["note"]."
"; echo "
"; //编辑词条表单 echo ""; echo "
"; //echo "";//Apply echo "";//Edit echo "
"; echo ""; echo "
"; } } //新建词条 echo "
"; echo ""; echo ""; echo "
"; //查他人数据 $query = "select * from term where \"word\" = ".$PDO->quote($word)."AND \"owner\" <> ".$PDO->quote($username)." limit 0,30"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); $count_return+=$iFetch; if($iFetch>0){ for($i=0;$i<$iFetch;$i++){ $mean=$Fetch[$i]["meaning"]; $guid=$Fetch[$i]["guid"]; $dict_list[$guid]=$Fetch[$i]["owner"]; echo "
"; echo ""; echo"
".$Fetch[$i]["owner"]."
"; echo "
".$mean."
"; echo "
".$Fetch[$i]["other_meaning"]."
"; echo "
".$Fetch[$i]["note"]."
"; echo "";//复制 echo "
"; } } //查内容 /* if($count_return<2){ $word1=$org_word; $wordInMean="%$org_word%"; echo $module_gui_str['editor']['1124'].":$org_word
"; $query = "select * from term where \"meaning\" like ".$PDO->quote($word)." limit 0,30"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); $count_return+=$iFetch; if($iFetch>0){ for($i=0;$i<$iFetch;$i++){ $mean=$Fetch[$i]["meaning"]; $pos=mb_stripos($mean,$word,0,"UTF-8"); if($pos){ if($pos>20){ $start=$pos-20; } else{ $start=0; } $newmean=mb_substr($mean,$start,100,"UTF-8"); } else{ $newmean=$mean; } $pos=mb_stripos($newmean,$word1,0,"UTF-8"); $head=mb_substr($newmean,0,$pos,"UTF-8"); $mid=mb_substr($newmean,$pos,mb_strlen($word1,"UTF-8"),"UTF-8"); $end=mb_substr($newmean,$pos+mb_strlen($word1,"UTF-8"),NULL,"UTF-8"); $heigh_light_mean="$head$mid$end"; $outXml = "
"; $outXml = $outXml."
".$Fetch[$i]["owner"]."
"; $outXml = $outXml."
".$Fetch[$i]["word"]."
"; $outXml = $outXml."
".$heigh_light_mean."
"; $outXml = $outXml."
{$Fetch[$i]["note"]}
"; $outXml = $outXml."
"; echo $outXml; } } } */ //查内容结束 echo "
"; echo "
"; break; } case "save": { $currTime=sprintf("%d",microtime(true)*1000); if(isset($_GET["modify_time"])){ $mTime=$_GET["modify_time"]; } else{ $mTime=time(); } if($_GET["guid"]!=""){ $mean=$_GET["mean"]; $query="UPDATE term SET meaning='$mean' , other_meaning='".$_GET["mean2"]."' , tag='".$_GET["tag"]."' , receive_time='".time()."' , modify_time='$mTime' , note='".$_GET["note"]."' where guid='".$_GET["guid"]."'"; } else{ $newGuid=UUID::v4(); $word=$_GET["word"]; $worden=pali2english($word); $mean=$_GET["mean"]; $mean2=$_GET["mean2"]; $note=$_GET["note"]; $tag=$_GET["tag"]; $time=time(); $query="INSERT INTO term VALUES (NULL, '$newGuid', '$word', '$worden', '$mean', '$mean2', '$note', '$tag', '$time', '$username', '1', 'zh', '$time', '$time')"; } $stmt = @PDO_Execute($query); $respond=array("status"=>0,"message"=>""); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); $respond['status']=1; $respond['message']=$error[2].$query; } else{ $respond['status']=0; $respond['message']=$word; } echo json_encode($respond, JSON_UNESCAPED_UNICODE); break; } case "copy"://拷贝到我的字典 { $query = "select * from term where \"guid\" = ".$PDO->quote($_GET["wordid"]); $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); if($iFetch>0){ /* 开始一个事务,关闭自动提交 */ $PDO->beginTransaction(); $query="INSERT INTO term ('id','guid','word','word_en','meaning','other_meaning','note','tag','create_time','owner','hit') VALUES (null,?,?,?,?,?,?,?,".time().",'$username',1)"; $stmt = $PDO->prepare($query); { $stmt->execute(array(UUID::v4, $Fetch[0]["word"], $Fetch[0]["word_en"], $Fetch[0]["meaning"], $Fetch[0]["other_meaning"], $Fetch[0]["note"], $Fetch[0]["tag"], )); } /* 提交更改 */ $PDO->commit(); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); echo "error - $error[2]
"; } else{ echo "updata ok."; } } break; } case "extract": { if(isset($_POST["words"])){ $words=$_POST["words"]; } if(isset($_POST["authors"])){ $authors=str_getcsv($_POST["authors"]); } $query = "select * from term where \"word\" in {$words} limit 0,1000"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); break; } case "sync": { $time=$_GET["time"]; $query = "select guid,modify_time from term where receive_time>'{$time}' limit 0,1000"; $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); break; } case "get": { $Fetch = array(); if(isset($guid)){ $query = "select * from term where \"guid\" = '{$guid}'"; } else if(isset($word)){ $query = "select * from term where \"word\" = '{$word}'"; } else{ echo "[]"; return; } $Fetch = PDO_FetchAll($query); $iFetch=count($Fetch); echo json_encode($Fetch, JSON_UNESCAPED_UNICODE); break; } } ?>