pc_get_book_res.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 "./config.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 = "../appdata/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 = "../appdata/palicanon/templet/toc.db3";
  30. $db_file = "../appdata/palicanon/pali_text/".$currBook."_pali.db3";
  31. }
  32. else{
  33. $db_file = "../appdata/palicanon/heading/toc.db3";
  34. }
  35. break;
  36. case "translate":
  37. $db_file = "../appdata/palicanon/translate/".$currBook."_translate.db3";
  38. break;
  39. case "note":
  40. $db_file = "../appdata/palicanon/note/".$currBook."_note.db3";
  41. break;
  42. case "file":
  43. $db_file = "../appdata/palicanon/file/file.db3";
  44. break;
  45. }
  46. //open database
  47. //echo "$db_file";
  48. PDO_Connect("sqlite:$db_file");
  49. switch($res_type){
  50. case "wbw":
  51. if($author=="templet"){
  52. $query = "SELECT * FROM \"main\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"paragraph\" = ".$PDO->quote($currParagraph)." ORDER BY vri ";
  53. }
  54. else{
  55. $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 ";
  56. }
  57. break;
  58. case "heading":
  59. if($author=="templet"){
  60. $query = "SELECT * FROM \"data\" WHERE \"book\" = ".$PDO->quote($currBook)." AND \"paragraph\" = ".$PDO->quote($currParagraph);
  61. }
  62. else{
  63. $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);;
  64. }
  65. break;
  66. case "translate":
  67. $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);
  68. break;
  69. case "note":
  70. $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);
  71. break;
  72. case "file":
  73. $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);
  74. break;
  75. }
  76. $Fetch = PDO_FetchAll($query);
  77. $iFetch=count($Fetch);
  78. if($iFetch>0){
  79. $outXml = "<pkg>";
  80. echo $outXml;
  81. //pakege head
  82. switch($res_type){
  83. case "wbw":
  84. $outXml = "<block>";
  85. $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>";
  86. $outXml .= "<data>";
  87. echo $outXml;
  88. break;
  89. case "heading":
  90. break;
  91. case "translate":
  92. $outXml = "<block>";
  93. $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>";
  94. $outXml .= "<data>";
  95. echo $outXml;
  96. break;
  97. case "note":
  98. $outXml = "<block>";
  99. $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>";
  100. $outXml .= "<data>";
  101. echo $outXml;
  102. break;
  103. case "file":
  104. $outXml = "<block>";
  105. $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>";
  106. $outXml .= "<data>";
  107. echo $outXml;
  108. break;
  109. }
  110. for($i=0;$i<$iFetch;$i++){
  111. switch($res_type){
  112. case "wbw":
  113. $outXml = "<word>";
  114. $outXml = $outXml."<id>".$Fetch[$i]["wid"]."</id>";
  115. $outXml = $outXml."<pali>".$Fetch[$i]["word"]."</pali>";
  116. $outXml = $outXml."<real>".$Fetch[$i]["real"]."</real>";
  117. $outXml = $outXml."<type>".$Fetch[$i]["type"]."</type>";
  118. $outXml = $outXml."<gramma>".$Fetch[$i]["gramma"]."</gramma>";
  119. $outXml = $outXml."<case>".$Fetch[$i]["type"]."#".$Fetch[$i]["gramma"]."</case>";
  120. $outXml = $outXml."<parent> </parent>";
  121. $outXml = $outXml."<mean>".$Fetch[$i]["mean"]."</mean>";
  122. $outXml = $outXml."<note>".$Fetch[$i]["note"]."</note>";
  123. $outXml = $outXml."<org>".$Fetch[$i]["part"]."</org>";
  124. $outXml = $outXml."<om>".$Fetch[$i]["partmean"]."</om>";
  125. $outXml = $outXml."<bmc>".$Fetch[$i]["bmc"]."</bmc>";
  126. $outXml = $outXml."<bmt>".$Fetch[$i]["bmt"]."</bmt>";
  127. $outXml = $outXml."<un>".$Fetch[$i]["un"]."</un>";
  128. $outXml = $outXml."<style>".$Fetch[$i]["style"]."</style>";
  129. $outXml = $outXml."<vri>".$Fetch[$i]["vri"]."</vri>";
  130. $outXml = $outXml."</word>";
  131. echo $outXml;
  132. break;
  133. case "heading":
  134. $outXml = "<block>";
  135. $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>";
  136. $outXml .= "<level>".$Fetch[$i]["level"]."</level>";
  137. $outXml .= "<style>".$Fetch[$i]["class"]."</style>";
  138. $outXml .= "</info>";
  139. $outXml .= "<data>";
  140. if($Fetch[$i]["level"]==0){
  141. $outXml .= "<text>".substr($Fetch[$i]["text"],0,10)."</text>";
  142. }
  143. else{
  144. $outXml .= "<text>".$Fetch[$i]["text"]."</text>";
  145. }
  146. $outXml .= "</data></block>";
  147. echo $outXml;
  148. break;
  149. case "translate":
  150. $outXml = "<sen>";
  151. $outXml = $outXml."<a>".$Fetch[$i]["anchor"]."</a>";
  152. $outXml = $outXml."<text>".$Fetch[$i]["text"]."</text>";
  153. $outXml = $outXml."</sen>";
  154. echo $outXml;
  155. break;
  156. }
  157. }
  158. }
  159. /*直接查询结束*/
  160. switch($res_type){
  161. case "wbw":
  162. $outXml = "</data></block></pkg>";
  163. break;
  164. case "heading":
  165. $outXml = "</pkg>";
  166. break;
  167. case "translate":
  168. $outXml = "</data></block></pkg>";
  169. break;
  170. case "note":
  171. $outXml = "</data></block></pkg>";
  172. break;
  173. case "file":
  174. $outXml = "</data></block></pkg>";
  175. break;
  176. }
  177. echo $outXml;
  178. ?>