2
0

note.php 1.8 KB

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