note.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once "../public/_pdo.php";
  3. require_once "../public/function.php";
  4. require_once "../path.php";
  5. if(isset($_GET["id"])){
  6. $id=$_GET["id"];
  7. }
  8. else{
  9. echo "error: no id";
  10. return;
  11. }
  12. if(isset($_GET["info"])){
  13. $info=$_GET["info"];
  14. }
  15. else{
  16. echo "error: no info";
  17. return;
  18. }
  19. $arrInfo = str_getcsv($info,"@");
  20. $arrSent = str_getcsv($arrInfo[0],"-");
  21. $bookId=$arrSent[0];
  22. $para=$arrSent[1];
  23. $begin=$arrSent[2];
  24. $end=$arrSent[3];
  25. $db_file = _DIR_PALICANON_TEMPLET_."/p".$bookId."_tpl.db3";
  26. PDO_Connect("sqlite:$db_file");
  27. $query="SELECT * FROM 'main' WHERE (\"paragraph\" = ".$PDO->quote($para)." ) ";
  28. $sth = $PDO->prepare($query);
  29. $sth->execute();
  30. $palitext="";
  31. while($result = $sth->fetch(PDO::FETCH_ASSOC))
  32. {
  33. $index =$result["wid"];
  34. if($index>=$begin && $index<=$end){
  35. if($result["type"]!=".ctl."){
  36. $paliword=$result["word"];
  37. if($result["style"]=="bld"){
  38. if(strchr($result["word"],"{")!=FALSE && strchr($result["word"],"}")!=FALSE ){
  39. $paliword = str_replace("{","<strong>",$paliword);
  40. $paliword = str_replace("}","</strong>",$paliword);
  41. }
  42. else{
  43. $paliword = "<strong>{$paliword}</strong>";
  44. }
  45. }
  46. $palitext .= $paliword." ";
  47. }
  48. }
  49. }
  50. $para_path=_get_para_path($bookId,$para);
  51. //find out translation
  52. $tran="";
  53. $db_file=_FILE_DB_SENTENCE_;
  54. try{
  55. PDO_Connect("sqlite:$db_file");
  56. $query="SELECT * FROM sentence WHERE book='{$bookId}' AND paragraph='{$para}' AND begin='{$begin}' AND end='{$end}' AND text <> '' order by modify_time DESC limit 0 ,1 ";
  57. $Fetch = PDO_FetchAll($query);
  58. $iFetch=count($Fetch);
  59. if($iFetch>0){
  60. $tran = $Fetch[0]["text"];
  61. }
  62. }
  63. catch (Exception $e) {
  64. $tran = $e->getMessage();
  65. //echo 'Caught exception: ', $e->getMessage(), "\n";
  66. }
  67. $output=array("id"=>$id,"palitext"=>$palitext,"tran"=>$tran,"ref"=>$para_path,"tran_count"=>$iFetch);
  68. echo json_encode($output, JSON_UNESCAPED_UNICODE);