2
0

pc_get_book_res.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. $currBook=$_GET["book"];
  3. $currParagraph=$_GET["paragraph"];
  4. $res_type=$_GET["res_type"];
  5. $language=$_GET["language"];
  6. $author=$_GET["author"];
  7. $editor=$_GET["editor"];
  8. $revision=$_GET["revision"];
  9. $edition=$_GET["edition"];
  10. $subver=$_GET["subver"];
  11. include "../path.php";
  12. include "./_pdo.php";
  13. include "./public.inc";
  14. $countInsert=0;
  15. $wordlist=array();
  16. $tempFile="temp.txt";
  17. $guid=GUIDv4();
  18. switch($res_type){
  19. case "wbw":
  20. if($author=="templet"){
  21. $db_file = _DIR_PALICANON_TEMPLET_."/".$currBook."_tpl.db3";
  22. }
  23. else{
  24. $db_file = "../appdata/palicanon/wbw/".$currBook."_wbw.db3";
  25. }
  26. break;
  27. case "heading":
  28. if($author=="templet"){
  29. $db_file = _FILE_DB_PALITEXT_;
  30. }
  31. else{
  32. $db_file = _FILE_DB_PALITEXT_;
  33. }
  34. break;
  35. case "translate":
  36. $db_file = _DIR_PALICANON_TRAN_."/".$currBook."_translate.db3";
  37. break;
  38. case "note":
  39. $db_file = "../appdata/palicanon/note/".$currBook."_note.db3";
  40. break;
  41. case "file":
  42. $db_file = "../appdata/palicanon/file/file.db3";
  43. break;
  44. }
  45. //open database
  46. //echo "$db_file";
  47. PDO_Connect("sqlite:$db_file");
  48. switch($res_type){
  49. case "wbw":
  50. if($author=="templet"){
  51. $query = "SELECT * FROM \"main\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"paragraph\" = ".$PDO->quote($currParagraph)." ORDER BY vri ";
  52. }
  53. else{
  54. $query = "SELECT * FROM \"main\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"paragraph\" = ".$PDO->quote($currParagraph)." AND \"language\" = ".$PDO->quote($language)." AND \"author\" = ".$PDO->quote($author)." AND \"editor\" = ".$PDO->quote($editor)." AND \"edition\" = ".$PDO->quote($edition)." AND \"subver\" = ".$PDO->quote($subver)." ORDER BY vri ";
  55. }
  56. break;
  57. case "heading":
  58. if($author=="templet"){
  59. $query = "SELECT * FROM \"data\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"paragraph\" = ".$PDO->quote($currParagraph);
  60. }
  61. else{
  62. $query = "SELECT * FROM \"data\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"par_num\" = ".$PDO->quote($currParagraph)." AND \"language\" = ".$PDO->quote($language)." AND \"author\" = ".$PDO->quote($author)." AND \"editor\" = ".$PDO->quote($editor)." AND \"edition\" = ".$PDO->quote($edition)." AND \"subver\" = ".$PDO->quote($subver);;
  63. }
  64. break;
  65. case "translate":
  66. $query="SELECT * FROM \"data\" WHERE \"paragraph\" = ".$PDO->quote($currParagraph)." AND \"language\" = ".$PDO->quote($language)." AND \"author\" = ".$PDO->quote($author)." AND \"editor\" = ".$PDO->quote($editor)." AND \"edition\" = ".$PDO->quote($edition)." AND \"subver\" = ".$PDO->quote($subver);
  67. break;
  68. case "note":
  69. $query="SELECT * FROM \"data\" WHERE \"paragraph\" = ".$PDO->quote($currParagraph)." AND \"language\" = ".$PDO->quote($language)." AND \"author\" = ".$PDO->quote($author)." AND \"editor\" = ".$PDO->quote($editor)." AND \"edition\" = ".$PDO->quote($edition)." AND \"subver\" = ".$PDO->quote($subver);
  70. break;
  71. case "file":
  72. $query="SELECT * FROM \"data\" WHERE \"paragraph\" = ".$PDO->quote($currParagraph)." AND \"language\" = ".$PDO->quote($language)." AND \"author\" = ".$PDO->quote($author)." AND \"editor\" = ".$PDO->quote($editor)." AND \"edition\" = ".$PDO->quote($edition)." AND \"subver\" = ".$PDO->quote($subver);
  73. break;
  74. }
  75. $Fetch = PDO_FetchAll($query);
  76. $iFetch=count($Fetch);
  77. if($iFetch>0){
  78. $outXml = "<pkg>";
  79. echo $outXml;
  80. //pakege head
  81. switch($res_type){
  82. case "wbw":
  83. $outXml = "<block>";
  84. $outXml .= "<info><id>$guid</id><type>$res_type</type><book>$currBook</book><paragraph>$currParagraph</paragraph><language>$language</language><author>$author</author><editor>$editor</editor><revision>$revision</revision><edition>$edition</edition><subver>$subver</subver></info>";
  85. $outXml .= "<data>";
  86. echo $outXml;
  87. break;
  88. case "heading":
  89. break;
  90. case "translate":
  91. $outXml = "<block>";
  92. $outXml .= "<info><id>$guid</id><type>$res_type</type><book>$currBook</book><paragraph>$currParagraph</paragraph><language>$language</language><author>$author</author><editor>$editor</editor><revision>$revision</revision><edition>$edition</edition><subver>$subver</subver></info>";
  93. $outXml .= "<data>";
  94. echo $outXml;
  95. break;
  96. case "note":
  97. $outXml = "<block>";
  98. $outXml .= "<info><id>$guid</id><type>$res_type</type><book>$currBook</book><paragraph>$currParagraph</paragraph><language>$language</language><author>$author</author><editor>$editor</editor><revision>$revision</revision><edition>$edition</edition><subver>$subver</subver></info>";
  99. $outXml .= "<data>";
  100. echo $outXml;
  101. break;
  102. case "file":
  103. $outXml = "<block>";
  104. $outXml .= "<info><id>$guid</id><type>$res_type</type><book>$currBook</book><paragraph>$currParagraph</paragraph><language>$language</language><author>$author</author><editor>$editor</editor><revision>$revision</revision><edition>$edition</edition><subver>$subver</subver></info>";
  105. $outXml .= "<data>";
  106. echo $outXml;
  107. break;
  108. }
  109. for($i=0;$i<$iFetch;$i++){
  110. switch($res_type){
  111. case "wbw":
  112. $outXml = "<word>";
  113. $outXml = $outXml."<id>".$Fetch[$i]["wid"]."</id>";
  114. $outXml = $outXml."<pali>".$Fetch[$i]["word"]."</pali>";
  115. $outXml = $outXml."<real>".$Fetch[$i]["real"]."</real>";
  116. $outXml = $outXml."<type>".$Fetch[$i]["type"]."</type>";
  117. $outXml = $outXml."<gramma>".$Fetch[$i]["gramma"]."</gramma>";
  118. $outXml = $outXml."<case>".$Fetch[$i]["type"]."#".$Fetch[$i]["gramma"]."</case>";
  119. $outXml = $outXml."<parent> </parent>";
  120. $outXml = $outXml."<mean>".$Fetch[$i]["mean"]."</mean>";
  121. $outXml = $outXml."<note>".$Fetch[$i]["note"]."</note>";
  122. $outXml = $outXml."<org>".$Fetch[$i]["part"]."</org>";
  123. $outXml = $outXml."<om>".$Fetch[$i]["partmean"]."</om>";
  124. $outXml = $outXml."<bmc>".$Fetch[$i]["bmc"]."</bmc>";
  125. $outXml = $outXml."<bmt>".$Fetch[$i]["bmt"]."</bmt>";
  126. $outXml = $outXml."<un>".$Fetch[$i]["un"]."</un>";
  127. $outXml = $outXml."<style>".$Fetch[$i]["style"]."</style>";
  128. $outXml = $outXml."<vri>".$Fetch[$i]["vri"]."</vri>";
  129. $outXml = $outXml."</word>";
  130. echo $outXml;
  131. break;
  132. case "heading":
  133. $outXml = "<block>";
  134. $outXml .= "<info><id>$guid</id><type>$res_type</type><book>$currBook</book><paragraph>$currParagraph</paragraph><language>$language</language><author>$author</author><editor>$editor</editor><revision>$revision</revision><edition>0</edition><subver>$subver</subver>";
  135. $outXml .= "<level>".$Fetch[$i]["level"]."</level>";
  136. $outXml .= "<style>".$Fetch[$i]["class"]."</style>";
  137. $outXml .= "</info>";
  138. $outXml .= "<data>";
  139. if($Fetch[$i]["level"]==0){
  140. $outXml .= "<text>".substr($Fetch[$i]["text"],0,10)."</text>";
  141. }
  142. else{
  143. $outXml .= "<text>".$Fetch[$i]["text"]."</text>";
  144. }
  145. $outXml .= "</data></block>";
  146. echo $outXml;
  147. break;
  148. case "translate":
  149. $outXml = "<sen>";
  150. $outXml = $outXml."<a>".$Fetch[$i]["anchor"]."</a>";
  151. $outXml = $outXml."<text>".$Fetch[$i]["text"]."</text>";
  152. $outXml = $outXml."</sen>";
  153. echo $outXml;
  154. break;
  155. }
  156. }
  157. }
  158. /*直接查询结束*/
  159. switch($res_type){
  160. case "wbw":
  161. $outXml = "</data></block></pkg>";
  162. break;
  163. case "heading":
  164. $outXml = "</pkg>";
  165. break;
  166. case "translate":
  167. $outXml = "</data></block></pkg>";
  168. break;
  169. case "note":
  170. $outXml = "</data></block></pkg>";
  171. break;
  172. case "file":
  173. $outXml = "</data></block></pkg>";
  174. break;
  175. }
  176. echo $outXml;
  177. ?>