2
0

step3.php 5.3 KB

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