Sfoglia il codice sorgente

将 install step4 中的建立数据库功能移动到step5

visuddhinanda 5 anni fa
parent
commit
ea930f21af

+ 1 - 1
app/install/db_insert_word_from_csv.php

@@ -3,7 +3,7 @@
 <head>
 <head>
 </head>
 </head>
 <body>
 <body>
-<h2>Insert to Index</h2>
+<h2>Insert csv to word table</h2>
 <p><a href="index.php">Home</a></p>
 <p><a href="index.php">Home</a></p>
 <?php
 <?php
 include "./_pdo.php";
 include "./_pdo.php";

+ 0 - 10
app/install/nav_bar.php

@@ -53,16 +53,6 @@
     </a>
     </a>
 </div>
 </div>
 
 
-
-<div  id = "step4" class="card nav_card">
-    <a href="step4.php" style="display: inline-block;width: 100%;height: 100%;">
-    <h3>4-语料库数据库文件</h3>
-    <div class="content">
-    
-    </div>
-    </a>
-</div>
-
 <div  id = "step5" class="card nav_card">
 <div  id = "step5" class="card nav_card">
     <a href="step5.php" style="display: inline-block;width: 100%;height: 100%;">
     <a href="step5.php" style="display: inline-block;width: 100%;height: 100%;">
     <h3>建立三藏语料数据库</h3>
     <h3>建立三藏语料数据库</h3>

+ 2 - 1
app/install/step1.php

@@ -53,6 +53,7 @@ foreach($dir as $onedir){
 }
 }
 ?>
 ?>
 </div>
 </div>
-<h2><a href="step2.php">Next</a></h2>
+<hr>
+<h2  style="text-align:center;"><a href="step2.php">Next</a></h2>
 </body>
 </body>
 </html>
 </html>

+ 2 - 2
app/install/step2.php

