visuddhinanda 5 лет назад
Родитель
Сommit
e46d93b59a

+ 0 - 0
app/install/_FILE_DB_PALITEXT_


+ 99 - 0
app/install/db_insert_bookword_from_csv.php

@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<h2>Insert to Index</h2>
+<?php
+include "./_pdo.php";
+include "../path.php";
+if(isset($_GET["from"])==false){
+?>
+<form action="db_insert_bookword_from_csv.php" method="get">
+From: <input type="text" name="from" value="0"><br>
+To: <input type="text" name="to" value="216"><br>
+<input type="submit">
+</form>
+<?php
+return;
+}
+
+$from=$_GET["from"];
+$to=$_GET["to"];
+
+$dirLog=_DIR_LOG_."/";
+$dirXmlBase=_DIR_PALI_CSV_."/";
+
+$filelist=array();
+$fileNums=0;
+$log="";
+echo "<h2>doing : No.{$from} book </h2>";
+
+global $dbh_word_index;
+$dns = "sqlite:"._FILE_DB_BOOK_WORD_;
+$dbh_word_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_word_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+if(($handle=fopen("filelist.csv",'r'))!==FALSE){
+	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
+		$fileNums++;
+	}
+}
+if($to==0 || $to>=$fileNums) $to=$fileNums-1;
+
+    $bookword = array();
+    
+	if(($fpoutput=fopen(_DIR_CSV_PALI_CANON_WORD_."/{$from}_words.csv", "r"))!==FALSE){
+		$count=0;
+		while(($data=fgetcsv($fpoutput,0,','))!==FALSE){
+            $book = $data[1];
+            if(isset($bookword[$data[3]])){
+                $bookword[$data[3]]++;
+            }
+            else{
+                $bookword[$data[3]] = 1;
+            }
+			
+			$count++;
+		}        
+    }
+
+		// 开始一个事务,关闭自动提交
+		$dbh_word_index->beginTransaction();
+		$query="INSERT INTO bookword ('book','wordindex','count') VALUES ( ? , ? , ?  )";
+		$stmt = $dbh_word_index->prepare($query);
+
+        foreach ($bookword as $key => $value) {
+            $stmt->execute(array($book,$key,$value));
+        }
+		// 提交更改 
+		$dbh_word_index->commit();
+		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+			$error = $dbh_word_index->errorInfo();
+			echo "error - $error[2] <br>";
+			$log.="$from, $FileName, error, $error[2] \r\n";
+		}
+		else{
+			echo "updata $count recorders.<br />";
+			$log.="updata $count recorders.\r\n";
+		}		
+
+
+
+	$myLogFile = fopen($dirLog."insert_index.log", "a");
+	fwrite($myLogFile, $log);
+	fclose($myLogFile);
+	
+
+if($from>=$to){
+	echo "<h2>齐活!功德无量!all done!</h2>";
+}
+else{
+	echo "<script>";
+	echo "window.location.assign(\"db_insert_bookword_from_csv.php?from=".($from+1)."&to=".$to."\")";
+	echo "</script>";
+	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+}
+?>
+</body>
+</html>

+ 20 - 8
app/install/nav_bar.php

@@ -26,38 +26,50 @@
 </div>
 
 <div id = "step1" class="card nav_card">
-    <h3>1.建立目录</h3>
-    <div class="content">
-   
-    </div>
+    <a href="step1.php" style="display: inline-block;width: 100%;height: 100%;">
+        <h3>1.建立目录</h3>
+        <div class="content">
+    
+        </div>
+    </a>
 </div>
 
 <div  id = "step2" class="card nav_card">
+    <a href="step2.php" style="display: inline-block;width: 100%;height: 100%;">
     <h3>2-用户数据存储库</h3>
     <div class="content">
     
     </div>
+    </a>
 </div>
 
+
 <div  id = "step3" class="card nav_card">
-    <h3>3-字典数据库</h3>
-    <div class="content">
-    
-    </div>
+    <a href="step3.php" style="display: inline-block;width: 100%;height: 100%;">
+        <h3>3-字典数据库</h3>
+        <div class="content">
+        
+        </div>
+    </a>
 </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">
+    <a href="step5.php" style="display: inline-block;width: 100%;height: 100%;">
     <h3>建立三藏语料数据库</h3>
     <div class="content">
     Build Pali Canon Database
     </div>
+    </a>
 </div>
 
 </div>

+ 3 - 0
app/install/step5.php

@@ -73,6 +73,9 @@ else{
 
 	<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_bookword_from_csv.php" target="_blank">从csv文件导入书单词索引表</a><br>
+	
 	</div>
 </div>