step5.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. require_once "install_head.php";
  3. ?>
  4. <html>
  5. <head>
  6. </head>
  7. <body>
  8. <style>
  9. #step5{
  10. background-color: #f1e7a4;
  11. }
  12. </style>
  13. <?php
  14. require_once 'nav_bar.php';
  15. ?>
  16. <h3>Step 4 Build Pali Canon Database 建立三藏语料数据库</h3>
  17. <div class="card" style="background-color:#f1e7a4;">
  18. 你可以下载已经制作好的语料数据库放在项目文件夹中
  19. <a href="https://www.dropbox.com/s/naf7sk9i9sf0dfi/appdata.7z?dl=0">drobox 7z format 754MB</a>
  20. 解压缩后放在项目tmp目录中
  21. <pre>
  22. [tmp]
  23. └appdata
  24. └dict
  25. └3rd
  26. └system
  27. └palicanon
  28. └user
  29. </pre>
  30. </div>
  31. <?php
  32. $dbfile[] = array(_FILE_DB_BOLD_, "bold.sql");
  33. $dbfile[] = array(_FILE_DB_INDEX_, "index.sql");
  34. $dbfile[] = array(_FILE_DB_BOOK_WORD_, "bookword.sql");
  35. $dbfile[] = array(_FILE_DB_PALI_INDEX_, "paliindex.sql");
  36. $dbfile[] = array(_FILE_DB_WORD_INDEX_, "wordindex.sql");
  37. $dbfile[] = array(_FILE_DB_PALI_SENTENCE_, "pali_sent.sql");
  38. $dbfile[] = array(_FILE_DB_PALITEXT_, "pali_text.sql");
  39. $dbfile[] = array(_FILE_DB_RESRES_INDEX_, "res.sql");
  40. $dir = "./palicanon_db/";
  41. if (isset($_GET["index"])) {
  42. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';
  43. $index = $_GET["index"];
  44. $dns = "" . $dbfile[$index][0];
  45. $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
  46. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  47. //建立数据库
  48. $_sql = file_get_contents($dir . $dbfile[$index][1]);
  49. $_arr = explode(';', $_sql);
  50. //执行sql语句
  51. foreach ($_arr as $_value) {
  52. $dbh->query($_value . ';');
  53. }
  54. echo $dns . "建立数据库成功";
  55. echo "</div>";
  56. }
  57. ?>
  58. <div class="card">
  59. <h4>拆分html文件</h4>
  60. <a href="xmlmaker.php">拆分</a><br>
  61. <a href="../../log/palicanoon.log" target="_blank">view log file</a>
  62. </div>
  63. <div class="card">
  64. <h4>逐词解析模板数据库</h4>
  65. <?php
  66. if (file_exists(_DIR_PALICANON_TEMPLET_)) {
  67. $iCount = 0;
  68. for ($i = 1; $i <= 217; $i++) {
  69. if (file_exists(_DIR_PALICANON_TEMPLET_ . "/p{$i}_tpl.db3")) {
  70. $iCount++;
  71. }
  72. }
  73. if ($iCount == 217) {
  74. echo "文件已经存在。<br>";
  75. echo '<a href="db_insert_templet.php">重新生成数据库</a>';
  76. } else {
  77. echo "缺少" . (217 - $iCount) . "个文件<br>";
  78. echo '<a href="db_insert_templet.php">生成数据库</a>';
  79. }
  80. } else {
  81. echo "模板数据库目录不存在<br>";
  82. }
  83. ?>
  84. </div>
  85. <div class="card">
  86. <h4>单词索引表</h4>
  87. <?php
  88. for ($i = 2; $i <= 4; $i++) {
  89. $db = $dbfile[$i];
  90. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
  91. echo '<div style="flex:5;">' . $db[0] . '</div>';
  92. echo '<div style="flex:3;">';
  93. if (!file_exists($db[0])) {
  94. echo "<span style='color:red;'>数据库不存在</span>";
  95. echo "</div>";
  96. echo '<div style="flex:2;"><a href="step4.php?index=' . $i . '">建立</a></div>';
  97. } else {
  98. echo "<span style='color:green;'>已存在</span>";
  99. echo "</div>";
  100. echo '<div style="flex:2;"><a href="step5.php?index=' . $i . '">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
  101. }
  102. echo "</div>";
  103. }
  104. ?>
  105. ?>
  106. <div class="contence">
  107. <a href="db_insert_index.php" target="_blank">生成-一本书一次写入</a><br>
  108. <a href="db_insert_index_once.php" target="_blank">一次生成所有的书</a><br>
  109. <a href="db_insert_index_csv.php" target="_blank">生成中间csv文件(项目文档已经有了。无需生成)</a><br>
  110. <a href="db_insert_bookword_from_csv.php" target="_blank">从csv文件导入书单词索引表(bookword)</a><br>
  111. <a href="db_insert_word_from_csv.php" target="_blank">从csv文件导入单词表(paliindex)</a><br>
  112. <a href="db_insert_wordindex_from_csv.php" target="_blank">从csv文件导入单词索引表(wordindex)</a><br>
  113. </div>
  114. </div>
  115. <div class="card">
  116. <h4>黑体字数据库</h4>
  117. <?php
  118. $db = $dbfile[0];
  119. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
  120. echo '<div style="flex:5;">' . $db[0] . '</div>';
  121. echo '<div style="flex:3;">';
  122. if (!file_exists($db[0])) {
  123. echo "<span style='color:red;'>数据库不存在</span>";
  124. echo "</div>";
  125. echo '<div style="flex:2;"><a href="step5.php?index=0">建立</a></div>';
  126. } else {
  127. echo "<span style='color:green;'>已存在</span>";
  128. echo "</div>";
  129. echo '<div style="flex:2;"><a href="step5.php?index=0">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
  130. }
  131. echo "</div>";
  132. ?>
  133. <div class="contence">
  134. <a href="db_insert_bold.php" target="_blank">生成</a>
  135. </div>
  136. </div>
  137. <div class="card">
  138. <h4>Pali句子库</h4>
  139. <?php
  140. $db = $dbfile[5];
  141. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
  142. echo '<div style="flex:5;">' . $db[0] . '</div>';
  143. echo '<div style="flex:3;">';
  144. /*
  145. if (!file_exists($db[0])) {
  146. echo "<span style='color:red;'>数据库不存在</span>";
  147. echo "</div>";
  148. echo '<div style="flex:2;"><a href="step5.php?index=5">建立</a></div>';
  149. } else
  150. */
  151. {
  152. echo "<span style='color:green;'>已存在</span>";
  153. echo "</div>";
  154. echo '<div style="flex:2;"><a href="step5.php?index=5">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
  155. }
  156. echo "</div>";
  157. //if (file_exists(_FILE_DB_PALI_SENTENCE_))
  158. {
  159. echo "Pali句子数据库已经存在<br>";
  160. echo '<a href="db_insert_sentence.php">重新生成</a>';
  161. }
  162. //else {
  163. // echo "Pali句子数据库不存在<br>";
  164. // echo '<a href="db_insert_sentence.php">生成</a>';
  165. //}
  166. ?>
  167. </div>
  168. <div class="card">
  169. <h4>Pali原文库</h4>
  170. <div>
  171. <?php
  172. $db = $dbfile[6];
  173. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
  174. echo '<div style="flex:5;">' . $db[0] . '</div>';
  175. echo '<div style="flex:3;">';
  176. if (!file_exists($db[0])) {
  177. echo "<span style='color:red;'>数据库不存在</span>";
  178. echo "</div>";
  179. echo '<div style="flex:2;"><a href="step5.php?index=6">建立</a></div>';
  180. } else {
  181. echo "<span style='color:green;'>已存在</span>";
  182. echo "</div>";
  183. echo '<div style="flex:2;"><a href="step5.php?index=6">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
  184. }
  185. echo "</div>";
  186. if (file_exists(_FILE_DB_PALITEXT_)) {
  187. echo "Pali原文数据库已经存在<br>";
  188. echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
  189. echo '<a href="db_update_palitext.php" target="_blank">更新</a><br>';
  190. } else {
  191. echo '<a href="db_insert_palitext.php">生成</a><br>';
  192. }
  193. echo "<a href = '" . _DIR_LOG_ . "/db_update_palitext.log" . "' target='_blank'>view Log</a>"
  194. ?>
  195. </div>
  196. </div>
  197. <div class="card">
  198. <h4>标题索引</h4>
  199. <div>
  200. <?php
  201. $db = $dbfile[7];
  202. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
  203. echo '<div style="flex:5;">' . $db[0] . '</div>';
  204. echo '<div style="flex:3;">';
  205. if (!file_exists($db[0])) {
  206. echo "<span style='color:red;'>数据库不存在</span>";
  207. echo "</div>";
  208. echo '<div style="flex:2;"><a href="step5.php?index=7">建立</a></div>';
  209. } else {
  210. echo "<span style='color:green;'>已存在</span>";
  211. echo "</div>";
  212. echo '<div style="flex:2;"><a href="step5.php?index=7">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
  213. }
  214. echo "</div>";
  215. //if (file_exists(_FILE_DB_PALITEXT_))
  216. {
  217. echo "标题索引数据库已经存在<br>";
  218. echo '<a href="db_update_toc.php" target="_blank">更新</a><br>';
  219. }
  220. /*
  221. else
  222. {
  223. echo "标题索引数据库不存在<br>";
  224. echo '<div style="flex:2;"><a href="step5.php?index=' . $i . '">建立</a></div>';
  225. }
  226. */
  227. echo "<a href = '" . _DIR_LOG_ . "/db_update_title.log" . "' target='_blank'>view Log</a>"
  228. ?>
  229. </div>
  230. </div>
  231. <hr>
  232. <h2>完成</h2>
  233. </body>
  234. </html>