step3.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. require_once "install_head.php";
  3. require_once '../pcdl/html_head.php';
  4. ?>
  5. <body>
  6. <style>
  7. #step3{
  8. background-color: #f1e7a4;
  9. }
  10. body{
  11. font-size:unset;
  12. }
  13. </style>
  14. <?php
  15. require_once 'nav_bar.php';
  16. ?>
  17. <div style="margin:1em;background-color:#f1e7a4;">
  18. 生成字典数据库。约需要10分钟。
  19. </div>
  20. <div>
  21. <?php
  22. $dbfile[] = array(_FILE_DB_REF_, "ref.sql");
  23. $dbfile[] = array(_FILE_DB_REF_INDEX_, "ref_index.sql");
  24. $dir = "./refdict_db/";
  25. foreach ($dbfile as $key => $db) {
  26. # code...
  27. echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';
  28. $dns = $db[0];
  29. $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
  30. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  31. //建立数据库
  32. $_sql = file_get_contents($dir . $db[1]);
  33. $_arr = explode(';', $_sql);
  34. //执行sql语句
  35. foreach ($_arr as $_value) {
  36. $dbh->query($_value . ';');
  37. }
  38. echo $dns . "建立数据库成功";
  39. echo "</div>";
  40. }
  41. ?>
  42. </div>
  43. <div id="response"></div>
  44. <script>
  45. <?php
  46. echo "var rich_file_list = new Array();\n";
  47. $filelist = array();
  48. if (($handle = fopen(_DIR_DICT_TEXT_ . '/rich/list.txt', 'r')) !== false) {
  49. while (($data = fgetcsv($handle, 0, ',')) !== false) {
  50. $filelist[] = $data;
  51. }
  52. foreach ($filelist as $value) {
  53. echo "rich_file_list.push(['{$value[0]}','{$value[1]}']);\n";
  54. }
  55. } else {
  56. // exit("无法打开rich文件列表");
  57. }
  58. echo "var sys_file_list = new Array();\n";
  59. $filelist = array();
  60. if (($handle = fopen(_DIR_DICT_TEXT_ . '/system/list.txt', 'r')) !== false) {
  61. while (($data = fgetcsv($handle, 0, ',')) !== false) {
  62. $filelist[] = $data;
  63. }
  64. foreach ($filelist as $value) {
  65. echo "sys_file_list.push(['{$value[0]}','{$value[1]}']);\n";
  66. }
  67. } else {
  68. // exit("无法打开system文件列表");
  69. }
  70. echo "var thin_file_list = new Array();\n";
  71. $filelist = array();
  72. if (($handle = fopen(_DIR_DICT_TEXT_ . '/thin/list.csv', 'r')) !== false) {
  73. while (($data = fgetcsv($handle, 0, ',')) !== false) {
  74. $filelist[] = $data;
  75. }
  76. foreach ($filelist as $value) {
  77. echo "thin_file_list.push(['{$value[0]}','{$value[1]}','{$value[2]}']);\n";
  78. }
  79. } else {
  80. //exit("无法打开thin文件列表");
  81. }
  82. ?>
  83. var iCurrRichDictIndex = 0;
  84. var iCurrSysDictIndex = 0;
  85. function run_rich_dict(index){
  86. if(index >= rich_file_list.length){
  87. $("#response").html($("#response").html()+"rich dict Down");
  88. run_sys_dict(0);
  89. }
  90. else{
  91. $.get("step3_run.php",
  92. {
  93. dbtype:"rich",
  94. filename:rich_file_list[index][0],
  95. dbname:rich_file_list[index][1]
  96. },
  97. function(data,status){
  98. $("#response").html($("#response").html()+data+"<br>");
  99. iCurrRichDictIndex++;
  100. run_rich_dict(iCurrRichDictIndex);
  101. });
  102. }
  103. }
  104. function run_sys_dict(index,onlyOne=false){
  105. if(index >= sys_file_list.length){
  106. $("#response").html($("#response").html()+"All Down");
  107. }
  108. else{
  109. iCurrSysDictIndex = index;
  110. $.get("step3_run.php",
  111. {
  112. dbtype:"system",
  113. filename:sys_file_list[index][0],
  114. dbname:sys_file_list[index][1]
  115. },
  116. function(data,status){
  117. $("#response").html($("#response").html()+data+"<br>");
  118. if(onlyOne){
  119. $("#response").html($("#response").html()+"all done<br>");
  120. }
  121. else{
  122. iCurrSysDictIndex++;
  123. run_sys_dict(iCurrSysDictIndex);
  124. }
  125. });
  126. }
  127. }
  128. var iCurrThinDictIndex=0;
  129. function run_ref_dict(index){
  130. if(index >= thin_file_list.length){
  131. $("#response").html($("#response").html()+"All Down");
  132. }
  133. else{
  134. iCurrThinDictIndex = index;
  135. $.get("step3_run.php",
  136. {
  137. dbtype:"thin",
  138. filename:thin_file_list[index][0],
  139. dbname:thin_file_list[index][1],
  140. table:thin_file_list[index][2]
  141. },
  142. function(data,status){
  143. $("#response").html($("#response").html()+data+"<br>");
  144. iCurrThinDictIndex++;
  145. run_ref_dict(iCurrThinDictIndex);
  146. });
  147. }
  148. }
  149. function run_part_dict(){
  150. $.get("step3_run.php",
  151. {
  152. dbtype:"part",
  153. filename:"",
  154. dbname:""
  155. },
  156. function(data,status){
  157. $("#response").html($("#response").html()+data+" done<br>");
  158. });
  159. }
  160. </script>
  161. <h2>
  162. </h2>
  163. <div class="card">
  164. <h4>第三方参考字典</h4>
  165. <div class="contence">
  166. <button onclick="run_ref_dict(0)">Build rich dictionary </button><span style="请注意!此操作将会覆盖原有数据库。"><br>
  167. </div>
  168. </div>
  169. <div class="card">
  170. <h4>标准格式字典</h4>
  171. <div class="contence">
  172. <button onclick="run_rich_dict(0)">Build rich dictionary </button><span style="请注意!此操作将会覆盖原有数据库。"><br>
  173. </div>
  174. </div>
  175. <div class="card">
  176. <h4>组分字典</h4>
  177. <div class="contence">
  178. <button onclick="run_part_dict()">Build part dictionary</button><span style="请注意!此操作将会覆盖原有数据库。">
  179. </div>
  180. </div>
  181. <hr>
  182. <h2 style="text-align:center;"><a href="step5.php">[Next]</a></h2>
  183. </body>
  184. </html>