@@ -67,7 +67,7 @@ for($i=0; $i<count($dbfile); $i++){
 ?>
 ?>
 <div>
 <div>
 </div>
 </div>
-
-<h2><a href="step3.php">Next</a></h2>
+<hr>
+<h2  style="text-align:center;"><a href="step3.php">Next</a></h2>
 </body>
 </body>
 </html>
 </html>

+ 1 - 1
app/install/step3.php

@@ -215,6 +215,6 @@ function run_part_dict(){
 	</div>
 	</div>
 </div>
 </div>
 <hr>
 <hr>
-<h2><a href="step4.php">[Next]</a></h2>
+<h2 style="text-align:center;"><a href="step5.php">[Next]</a></h2>
 </body>
 </body>
 </html>
 </html>

+ 104 - 9
app/install/step5.php

@@ -16,12 +16,11 @@ require_once 'nav_bar.php';
 <h3>Step 4 Build Pali Canon Database 建立三藏语料数据库</h3>
 <h3>Step 4 Build Pali Canon Database 建立三藏语料数据库</h3>
 
 
 <div class="card" style="background-color:#f1e7a4;">
 <div class="card" style="background-color:#f1e7a4;">
-目前本功能尚未实现。请下载已经制作好的语料数据库放在项目文件夹中
+你可以下载已经制作好的语料数据库放在项目文件夹中
 <a href="https://www.dropbox.com/s/naf7sk9i9sf0dfi/appdata.7z?dl=0">drobox 7z format 754MB</a>
 <a href="https://www.dropbox.com/s/naf7sk9i9sf0dfi/appdata.7z?dl=0">drobox 7z format 754MB</a>
-解压缩后放在项目目录中
+解压缩后放在项目tmp目录中
 <pre>
 <pre>
-[project dir]
- └app
+[tmp]
  └appdata
  └appdata
    └dict
    └dict
      └3rd
      └3rd
@@ -30,7 +29,33 @@ require_once 'nav_bar.php';
  └user 
  └user 
  </pre>
  </pre>
 </div>
 </div>
+<?php
+$dbfile[]=array(_FILE_DB_BOLD_,"bold.sql");
+$dbfile[]=array(_FILE_DB_INDEX_,"index.sql");
+$dbfile[]=array(_FILE_DB_BOOK_WORD_,"bookword.sql");
+$dbfile[]=array(_FILE_DB_PALI_INDEX_,"paliindex.sql");
+$dbfile[]=array(_FILE_DB_WORD_INDEX_,"wordindex.sql");
+$dbfile[]=array(_FILE_DB_PALI_SENTENCE_,"pali_sent.sql");
+$dbfile[]=array(_FILE_DB_PALITEXT_,"pali_text.sql");
+$dir="./palicanon_db/";
 
 
+if(isset($_GET["index"])){
+echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';	
+	$index = $_GET["index"];
+	$dns = "sqlite:".$dbfile[$index][0];
+	$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+	//建立数据库
+	$_sql = file_get_contents($dir.$dbfile[$index][1]);
+	$_arr = explode(';', $_sql);
+	//执行sql语句
+	foreach ($_arr as $_value) {
+		$dbh->query($_value.';');
+	}
+	echo $dns."建立数据库成功";
+echo "</div>"; 
+}
+?>
 
 
 <div class="card">
 <div class="card">
 <h4>拆分html文件</h4>
 <h4>拆分html文件</h4>
@@ -66,21 +91,58 @@ else{
 
 
 <div class="card">
 <div class="card">
 	<h4>单词索引表</h4>
 	<h4>单词索引表</h4>
+	<?php
+	for($i=2; $i<=4; $i++){
+		$db = $dbfile[$i];
+		echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
+		echo '<div style="flex:5;">'.$db[0].'</div>';
+		echo '<div style="flex:3;">';
+		if(!file_exists($db[0])){
+			echo "<span style='color:red;'>数据库不存在</span>";
+			echo "</div>"; 
+			echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">建立</a></div>';    
+		}
+		else{
+			echo "<span style='color:green;'>已存在</span>";
+			echo "</div>"; 
+			echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+		}
+		echo "</div>";  
+	}
+	?>
+	?>
 	<div class="contence">
 	<div class="contence">
-	<a href="db_insert_index_csv.php" target="_blank">csv</a><br>
 	<a href="db_insert_index.php" target="_blank">生成-一本书一次写入</a><br>
 	<a href="db_insert_index.php" target="_blank">生成-一本书一次写入</a><br>
 	<a href="db_insert_index_once.php" target="_blank">一次生成所有的书</a><br>
 	<a href="db_insert_index_once.php" target="_blank">一次生成所有的书</a><br>
 
 
-	<a href="db_insert_word_from_csv.php" target="_blank">从csv文件导入单词表</a><br>
-	<a href="db_insert_wordindex_from_csv.php" target="_blank">从csv文件导入单词索引表</a><br>
+	<a href="db_insert_index_csv.php" target="_blank">生成中间csv文件(项目文档已经有了。无需生成)</a><br>
+	<a href="db_insert_bookword_from_csv.php" target="_blank">从csv文件导入书单词索引表(bookword)</a><br>	
+	<a href="db_insert_word_from_csv.php" target="_blank">从csv文件导入单词表(paliindex)</a><br>
+	<a href="db_insert_wordindex_from_csv.php" target="_blank">从csv文件导入单词索引表(wordindex)</a><br>
 
 
-	<a href="db_insert_bookword_from_csv.php" target="_blank">从csv文件导入书单词索引表</a><br>
 	
 	
 	</div>
 	</div>
 </div>
 </div>
 
 
 <div class="card">
 <div class="card">
 	<h4>黑体字数据库</h4>
 	<h4>黑体字数据库</h4>
+	<?php
+	$db = $dbfile[0];
+	echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
+	echo '<div style="flex:5;">'.$db[0].'</div>';
+	echo '<div style="flex:3;">';
+	if(!file_exists($db[0])){
+        echo "<span style='color:red;'>数据库不存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">建立</a></div>';    
+	}
+	else{
+        echo "<span style='color:green;'>已存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+    }
+	echo "</div>";  
+	?>
 	<div class="contence">
 	<div class="contence">
 	<a href="db_insert_bold.php" target="_blank">生成</a>
 	<a href="db_insert_bold.php" target="_blank">生成</a>
 	</div>
 	</div>
@@ -89,6 +151,22 @@ else{
 <div class="card">
 <div class="card">
 <h4>Pali句子库</h4>
 <h4>Pali句子库</h4>
 <?php
 <?php
+	$db = $dbfile[5];
+	echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
+	echo '<div style="flex:5;">'.$db[0].'</div>';
+	echo '<div style="flex:3;">';
+	if(!file_exists($db[0])){
+        echo "<span style='color:red;'>数据库不存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">建立</a></div>';    
+	}
+	else{
+        echo "<span style='color:green;'>已存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+    }
+	echo "</div>";  
+
 if(file_exists(_FILE_DB_PALI_SENTENCE_)){
 if(file_exists(_FILE_DB_PALI_SENTENCE_)){
 	echo "Pali句子数据库已经存在<br>";
 	echo "Pali句子数据库已经存在<br>";
 	echo '<a href="db_insert_sentence.php">重新生成</a>';
 	echo '<a href="db_insert_sentence.php">重新生成</a>';
@@ -102,8 +180,25 @@ else{
 
 
 <div class="card">
 <div class="card">
 <h4>Pali原文库</h4>
 <h4>Pali原文库</h4>
+
 <div>
 <div>
 <?php
 <?php
+	$db = $dbfile[6];
+	echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;display:flex;">';
+	echo '<div style="flex:5;">'.$db[0].'</div>';
+	echo '<div style="flex:3;">';
+	if(!file_exists($db[0])){
+        echo "<span style='color:red;'>数据库不存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">建立</a></div>';    
+	}
+	else{
+        echo "<span style='color:green;'>已存在</span>";
+    	echo "</div>"; 
+        echo '<div style="flex:2;"><a href="step4.php?index='.$i.'">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+    }
+	echo "</div>";  
+
 if(file_exists(_FILE_DB_PALITEXT_)){
 if(file_exists(_FILE_DB_PALITEXT_)){
 	echo "Pali原文数据库已经存在<br>";
 	echo "Pali原文数据库已经存在<br>";
 	echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
 	echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
@@ -119,6 +214,6 @@ echo "<a href = '"._DIR_LOG_."/db_update_palitext.log"."' target='_blank'>view L
 
 
 
 
 <hr>
 <hr>
-<h2><a href="step4.php">Next</a></h2>
+<h2>完成</h2>
 </body>
 </body>
 </html>
 </html>