pc_get_book_res.php 8.6 KB

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