Parcourir la source

修改数据连接字符串,为了更换数据库做准备

visuddhinanda il y a 5 ans
Parent
commit
13d6bfe2ca
100 fichiers modifiés avec 5495 ajouts et 5787 suppressions
  1. 57 64
      app/admin/db_update_cs6_para.php
  2. 77 80
      app/admin/setting.php
  3. 31 35
      app/admin/update_user_active_time.php
  4. 116 123
      app/admin/word_index_weight_refresh.php
  5. 1 1
      app/article/add_article_to_collect.php
  6. 2 2
      app/article/collect_get.php
  7. 1 1
      app/article/collect_list.php
  8. 1 1
      app/article/get.php
  9. 1 1
      app/article/list.php
  10. 1 1
      app/article/list_article_in_collect.php
  11. 1 1
      app/article/list_new.php
  12. 3 3
      app/article/my_article_post.php
  13. 1 1
      app/article/my_article_put.php
  14. 1 1
      app/article/my_collect_post.php
  15. 1 1
      app/article/my_collect_put.php
  16. 1 1
      app/channal/coop_new_user.php
  17. 1 1
      app/channal/function.php
  18. 2 2
      app/channal/get.php
  19. 2 2
      app/channal/my_channal_get.php
  20. 3 3
      app/channal/my_channal_post.php
  21. 1 1
      app/channal/my_channal_put.php
  22. 1 1
      app/collect/function.php
  23. 1 1
      app/collect/list.php
  24. 1 1
      app/course/course_get.php
  25. 1 1
      app/course/course_list.php
  26. 1 1
      app/course/lesson_get.php
  27. 1 1
      app/course/lesson_list.php
  28. 1 1
      app/course/list_new.php
  29. 1 1
      app/course/my_course_edit.php
  30. 1 1
      app/course/my_course_insert.php
  31. 1 1
      app/course/my_course_list.php
  32. 1 1
      app/course/my_course_update.php
  33. 1 1
      app/course/my_lesson_edit.php
  34. 1 1
      app/course/my_lesson_insert.php
  35. 1 1
      app/course/my_lesson_list.php
  36. 1 1
      app/course/my_lesson_new.php
  37. 1 1
      app/course/my_lesson_update.php
  38. 2 2
      app/course/teacher_list.php
  39. 1 1
      app/dict/comp_csv.php
  40. 371 390
      app/dict/dict_lookup.php
  41. 1 1
      app/dict/turbo_split.php
  42. 1 1
      app/dict_builder/dict_find3.php
  43. 2 2
      app/dict_builder/get_one_word.php
  44. 1 1
      app/dict_builder/index - 副本.php
  45. 88 94
      app/dict_builder/index.php
  46. 61 72
      app/dict_builder/save.php
  47. 137 145
      app/doc/coop.php
  48. 1 1
      app/doc/coopfilelist.php
  49. 40 45
      app/doc/docinfo.php
  50. 4 4
      app/doc/edit_wbw.php
  51. 398 407
      app/doc/fork.php
  52. 69 75
      app/doc/load_channal_para.php
  53. 252 269
      app/doc/pcs2db.php
  54. 29 31
      app/fullcalendar/examples/php/get-date.php
  55. 30 34
      app/group/function.php
  56. 35 38
      app/group/get.php
  57. 9 10
      app/group/get_name.php
  58. 229 238
      app/group/group.php
  59. 38 40
      app/group/group_del.php
  60. 5 9
      app/group/list.php
  61. 8 9
      app/group/list_member.php
  62. 1 1
      app/group/member_del.php
  63. 48 50
      app/group/member_put.php
  64. 29 31
      app/group/my_group_put.php
  65. 15 16
      app/hostsetting/function.php
  66. 62 65
      app/install/db_create.php
  67. 117 121
      app/install/db_insert_bold.php
  68. 58 62
      app/install/db_insert_bookword_from_csv.php
  69. 258 279
      app/install/db_insert_index.php
  70. 193 207
      app/install/db_insert_index_once.php
  71. 116 123
      app/install/db_insert_page_index.php
  72. 88 95
      app/install/db_insert_palitext.php
  73. 298 317
      app/install/db_insert_sentence.php
  74. 25 29
      app/install/db_insert_sim.php
  75. 111 113
      app/install/db_insert_templet.php
  76. 49 51
      app/install/db_insert_word_from_csv.php
  77. 36 43
      app/install/db_insert_wordindex_from_csv.php
  78. 28 27
      app/install/db_pali_text_export.php
  79. 155 162
      app/install/db_update_palitext.php
  80. 99 106
      app/install/db_update_toc.php
  81. 24 27
      app/install/install_head.php
  82. 111 113
      app/install/page_index.php
  83. 40 42
      app/install/step2.php
  84. 51 62
      app/install/step3.php
  85. 59 71
      app/install/step3_run.php
  86. 35 37
      app/install/step4.php
  87. 139 149
      app/install/step5.php
  88. 29 31
      app/lib/fullcalendar/php/get-date.php
  89. 7 8
      app/media/function.php
  90. 35 44
      app/media/get.php
  91. 40 47
      app/nissaya/get.php
  92. 23 26
      app/pali_sent/get_sim.php
  93. 251 239
      app/pali_sent/pali_sent.php
  94. 9 11
      app/pali_sent/pali_sent_list.php
  95. 219 212
      app/pali_sent/sim_sent.php
  96. 58 64
      app/palicanon/book_tag.php
  97. 65 73
      app/palicanon/get_chapter_children.php
  98. 49 54
      app/palicanon/get_chapter_info.php
  99. 89 73
      app/path.php
  100. 243 245
      app/pcdl/change.php

+ 57 - 64
app/admin/db_update_cs6_para.php

@@ -2,75 +2,68 @@
 require_once "../public/_pdo.php";
 require_once "../path.php";
 
-	$db_file = _FILE_DB_PALITEXT_;
-	PDO_Connect("sqlite:$db_file");
+$db_file = _FILE_DB_PALITEXT_;
+PDO_Connect("$db_file");
 
-	$query = "SELECT * from books where 1";
-	$books = PDO_FetchAll($query);
+$query = "SELECT * from books where 1";
+$books = PDO_FetchAll($query);
 
+$db_file = _FILE_DB_PAGE_INDEX_;
+PDO_Connect("$db_file");
 
-	$db_file = _FILE_DB_PAGE_INDEX_;
-	PDO_Connect("sqlite:$db_file");
+// 打开文件并读取数据
+$irow = 0;
+if (($fp = fopen("./cs6_para.csv", "r")) !== false) {
+    // 开始一个事务,关闭自动提交
+    $PDO->beginTransaction();
+    $query = "INSERT INTO cs6_para ('book','para','bookid','cspara','book_name') VALUES (  ? , ? , ? , ? , ? )";
+    $stmt = $PDO->prepare($query);
 
-	// 打开文件并读取数据
-	$irow=0;
-	if(($fp=fopen("./cs6_para.csv", "r"))!==FALSE){
-		// 开始一个事务,关闭自动提交
-		$PDO->beginTransaction();
-		$query="INSERT INTO cs6_para ('book','para','bookid','cspara','book_name') VALUES (  ? , ? , ? , ? , ? )";
-		$stmt = $PDO->prepare($query);
+    // 提交更改
+    try {
+        while (($data = fgetcsv($fp, 0, ',')) !== false) {
+            $irow++;
+            if ($irow > 1) {
+                $book_id = 0;
+                foreach ($books as $key => $value) {
+                    # code...
+                    if ($value["book"] == $data[0] && $data[1] >= $value["paragraph"]) {
+                        $book_id = $value["id"];
+                        break;
+                    }
+                }
+                if ($data[3] == $data[4]) {
+                    $stmt->execute(array($data[0], $data[1], $book_id, $data[3], $data[2]));
+                } else {
+                    $begin = (int) $data[3];
+                    $end = (int) $data[4];
+                    $arr1 = array();
+                    for ($i = $begin; $i <= $end; $i++) {
+                        $arr1[] = $i;
+                    }
+                    foreach ($arr1 as $key => $value) {
+                        $stmt->execute(array($data[0], $data[1], $book_id, $value, $data[2]));
+                    }
+                }
 
-		// 提交更改 
-		try{
-			while(($data=fgetcsv($fp,0,','))!==FALSE){
-				$irow++;
-				if($irow>1){
-					$book_id=0;
-					foreach ($books as $key => $value) {
-						# code...
-						if($value["book"]==$data[0] && $data[1]>=$value["paragraph"]){
-							$book_id = $value["id"];
-							break;
-						}
-					}
-					if($data[3]==$data[4]){
-						$stmt->execute(array($data[0],$data[1],$book_id,$data[3],$data[2]));
-					}
-					else{
-						$begin = (int)$data[3];
-						$end = (int)$data[4];
-						$arr1=array();
-						for($i=$begin; $i<=$end; $i++){
-							$arr1[] = $i;
-						}
-						foreach ($arr1 as $key => $value) {
-							$stmt->execute(array($data[0],$data[1],$book_id,$value,$data[2]));
-						}						
-					}
+            }
+        }
+        $PDO->commit();
+    } catch (Exception $e) {
+        var_dump($e);
+        $PDO->rollback();
+    }
 
-				}
-			}
-			$PDO->commit();
-		}catch (Exception $e){
-			var_dump($e);
-			$PDO->rollback();
-		}
+    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        echo "error - $error[2] \n";
+    } else {
+        echo "updata  recorders.\n";
+    }
 
-		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-			$error = PDO_ErrorInfo();
-			echo "error - $error[2] \n";
-		}
-		else{
-			echo "updata  recorders.\n";
-		}			
+    fclose($fp);
+} else {
+    echo "can not open csv file. cs6_para.csv";
+}
 
-		fclose($fp);
-	}
-	else{
-		echo "can not open csv file. cs6_para.csv";
-	}
-	
-
-
-	echo "齐活!功德无量!all done!";	
-?>
+echo "齐活!功德无量!all done!";

+ 77 - 80
app/admin/setting.php

@@ -3,18 +3,15 @@
 require_once '../path.php';
 require_once "../public/_pdo.php";
 
-if(isset($_GET["language"])){$currLanguage=$_GET["language"];}
-else{$currLanguage="en";}
+if (isset($_GET["language"])) {$currLanguage = $_GET["language"];} else { $currLanguage = "en";}
 
-if(isset($_GET["device"])){$currDevice=$_GET["device"];}
-else{$currDevice="computer";}
+if (isset($_GET["device"])) {$currDevice = $_GET["device"];} else { $currDevice = "computer";}
 
-if(isset($_GET["item"])){$currSettingItem=$_GET["item"];}
-else{$currSettingItem="local_gramma";}
+if (isset($_GET["item"])) {$currSettingItem = $_GET["item"];} else { $currSettingItem = "local_gramma";}
 
-$album_power["15"]="超级管理员";
-$album_power["1"]="管理员";
-$album_power["2"]="编辑";
+$album_power["15"] = "超级管理员";
+$album_power["1"] = "管理员";
+$album_power["2"] = "编辑";
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html>
@@ -30,7 +27,7 @@ $album_power["2"]="编辑";
 </head>
 <body class="mainbody" id="mbody">
 	<div class="main">
-		<!-- content begin--> 
+		<!-- content begin-->
 		<div id="leftmenuinner">
 			<div class="toolgroup1">
 
@@ -39,8 +36,8 @@ $album_power["2"]="编辑";
 			<div >
 				<h1>Setting</h1>
 			</div>
-			
-			<div class='toc' id='leftmenuinnerinner'>	
+
+			<div class='toc' id='leftmenuinnerinner'>
 				<ul class="setting_item">
 					<li><a href="setting.php?item=general">General</a></li>
 					<li><a href="setting.php?item=studio">Studio</a></li>
@@ -60,17 +57,17 @@ $album_power["2"]="编辑";
 		<div class="tool_bar">
 			<div >
 			<?php
-			switch($currSettingItem){
-				case "account":
-				break;
-				case "album":
-				if(isset($_GET["id"])){
-					echo "<a href='setting.php?item=album'>返回</a>";
-				}
-				break;
-			}
-			?>
-				
+switch ($currSettingItem) {
+    case "account":
+        break;
+    case "album":
+        if (isset($_GET["id"])) {
+            echo "<a href='setting.php?item=album'>返回</a>";
+        }
+        break;
+}
+?>
+
 			</div>
 			<div>
 				<span>Language</span>
@@ -83,39 +80,39 @@ $album_power["2"]="编辑";
 			</div>
 		</div>
 <?php
-	switch($currSettingItem){
-		case "account":
-			PDO_Connect("sqlite:"._FILE_DB_USERINFO_);
-			$query = "SELECT * from 'user' where 1 limit 0,1000";
-			$user_info = PDO_FetchAll($query);
-			echo "<table>";
-			echo "<tr><th>id</th><th>user name</th><th>nick name</th></tr>";
-			
-			foreach($user_info as $user){
-				echo "<tr>";	
-				echo "<td>{$user["id"]}</td>";
-				echo "<td>{$user["username"]}</td>";
-				echo "<td>{$user["nickname"]}</td>";
-				echo "</tr>";
-			}
-			
-			echo "</table>";
-			break;
-		case "album":
-			$db_file = _FILE_DB_RES_INDEX_;
-			PDO_Connect("sqlite:$db_file");		
-			echo "<h2>Album</h2>";
-
-			$query = "SELECT * from 'album' where 1 limit 0,1000";
-			$Fetch = PDO_FetchAll($query);
-			?>
+switch ($currSettingItem) {
+    case "account":
+        PDO_Connect("" . _FILE_DB_USERINFO_);
+        $query = "SELECT * from 'user' where 1 limit 0,1000";
+        $user_info = PDO_FetchAll($query);
+        echo "<table>";
+        echo "<tr><th>id</th><th>user name</th><th>nick name</th></tr>";
+
+        foreach ($user_info as $user) {
+            echo "<tr>";
+            echo "<td>{$user["id"]}</td>";
+            echo "<td>{$user["username"]}</td>";
+            echo "<td>{$user["nickname"]}</td>";
+            echo "</tr>";
+        }
+
+        echo "</table>";
+        break;
+    case "album":
+        $db_file = _FILE_DB_RES_INDEX_;
+        PDO_Connect("$db_file");
+        echo "<h2>Album</h2>";
+
+        $query = "SELECT * from 'album' where 1 limit 0,1000";
+        $Fetch = PDO_FetchAll($query);
+        ?>
 			<table>
 				<tr>
 					<th>Book</th><th>Title</th><th>Author</th><th>语言</th><th>媒体</th><th></th><th></th>
 				</tr>
 			<?php
-			foreach($Fetch as $album){
-				echo "<tr><td>{$album["book"]}</td>
+foreach ($Fetch as $album) {
+            echo "<tr><td>{$album["book"]}</td>
 						  <td>{$album["title"]}</td>
 						  <td>{$album["author"]}</td>
 						  <td>{$album["language"]}</td>
@@ -123,37 +120,37 @@ $album_power["2"]="编辑";
 						  <td><a href=\"../app/album.php?op=show_info&album_id={$album["id"]}\" target='_blank'>详情</a></td>
 						  <td><a href=\"../app/album.php?op=export&album_id={$album["id"]}\" target='_blank'>导出</a></td>
 						</tr>";
-			}
-			echo "</table>";
-			break;		
-		case "share":
-			PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-			$query = "SELECT count(*) from 'fileindex' where share=1";
-			$file_count = PDO_FetchOne($query);
-			echo "共计:{$file_count} 个共享文件";
-			$query = "SELECT * from 'fileindex' where share=1 limit 0,100";
-			$file_share = PDO_FetchAll($query);			
-			echo "<table>";
-			echo "<tr><th>id</th><th>user id</th><th>Title</th><th>Size</th><th></th></tr>";
-			
-			foreach($file_share as $file){
-				echo "<tr>";	
-				echo "<td>{$file["id"]}</td>";
-				echo "<td>{$file["user_id"]}</td>";
-				echo "<td>{$file["title"]}</td>";
-				echo "<td>{$file["file_size"]}</td>";
-				echo "<td>详情</td>";
-				echo "</tr>";
-			}
-			
-			echo "</table>";		
-			break;
-	}
-			
+        }
+        echo "</table>";
+        break;
+    case "share":
+        PDO_Connect("" . _FILE_DB_FILEINDEX_);
+        $query = "SELECT count(*) from 'fileindex' where share=1";
+        $file_count = PDO_FetchOne($query);
+        echo "共计:{$file_count} 个共享文件";
+        $query = "SELECT * from 'fileindex' where share=1 limit 0,100";
+        $file_share = PDO_FetchAll($query);
+        echo "<table>";
+        echo "<tr><th>id</th><th>user id</th><th>Title</th><th>Size</th><th></th></tr>";
+
+        foreach ($file_share as $file) {
+            echo "<tr>";
+            echo "<td>{$file["id"]}</td>";
+            echo "<td>{$file["user_id"]}</td>";
+            echo "<td>{$file["title"]}</td>";
+            echo "<td>{$file["file_size"]}</td>";
+            echo "<td>详情</td>";
+            echo "</tr>";
+        }
+
+        echo "</table>";
+        break;
+}
+
 ?>
-			
+
 		</div>
 	</div>
-			
+
 </body>
 </html>

+ 31 - 35
app/admin/update_user_active_time.php

@@ -4,52 +4,48 @@ require_once '../path.php';
 date_default_timezone_set("UTC");
 $logfile = "update_user_active_time_last.txt";
 $last = file_get_contents($logfile);
-$start = strtotime($last." +1 day");
-$end = strtotime($last." +2 day");
+$start = strtotime($last . " +1 day");
+$end = strtotime($last . " +2 day");
 $today = strtotime("today");
 
-$dns = "sqlite:"._FILE_DB_USER_ACTIVE_;
-$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+$dns = "" . _FILE_DB_USER_ACTIVE_;
+$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-
-$dns = "sqlite:"._FILE_DB_USER_ACTIVE_INDEX_;
-$dbh_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+$dns = "" . _FILE_DB_USER_ACTIVE_INDEX_;
+$dbh_index = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 /* 开始一个事务,关闭自动提交 */
 $dbh_index->beginTransaction();
 $query = "INSERT INTO active_index (user_id, date , duration , hit) VALUES (?, ?, ? , ?)";
 $sth_index = $dbh_index->prepare($query);
 
-$runing=$last;
+$runing = $last;
 while ($end <= $today) {
-	$runing=gmdate("Y-m-d",$start);
-	echo "runing:".$runing."\n";
-
-	# do one day
-	$query = "SELECT user_id, sum(duration) as time , sum(hit) as hit  FROM edit WHERE end between ? and ?  group by user_id ";
-	$stmt = $dbh->prepare($query);
-	$stmt->execute(array($start*1000,$end*1000));
-	while($result = $stmt->fetch(PDO::FETCH_ASSOC))
-	{
-		$user_id = $result["user_id"];
-		$time = $result["time"];
-		$hit = $result["hit"];
-		$sth_index->execute(array($user_id,$start*1000,$time,$hit));
-		echo "$user_id - $time - $hit \n";
-	}
-	$start = $end;
-	$end = strtotime( gmdate("Y-m-d",$end)." +1 day");
+    $runing = gmdate("Y-m-d", $start);
+    echo "runing:" . $runing . "\n";
+
+    # do one day
+    $query = "SELECT user_id, sum(duration) as time , sum(hit) as hit  FROM edit WHERE end between ? and ?  group by user_id ";
+    $stmt = $dbh->prepare($query);
+    $stmt->execute(array($start * 1000, $end * 1000));
+    while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
+        $user_id = $result["user_id"];
+        $time = $result["time"];
+        $hit = $result["hit"];
+        $sth_index->execute(array($user_id, $start * 1000, $time, $hit));
+        echo "$user_id - $time - $hit \n";
+    }
+    $start = $end;
+    $end = strtotime(gmdate("Y-m-d", $end) . " +1 day");
 }
 $dbh_index->commit();
 if (!$sth_index || ($sth_index && $sth_index->errorCode() != 0)) {
-	/*  识别错误且回滚更改  */
-	$sth_index->rollBack();
-	$error = $dbh_index->errorInfo();
-	echo "error:".$error[2]."\n";
+    /*  识别错误且回滚更改  */
+    $sth_index->rollBack();
+    $error = $dbh_index->errorInfo();
+    echo "error:" . $error[2] . "\n";
 }
 
-echo "run until:".$runing."\n";
-echo file_put_contents($logfile,$runing);
-
-?>
+echo "run until:" . $runing . "\n";
+echo file_put_contents($logfile, $runing);

+ 116 - 123
app/admin/word_index_weight_refresh.php

@@ -1,142 +1,135 @@
 <?php
 /*
 计算单词权重
-*/
+ */
 require_once '../path.php';
 require_once './word_index_weight_table.php';
 
-if(isset($_GET["from"])){
-	$from = $_GET["from"];
-	$to = $_GET["to"];
+if (isset($_GET["from"])) {
+    $from = $_GET["from"];
+    $to = $_GET["to"];
+} else {
+    if ($argc != 3) {
+        echo "无效的参数 ";
+        exit;
+    }
+    $from = (int) $argv[1];
+    $to = (int) $argv[2];
+    if ($to > 217) {
+        $to = 217;
+    }
 }
-else{
-	if ($argc != 3){
-	echo "无效的参数 ";
-	exit;
-	}
-	$from = (int)$argv[1];
-	$to =(int)$argv[2];
-	if($to>217){
-		$to = 217;
-	}
-}
-
 
-$dh_word = new PDO("sqlite:"._FILE_DB_WORD_INDEX_, "", "");
+$dh_word = new PDO("" . _FILE_DB_WORD_INDEX_, "", "");
 $dh_word->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dh_pali = new PDO("sqlite:"._FILE_DB_PALI_INDEX_, "", "");
+$dh_pali = new PDO("" . _FILE_DB_PALI_INDEX_, "", "");
 $dh_pali->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 echo "from=$from to = $to \n";
-for ($i=$from; $i <=$to ; $i++) {
-	$time_start = microtime(true);
-	echo "正在处理 book= $i ";
-	$query = "SELECT max(paragraph) from word where book={$i}";
-	$stmt = $dh_pali->query($query);
-	$row = $stmt->fetch(PDO::FETCH_NUM);
+for ($i = $from; $i <= $to; $i++) {
+    $time_start = microtime(true);
+    echo "正在处理 book= $i ";
+    $query = "SELECT max(paragraph) from word where book={$i}";
+    $stmt = $dh_pali->query($query);
+    $row = $stmt->fetch(PDO::FETCH_NUM);
     if ($row) {
-		$max_para =  $row[0];
-		echo "段落数量:$max_para \n";
-		for ($j=0; $j <=$max_para ; $j++) {
-			# code...
-			$query = "SELECT id,book,wordindex,bold from word where book={$i} and paragraph={$j} order by id ASC";
-			$stmt = $dh_pali->query($query);
-			$fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+        $max_para = $row[0];
+        echo "段落数量:$max_para \n";
+        for ($j = 0; $j <= $max_para; $j++) {
+            # code...
+            $query = "SELECT id,book,wordindex,bold from word where book={$i} and paragraph={$j} order by id ASC";
+            $stmt = $dh_pali->query($query);
+            $fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+            $query = "SELECT wordindex,count(*) as co from word where book={$i} and paragraph={$j} group by wordindex";
+            $stmt = $dh_pali->query($query);
+            $fetch_voc = $stmt->fetchAll(PDO::FETCH_ASSOC);
+            $vocabulary = array();
+            foreach ($fetch_voc as $key => $value) {
+                $vocabulary[$value["wordindex"]] = $value["co"];
+            }
+            for ($iWord = 0; $iWord < count($fetch); $iWord++) {
+                # 非黑体字
+                if ($fetch[$iWord]["bold"] == 0) {
+                    $count = $vocabulary[$fetch[$iWord]["wordindex"]];
+                    $paraWeight = pow(1.01, $count); //总分
+                    if ($paraWeight > 1.9) {
+                        $paraWeight = 1.9;
+                    }
+                    $weight = $paraWeight / $count;
+                } else {
+                    #黑体字
+                    #查找前后相连的黑体字
+                    $begin = $iWord;
+                    while ($fetch[$begin]["bold"] == 1) {
+                        $begin--;
+                        if ($begin < 0) {
+                            break;
+                        }
+                    }
+                    $begin = $begin + 1;
 
-			$query = "SELECT wordindex,count(*) as co from word where book={$i} and paragraph={$j} group by wordindex";
-			$stmt = $dh_pali->query($query);
-			$fetch_voc = $stmt->fetchAll(PDO::FETCH_ASSOC);			
-			$vocabulary = array();
-			foreach ($fetch_voc as $key => $value) {
-				$vocabulary[$value["wordindex"]] = $value["co"];
-			}
-			for ($iWord=0; $iWord <count($fetch) ; $iWord++) { 
-				# 非黑体字
-				if($fetch[$iWord]["bold"]==0){
-					$count = $vocabulary[$fetch[$iWord]["wordindex"]];
-					$paraWeight = pow(1.01,$count);//总分
-					if($paraWeight>1.9){
-						$paraWeight = 1.9;
-					}			
-					$weight = $paraWeight/$count;						
-				}
-				else{
-					#黑体字
-					#查找前后相连的黑体字
-					$begin = $iWord;
-					while ($fetch[$begin]["bold"] ==1) {
-						$begin--;
-						if($begin<0){
-							break;
-						}
-					}
-					$begin = $begin+1;
+                    $end = $iWord;
+                    while ($fetch[$end]["bold"] == 1) {
+                        $end++;
+                        if ($end > count($fetch) - 1) {
+                            break;
+                        }
+                    }
+                    $end = $end - 1;
+                    $bold_count = $end - $begin + 1;
+                    if ($bold_count == 1) {
 
-					$end = $iWord;
-					while ($fetch[$end]["bold"] ==1) {
-						$end++;
-						if($end>count($fetch)-1){
-							break;
-						}
-					}
-					$end = $end-1;
-					$bold_count = $end-$begin+1;
-					if($bold_count==1){
-						
-						$query = "SELECT * from wordindex where id=".$fetch[$iWord]["wordindex"];
-						$stmt_word = $dh_word->query($query);
-						$wordinfo = $stmt_word->fetch(PDO::FETCH_ASSOC);
-						$bookId = (int)$fetch[$iWord]["book"];
-						if(mb_substr($wordinfo["word"],-2)=="ti"){
-							$weight = 100+$book_weight[$bookId];
-						}
-						else{
-							$weight = 100+$book_weight[$bookId];
-						}
-						//echo "单独黑体 $weight \n";
-					}
-					else{
-						#连续黑体字
-						//echo "连续黑体字";
-						$len_sum = 0;
-						$len_curr = 0;
-						for ($iBold=$begin; $iBold <=$end ; $iBold++) { 
-							# code...
-							$boldid = $fetch[$iBold]["wordindex"];
-							$query = "SELECT len from wordindex where id=".$boldid;
-							$stmt_bold = $dh_word->query($query);
-							$wordbold = $stmt_bold->fetch(PDO::FETCH_ASSOC);
-							$len_sum += $wordbold["len"];
-							if($iBold==$i){
-								$len_curr = $wordbold["len"];
-							}
-						}
-						$weight = 10+$len_curr/$len_sum;
-					}
-				}
-				//echo $weight."\n";
-				$fetch[$iWord]["weight"] = (int)($weight*100);
-			}
-			# 将整段权重写入据库
-			$dh_pali->beginTransaction();
-			$query = "UPDATE word set weight = ? where id=? ";
-			$stmt_weight = $dh_pali->prepare($query);
-			foreach ($fetch as $key => $value) {
-        		$stmt_weight->execute(array($value["weight"],$value["id"]));
-			}
-			$dh_pali->commit();
-			if (!$stmt_weight || ($stmt_weight && $stmt_weight->errorCode() != 0)) {
-				$error = $dh_pali->errorInfo();
-				echo "error - $error[2]";
-			}
-			else{
-				//echo "修改数据库成功 book={$i} paragraph={$j} \n";
-			}
-		}
+                        $query = "SELECT * from wordindex where id=" . $fetch[$iWord]["wordindex"];
+                        $stmt_word = $dh_word->query($query);
+                        $wordinfo = $stmt_word->fetch(PDO::FETCH_ASSOC);
+                        $bookId = (int) $fetch[$iWord]["book"];
+                        if (mb_substr($wordinfo["word"], -2) == "ti") {
+                            $weight = 100 + $book_weight[$bookId];
+                        } else {
+                            $weight = 100 + $book_weight[$bookId];
+                        }
+                        //echo "单独黑体 $weight \n";
+                    } else {
+                        #连续黑体字
+                        //echo "连续黑体字";
+                        $len_sum = 0;
+                        $len_curr = 0;
+                        for ($iBold = $begin; $iBold <= $end; $iBold++) {
+                            # code...
+                            $boldid = $fetch[$iBold]["wordindex"];
+                            $query = "SELECT len from wordindex where id=" . $boldid;
+                            $stmt_bold = $dh_word->query($query);
+                            $wordbold = $stmt_bold->fetch(PDO::FETCH_ASSOC);
+                            $len_sum += $wordbold["len"];
+                            if ($iBold == $i) {
+                                $len_curr = $wordbold["len"];
+                            }
+                        }
+                        $weight = 10 + $len_curr / $len_sum;
+                    }
+                }
+                //echo $weight."\n";
+                $fetch[$iWord]["weight"] = (int) ($weight * 100);
+            }
+            # 将整段权重写入据库
+            $dh_pali->beginTransaction();
+            $query = "UPDATE word set weight = ? where id=? ";
+            $stmt_weight = $dh_pali->prepare($query);
+            foreach ($fetch as $key => $value) {
+                $stmt_weight->execute(array($value["weight"], $value["id"]));
+            }
+            $dh_pali->commit();
+            if (!$stmt_weight || ($stmt_weight && $stmt_weight->errorCode() != 0)) {
+                $error = $dh_pali->errorInfo();
+                echo "error - $error[2]";
+            } else {
+                //echo "修改数据库成功 book={$i} paragraph={$j} \n";
+            }
+        }
     } else {
         echo "无法获取段落最大值";
-	}
-	echo "处理时间 :".( microtime(true)-$time_start);
+    }
+    echo "处理时间 :" . (microtime(true) - $time_start);
 }
-?>

+ 1 - 1
app/article/add_article_to_collect.php

@@ -16,7 +16,7 @@ if(isset($_POST["id"])){
     $dirty_collect = array();
     $data = json_decode($_POST["data"]);
     $title = $_POST["title"];
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $article_id=$_POST["id"];
     //找出脏的collect
     $query = "SELECT collect_id FROM article_list  WHERE article_id = ? ";

+ 2 - 2
app/article/collect_get.php

@@ -8,7 +8,7 @@ require_once '../ucenter/function.php';
 
 
 if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $id=$_GET["id"];
     $query = "select * from collect  where id = ? ";
     $Fetch = PDO_FetchRow($query,array($id));
@@ -26,7 +26,7 @@ if(isset($_GET["id"])){
 }
 else if(isset($_GET["article"])){
     # 给文章编号,查文集信息
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $article=$_GET["article"];
     $query = "SELECT collect_id FROM article_list  WHERE article_id = ? ";
     $Fetch = PDO_FetchAll($query,array($article));

+ 1 - 1
app/article/collect_list.php

@@ -8,7 +8,7 @@ require_once '../ucenter/function.php';
 
 
 if(isset($_GET["userid"])){
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $userid=$_GET["userid"];
     $query = "SELECT * from collect  where owner = ".$PDO->quote($userid)." and status <> 0 order by modify_time DESC";
     $Fetch = PDO_FetchAll($query);

+ 1 - 1
app/article/get.php

@@ -8,7 +8,7 @@ require_once '../ucenter/function.php';
 
 
 if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $id=$_GET["id"];
     $query = "SELECT * FROM article  WHERE id = ? ";
     $Fetch = PDO_FetchRow($query,array($id));

+ 1 - 1
app/article/list.php

@@ -5,7 +5,7 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 if(isset($_GET["userid"])){
     $userid=$_GET["userid"];
     $query = "SELECT * from article  where owner = ? and status <> 0 order by modify_time DESC";

+ 1 - 1
app/article/list_article_in_collect.php

@@ -8,7 +8,7 @@ require_once '../ucenter/function.php';
 
 $output  = array();
 if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $article_id=$_GET["id"];
     $query = "SELECT collect_id as id from article_list  where article_id = ?  ";
     $exist = PDO_FetchAll($query,array($article_id));

+ 1 - 1
app/article/list_new.php

@@ -24,7 +24,7 @@ require_once '../collect/function.php';
     else{
         $begin = 0;
     }
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $query = "SELECT id,title,subtitle,summary,owner,modify_time from article  where status <> 0 ";
     
     if(isset($_GET["orderby"])){

+ 3 - 3
app/article/my_article_post.php

@@ -10,7 +10,7 @@ add_edit_event(_ARTICLE_EDIT_,$_POST["id"]);
 $respond=array("status"=>0,"message"=>"");
 
 # 检查是否由修改权限
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 $query = "SELECT owner FROM  article WHERE id= ?";
 $owner = PDO_FetchOne($query,array($_POST["id"]));
 if($owner!=$_COOKIE["userid"]){
@@ -43,7 +43,7 @@ if($_POST["import"]=='on'){
             echo json_encode($respond, JSON_UNESCAPED_UNICODE);
             exit;
         }
-        PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+        PDO_Connect(""._FILE_DB_SENTENCE_);
 
         /* 开始一个事务,关闭自动提交 */
         $PDO->beginTransaction();
@@ -112,7 +112,7 @@ if($_POST["import"]=='on'){
     }
 }
 
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 
 $query="UPDATE article SET title = ? , subtitle = ? , summary = ?, content = ?  , tag = ? , setting = ? , status = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
 $sth = $PDO->prepare($query);

+ 1 - 1
app/article/my_article_put.php

@@ -6,7 +6,7 @@ require_once '../hostsetting/function.php';
 require_once "../ucenter/active.php";
 
 $respond=array("status"=>0,"message"=>"");
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 
 $query="INSERT INTO article ( id,  title  , subtitle  , summary , content   , tag  , owner, setting  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
 $sth = $PDO->prepare($query);

+ 1 - 1
app/article/my_collect_post.php

@@ -9,7 +9,7 @@ add_edit_event(_COLLECTION_EDIT_,$_POST["id"]);
 
 $respond=array("status"=>0,"message"=>"");
 
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 
 $query="UPDATE collect SET title = ? , subtitle = ? , summary = ?, article_list = ?  ,  status = ? , lang = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
 $sth = $PDO->prepare($query);

+ 1 - 1
app/article/my_collect_put.php

@@ -6,7 +6,7 @@ require_once '../hostsetting/function.php';
 require_once "../ucenter/active.php";
 
 $respond=array("status"=>0,"message"=>"");
-PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+PDO_Connect(""._FILE_DB_USER_ARTICLE_);
 
 $query="INSERT INTO collect ( id,  title  , subtitle  , summary , article_list   , owner, lang  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ?  , ? , ? , ? , ? , ? , ? , ? ) ";
 $sth = $PDO->prepare($query);

+ 1 - 1
app/channal/coop_new_user.php

@@ -5,7 +5,7 @@ require_once '../public/function.php';
 
 $respond=array("status"=>0,"message"=>"");
 if(isset($_COOKIE["userid"]) && isset($_POST["channel_id"])){
-	PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+	PDO_Connect(""._FILE_DB_CHANNAL_);
 	$query="INSERT INTO cooperation ( channal_id , user_id  ,type  , power  )  
 	VALUES  (  ? , ? , ? , ? ) ";
 	$sth = $PDO->prepare($query);

+ 1 - 1
app/channal/function.php

@@ -4,7 +4,7 @@ class Channal
 {
     public $dbh;
     public function __construct() {
-        $dns = "sqlite:"._FILE_DB_CHANNAL_;
+        $dns = ""._FILE_DB_CHANNAL_;
         $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
     }

+ 2 - 2
app/channal/get.php

@@ -6,7 +6,7 @@ require_once "../public/_pdo.php";
 require_once '../ucenter/function.php';
 
 # 找我加入的群
-PDO_Connect("sqlite:"._FILE_DB_GROUP_);
+PDO_Connect(""._FILE_DB_GROUP_);
 $query = "SELECT group_id from group_member where user_id = ?  limit 0,100";
 $my_group = PDO_FetchAll($query,array($_COOKIE["userid"]));
 $userList = array();
@@ -17,7 +17,7 @@ foreach ($my_group as $key => $value) {
 }
 
 //找自己的
-PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+PDO_Connect(""._FILE_DB_CHANNAL_);
 $query = "SELECT * from channal where owner = ?  limit 0,100";
 $Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
 

+ 2 - 2
app/channal/my_channal_get.php

@@ -9,7 +9,7 @@ require_once '../group/function.php';
 
 
 if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+    PDO_Connect(""._FILE_DB_CHANNAL_);
     $id=$_GET["id"];
     $query = "SELECT * FROM channal  WHERE id = ? ";
 	$Fetch = PDO_FetchRow($query,array($id));
@@ -34,7 +34,7 @@ if(isset($_GET["id"])){
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 }
 else{
-    PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+    PDO_Connect(""._FILE_DB_CHANNAL_);
     $query = "SELECT * FROM channal  WHERE owner = ? ";
     $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);

+ 3 - 3
app/channal/my_channal_post.php

@@ -6,7 +6,7 @@ require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 
 #先查询对此channal是否有权限修改
-   PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+   PDO_Connect(""._FILE_DB_CHANNAL_);
 $cooperation = 0;
 if(isset($_POST["id"])){
     $query = "SELECT owner FROM channal WHERE id=?";
@@ -53,7 +53,7 @@ if (!$sth || ($sth && $sth->errorCode() != 0)) {
 }
 else{
     // 设置 句子库和逐词译库可见性
-    PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+    PDO_Connect(""._FILE_DB_SENTENCE_);
     $query="UPDATE sentence SET language = ?  , status = ? where  channal = ?  ";
     $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
     if (!$sth || ($sth && $sth->errorCode() != 0)) {
@@ -63,7 +63,7 @@ else{
     }
     else{
         // 设置 逐词译库可见性
-        PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+        PDO_Connect(""._FILE_DB_USER_WBW_);
         $query="UPDATE wbw_block SET lang = ?  , status = ? where  channal = ?  ";
         $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
         if (!$sth || ($sth && $sth->errorCode() != 0)) {

+ 1 - 1
app/channal/my_channal_put.php

@@ -5,7 +5,7 @@ require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 if(isset($_COOKIE["userid"])){
-	PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+	PDO_Connect(""._FILE_DB_CHANNAL_);
 	$query="INSERT INTO channal ( id,  owner  , name  , summary ,  status  , lang, create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ?  ) ";
 	$sth = $PDO->prepare($query);
 	$sth->execute(array(UUID::v4() , $_COOKIE["userid"] , $_POST["name"] , "" , $_POST["status"] ,$_POST["lang"]  ,  mTime() ,  mTime() , mTime() ));

+ 1 - 1
app/collect/function.php

@@ -6,7 +6,7 @@ class CollectInfo
     private $dbh;
     private $buffer;
     public function __construct() {
-        $dns = "sqlite:"._FILE_DB_USER_ARTICLE_;
+        $dns = ""._FILE_DB_USER_ARTICLE_;
         $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
         $buffer = array();

+ 1 - 1
app/collect/list.php

@@ -23,7 +23,7 @@ require_once '../ucenter/function.php';
     else{
         $begin = 0;
     }
-    PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
     $query = "SELECT * FROM collect  where  1 ";
     if(isset($_GET["orderby"])){
         switch ($_GET["orderby"]) {

+ 1 - 1
app/course/course_get.php

@@ -6,7 +6,7 @@ require_once "../public/_pdo.php";
 require_once "../ucenter/function.php";
 
 $userinfo = new UserInfo();
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from course where id = ?   limit 0,1";
 $fCourse = PDO_FetchRow($query,array($_GET["id"]));
 

+ 1 - 1
app/course/course_list.php

@@ -18,7 +18,7 @@ require_once '../ucenter/function.php';
 40 已完结
 */
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 if(isset($_GET["teacher"])){
     $query = "SELECT * from course where teacher = ?  order by create_time DESC limit 0,100";

+ 1 - 1
app/course/lesson_get.php

@@ -7,7 +7,7 @@ require_once "../ucenter/function.php";
 
 $userinfo = new UserInfo();
 
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from lesson where id = ?   limit 0,1";
 $fLesson = PDO_FetchRow($query,array($_GET["id"]));
 

+ 1 - 1
app/course/lesson_list.php

@@ -5,7 +5,7 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from lesson where course_id = ? order by date DESC    limit 0,200";
 $fAllLesson = PDO_FetchAll($query,array($_GET["id"]));
 echo json_encode($fAllLesson, JSON_UNESCAPED_UNICODE);

+ 1 - 1
app/course/list_new.php

@@ -7,7 +7,7 @@ require_once '../public/load_lang.php';
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:" . _FILE_DB_COURSE_);
+PDO_Connect("" . _FILE_DB_COURSE_);
 $query = "SELECT * from course where 1  order by modify_time DESC limit 0,4";
 $Fetch = PDO_FetchAll($query);
 

+ 1 - 1
app/course/my_course_edit.php

@@ -41,7 +41,7 @@ require_once "../public/_pdo.php";
 require_once '../media/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 
 $query = "SELECT * from course where id = ?   limit 0,1";

+ 1 - 1
app/course/my_course_insert.php

@@ -4,7 +4,7 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 $query = "INSERT INTO course (id,  title,  subtitle, creator, tag, summary, status, cover, teacher,  lang , speech_lang ,attachment, lesson_num , create_time , modify_time , receive_time ) 
                       VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?  )";

+ 1 - 1
app/course/my_course_list.php

@@ -37,7 +37,7 @@ require_once '../public/load_lang.php';
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from course where creator = ?  order by modify_time DESC limit 0,100";
 $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
 

+ 1 - 1
app/course/my_course_update.php

@@ -34,7 +34,7 @@ if(isset($_FILES["cover"])){
 
 //处理文件上传结束
 
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 $query="UPDATE course SET  title = ? , subtitle = ? ,  summary = ? , teacher = ?  , tag = ?  , lang = ?  , attachment = ? , status = ? , receive_time = ?  , modify_time = ?   where  id = ?  ";
 $sth = $PDO->prepare($query);

+ 1 - 1
app/course/my_lesson_edit.php

@@ -43,7 +43,7 @@ require_once "../public/_pdo.php";
 require_once '../media/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 $query = "SELECT * from lesson where id = ?  limit 0,1";
 $Fetch = PDO_FetchAll($query,array($_GET["lesson"]));

+ 1 - 1
app/course/my_lesson_insert.php

@@ -4,7 +4,7 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 
 $query="UPDATE course SET  receive_time= ?  , modify_time= ?   where  id = ?  ";
 PDO_Execute($query,array(mTime(),mTime(),$_POST["course_id"]));

+ 1 - 1
app/course/my_lesson_list.php

@@ -42,7 +42,7 @@ require_once "../public/_pdo.php";
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from course where id = ?   limit 0,1";
 $Fetch = PDO_FetchAll($query,array($_GET["course"]));
 if(count($Fetch)==0)

+ 1 - 1
app/course/my_lesson_new.php

@@ -35,7 +35,7 @@ require_once "../public/_pdo.php";
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query = "SELECT * from course where id = ?   limit 0,1";
 $Fetch = PDO_FetchAll($query,array($_GET["course"]));
 if(count($Fetch)==0)

+ 1 - 1
app/course/my_lesson_update.php

@@ -4,7 +4,7 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect(""._FILE_DB_COURSE_);
 $query="SELECT course_id from lesson  where  id = ?  ";
 $course_id = PDO_FetchOne($query,array($_POST["lesson"]));
 

+ 2 - 2
app/course/teacher_list.php

@@ -7,7 +7,7 @@ require_once '../public/load_lang.php';
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:" . _FILE_DB_COURSE_);
+PDO_Connect("" . _FILE_DB_COURSE_);
 $query = "SELECT teacher,count(*) as co from course where 1 group by teacher order by co DESC limit 0,4";
 $Fetch = PDO_FetchAll($query);
 
@@ -17,7 +17,7 @@ foreach ($Fetch as $value) {
     echo '<div class="teacher_text">';
     echo '<div class="title"><a href="../uhome/course.php?userid=' . $value['teacher'] . '">' . ucenter_getA($value['teacher']) . '</a></div>';
     echo '<div class="teacher_intro">';
-    PDO_Connect("sqlite:" . _FILE_DB_USERINFO_);
+    PDO_Connect("" . _FILE_DB_USERINFO_);
     $query = "SELECT bio from profile where user_id = ? limit 0,10";
     $Fetch = PDO_FetchAll($query,array($value['teacher']));
     if($Fetch){

+ 1 - 1
app/dict/comp_csv.php

@@ -9,7 +9,7 @@ $myfile = fopen(_DIR_TEMP_ . "/comp.csv", "a");
 $filefail = fopen(_DIR_TEMP_ . "/comp_fail.txt", "a");
 $iMax = 10;
 /*
-$dns = "sqlite:" . _FILE_DB_WORD_INDEX_;
+$dns = "" . _FILE_DB_WORD_INDEX_;
 $dbh_word = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_word->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 

+ 371 - 390
app/dict/dict_lookup.php

@@ -4,424 +4,405 @@ require_once '../path.php';
 require_once '../public/casesuf.inc';
 require_once '../public/union.inc';
 require_once "../public/_pdo.php";
-require_once "../public/load_lang.php";//语言文件
+require_once "../public/load_lang.php"; //语言文件
 require_once "../public/function.php";
 require_once "../search/word_function.php";
 require_once "../ucenter/active.php";
 
 _load_book_index();
 
+$op = $_GET["op"];
+$word = mb_strtolower($_GET["word"], 'UTF-8');
+$org_word = $word;
 
-$op=$_GET["op"];
-$word=mb_strtolower($_GET["word"],'UTF-8');
-$org_word=$word;
+$count_return = 0;
+$dict_list = array();
 
-$count_return=0;
-$dict_list=array();
+$right_word_list = "";
 
-$right_word_list="";
-
-global $PDO;
-function isExsit($word){
 global $PDO;
-		$query = "SELECT count(*) as co from dict where word = ? ";
-		$row=PDO_FetchOne($query,array($word));
-		if($row[0]==0){
-			return false;
-		}
-		else{
-			return true;
-		}
+function isExsit($word)
+{
+    global $PDO;
+    $query = "SELECT count(*) as co from " . _TABLE_DICT_REF_ . " where word = ? ";
+    $row = PDO_FetchOne($query, array($word));
+    if ($row[0] == 0) {
+        return false;
+    } else {
+        return true;
+    }
 }
 
-function myfunction($v1,$v2)
+function myfunction($v1, $v2)
 {
-return $v1 . "+" . $v2;
+    return $v1 . "+" . $v2;
 }
 
-function mySplit($strWord){
-	//echo("<br>".$strWord."<br>");
-	$doubleword="kkggccjjṭṭḍḍttddppbb";
-	$len=mb_strlen($strWord,"UTF-8");
-	if($len>5){
-		for($i=$len-1;$i>3;$i--){
-			$str1=mb_substr($strWord,0,$i,"UTF-8");
-			$str2=mb_substr($strWord,$i,NULL,"UTF-8");
-			//echo "$str1 + $str2 = ";
-			if(isExsit($str1)){
-				//echo "match";
-				$left2=mb_substr($str2,0,2,"UTF-8");
-				if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-					$str2=mb_substr($str2,1,NULL,"UTF-8");
-				}
-				return array($str1,$str2);
-			}
-			else{
-				$str1=$str1."a";
-				if(isExsit($str1)){
-					//echo "match";
-					$left2=mb_substr($str2,0,2,"UTF-8");
-					if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-						$str2=mb_substr($str2,1,NULL,"UTF-8");
-					}
-					return array($str1,$str2);
-				}
-			}
-		}
-		//not found
-		if(mb_substr($strWord,0,1,"UTF-8")=="ā"){
-			$strWord='a'.mb_substr($strWord,1,NULL,"UTF-8");
-			for($i=$len-1;$i>3;$i--){
-				$str1=mb_substr($strWord,0,$i,"UTF-8");
-				$str2=mb_substr($strWord,$i,NULL,"UTF-8");
-				//echo "$str1 + $str2 = ";
-				if(isExsit($str1)){
-					//echo "match";
-					$left2=mb_substr($str2,0,2,"UTF-8");
-					if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-						$str2=mb_substr($str2,1,NULL,"UTF-8");
-					}
-					return array($str1,$str2);
-				}
-				else{
-					$str1=$str1."a";
-					if(isExsit($str1)){
-						//echo "match";
-						$left2=mb_substr($str2,0,2,"UTF-8");
-						if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-							$str2=mb_substr($str2,1,NULL,"UTF-8");
-						}
-						return array($str1,$str2);
-					}
-				}
-			}			
-		}
-		//not found
-		if(mb_substr($strWord,0,1,"UTF-8")=="e"){
-			$strWord='i'.mb_substr($strWord,1,NULL,"UTF-8");
-			for($i=$len-1;$i>3;$i--){
-				$str1=mb_substr($strWord,0,$i,"UTF-8");
-				$str2=mb_substr($strWord,$i,NULL,"UTF-8");
-				//echo "$str1 + $str2 = ";
-				if(isExsit($str1)){
-					//echo "match";
-					$left2=mb_substr($str2,0,2,"UTF-8");
-					if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-						$str2=mb_substr($str2,1,NULL,"UTF-8");
-					}
-					return array($str1,$str2);
-				}
-				else{
-					$str1=$str1."a";
-					if(isExsit($str1)){
-						//echo "match";
-						$left2=mb_substr($str2,0,2,"UTF-8");
-						if(mb_strpos($doubleword,$left2,0,"UTF-8")!==FALSE){
-							$str2=mb_substr($str2,1,NULL,"UTF-8");
-						}
-						return array($str1,$str2);
-					}
-				}
-			}			
-		}		
-	}
-	return(FALSE);
+function mySplit($strWord)
+{
+    //echo("<br>".$strWord."<br>");
+    $doubleword = "kkggccjjṭṭḍḍttddppbb";
+    $len = mb_strlen($strWord, "UTF-8");
+    if ($len > 5) {
+        for ($i = $len - 1; $i > 3; $i--) {
+            $str1 = mb_substr($strWord, 0, $i, "UTF-8");
+            $str2 = mb_substr($strWord, $i, null, "UTF-8");
+            //echo "$str1 + $str2 = ";
+            if (isExsit($str1)) {
+                //echo "match";
+                $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                    $str2 = mb_substr($str2, 1, null, "UTF-8");
+                }
+                return array($str1, $str2);
+            } else {
+                $str1 = $str1 . "a";
+                if (isExsit($str1)) {
+                    //echo "match";
+                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                        $str2 = mb_substr($str2, 1, null, "UTF-8");
+                    }
+                    return array($str1, $str2);
+                }
+            }
+        }
+        //not found
+        if (mb_substr($strWord, 0, 1, "UTF-8") == "ā") {
+            $strWord = 'a' . mb_substr($strWord, 1, null, "UTF-8");
+            for ($i = $len - 1; $i > 3; $i--) {
+                $str1 = mb_substr($strWord, 0, $i, "UTF-8");
+                $str2 = mb_substr($strWord, $i, null, "UTF-8");
+                //echo "$str1 + $str2 = ";
+                if (isExsit($str1)) {
+                    //echo "match";
+                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                        $str2 = mb_substr($str2, 1, null, "UTF-8");
+                    }
+                    return array($str1, $str2);
+                } else {
+                    $str1 = $str1 . "a";
+                    if (isExsit($str1)) {
+                        //echo "match";
+                        $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                        if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                            $str2 = mb_substr($str2, 1, null, "UTF-8");
+                        }
+                        return array($str1, $str2);
+                    }
+                }
+            }
+        }
+        //not found
+        if (mb_substr($strWord, 0, 1, "UTF-8") == "e") {
+            $strWord = 'i' . mb_substr($strWord, 1, null, "UTF-8");
+            for ($i = $len - 1; $i > 3; $i--) {
+                $str1 = mb_substr($strWord, 0, $i, "UTF-8");
+                $str2 = mb_substr($strWord, $i, null, "UTF-8");
+                //echo "$str1 + $str2 = ";
+                if (isExsit($str1)) {
+                    //echo "match";
+                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                        $str2 = mb_substr($str2, 1, null, "UTF-8");
+                    }
+                    return array($str1, $str2);
+                } else {
+                    $str1 = $str1 . "a";
+                    if (isExsit($str1)) {
+                        //echo "match";
+                        $left2 = mb_substr($str2, 0, 2, "UTF-8");
+                        if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
+                            $str2 = mb_substr($str2, 1, null, "UTF-8");
+                        }
+                        return array($str1, $str2);
+                    }
+                }
+            }
+        }
+    }
+    return (false);
 }
 
+switch ($op) {
+    case "pre": //预查询
+        PDO_Connect("" . _FILE_DB_REF_INDEX_);
+        echo "<div>";
+        $query = "SELECT word,count from " . _TABLE_DICT_REF_ . " where eword like ?  OR word like ?  limit 0,20";
 
-switch($op){
-	case "pre"://预查询
-		PDO_Connect("sqlite:"._FILE_DB_REF_INDEX_);
-		echo "<div>";
-		$query = "SELECT word,count from dict where eword like ?  OR word like ?  limit 0,20";
+        $Fetch = PDO_FetchAll($query, array($word . '%', $word . '%'));
+        $iFetch = count($Fetch);
+        if ($iFetch > 0) {
+            for ($i = 0; $i < $iFetch; $i++) {
+                $word = $Fetch[$i]["word"];
+                $count = $Fetch[$i]["count"];
+                echo "<div class='dict_word_list'>";
+                echo "<a onclick='dict_pre_word_click(\"$word\")'>$word-$count</a>";
+                echo "</div>";
+            }
+        }
+        echo "</div>";
+        break;
+    case "search":
+        add_edit_event(_DICT_LOOKUP_, $word);
+        echo "<div id='dict_list_shell' onclick='setNaviVisibility()'><div id='dict_list' class='dict_list_off'></div></div>";
+        echo "<div id='dict_ref'>";
+        $dict_list_a = [];
+        //社区字典开始
+        PDO_Connect("" . _FILE_DB_WBW_);
+        $query = "SELECT *  from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
+        $Fetch = PDO_FetchAll($query, array($word));
+        $iFetch = count($Fetch);
+        $count_return += $iFetch;
+        if ($iFetch > 0) {
+            $userlist = array();
+            foreach ($Fetch as $value) {
+                if (isset($userlist[$value["creator"]])) {
+                    $userlist[$value["creator"]] += 1;
+                } else {
+                    $userlist[$value["creator"]] = 1;
+                }
+                $userwordcase = $value["type"] . "#" . $value["gramma"];
+                if (isset($userdict["{$userwordcase}"])) {
+                    $userdict["{$userwordcase}"]["mean"] .= $value["mean"] . ";";
+                    $userdict["{$userwordcase}"]["factors"] .= $value["factors"];
+                } else {
+                    $userdict["{$userwordcase}"]["mean"] = $value["mean"];
+                    $userdict["{$userwordcase}"]["factors"] = $value["factors"];
+                }
 
-		$Fetch = PDO_FetchAll($query,array($word.'%',$word.'%'));
-		$iFetch=count($Fetch);
-		if($iFetch>0){
-			for($i=0;$i<$iFetch;$i++){
-				$word=$Fetch[$i]["word"];
-				$count=$Fetch[$i]["count"];
-				echo  "<div class='dict_word_list'>";
-				echo  "<a onclick='dict_pre_word_click(\"$word\")'>$word-$count</a>";
-				echo  "</div>";
-			}
-		}
-		echo "</div>";
-		break;
-	case "search":
-		add_edit_event(_DICT_LOOKUP_,$word);
-		echo "<div id='dict_list_shell' onclick='setNaviVisibility()'><div id='dict_list' class='dict_list_off'></div></div>";
-		echo "<div id='dict_ref'>";	
-		$dict_list_a = [];
-		//社区字典开始
-		PDO_Connect("sqlite:"._FILE_DB_WBW_);
-		$query = "SELECT *  from dict where pali = ? limit 0,100";
-		$Fetch = PDO_FetchAll($query,array($word));
-		$iFetch=count($Fetch);
-		$count_return+=$iFetch;
-		if($iFetch>0){
-			$userlist = array();
-			foreach($Fetch as $value){
-				if(isset($userlist[$value["creator"]])){
-					$userlist[$value["creator"]] += 1;
-				}
-				else{
-					$userlist[$value["creator"]] = 1;
-				}
-				$userwordcase = $value["type"]."#".$value["gramma"];
-				if(isset($userdict["{$userwordcase}"])){
-					$userdict["{$userwordcase}"]["mean"] .= $value["mean"].";";
-					$userdict["{$userwordcase}"]["factors"] .= $value["factors"];
-				}
-				else{
-					$userdict["{$userwordcase}"]["mean"] = $value["mean"];
-					$userdict["{$userwordcase}"]["factors"] = $value["factors"];
-				}
-				
+            }
+            echo "<div class='dict_word'>";
+            echo "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
+            $dict_list_a[] = array("net", $_local->gui->com_dict);
 
-			}
-			echo "<div class='dict_word'>";
-			echo "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
-			$dict_list_a[] = array("net",$_local->gui->com_dict);
+            foreach ($userdict as $key => $value) {
+                echo "<div class='mean'>{$key}:{$value["mean"]}</div>";
+            }
+            echo "<div><span>{$_local->gui->contributor}:</span>";
+            foreach ($userlist as $key => $value) {
+                echo $key . "[" . $value . "]";
+            }
+            echo "</div>";
+            echo "</div>";
+        }
+        //社区字典结束
 
-			foreach($userdict as $key => $value){
-				echo "<div class='mean'>{$key}:{$value["mean"]}</div>";
-			}
-			echo "<div><span>{$_local->gui->contributor}:</span>";
-			foreach ($userlist as $key => $value) {
-				echo $key."[".$value."]";
-			}
-			echo "</div>";
-			echo "</div>";
-		}
-		//社区字典结束
+        PDO_Connect("" . _FILE_DB_REF_);
+        //直接查询
+        $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,100";
 
-		PDO_Connect("sqlite:"._FILE_DB_REF_);
-		//直接查询
-		$query = "SELECT dict.dict_id,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,100";
-		
-		$Fetch = PDO_FetchAll($query,array($word));
-		$iFetch=count($Fetch);
-		$count_return+=$iFetch;
-		if($iFetch>0){
-			for($i=0;$i<$iFetch;$i++){
-				$mean=$Fetch[$i]["mean"];
-				$dictid=$Fetch[$i]["dict_id"];
-				$dict_list[$dictid]=$Fetch[$i]["shortname"];
-				$dict_list_a[] = array("ref_dict_$dictid",$Fetch[$i]["shortname"]);
-				$outXml = "<div class='dict_word'>";
-				$outXml = $outXml."<a name='ref_dict_$dictid'></a>";
-				$outXml = $outXml."<div class='dict'>".$Fetch[$i]["shortname"]."</div>";
-				$outXml = $outXml."<div class='mean'>".$mean."</div>";
-				$outXml = $outXml."</div>";
-				echo $outXml;
-			}
-		}
-		//去除尾查
-		$newWord=array();
-		for ($row = 0; $row < count($case); $row++) {
-			$len=mb_strlen($case[$row][1],"UTF-8");
-			$end=mb_substr($word, 0-$len,NULL,"UTF-8");
-			if($end==$case[$row][1]){
-				$base=mb_substr($word, 0,mb_strlen($word,"UTF-8")-$len,"UTF-8").$case[$row][0];
-				if($base!=$word){
-					$thiscase = "";
-					$arrCase = explode('$',$case[$row][2]);
-					foreach($arrCase as $value){
-						$caseid = "grammar_".str_replace('.','',$value);
-						$thiscase .= "<guide gid='$caseid'>$value</guide>";
-					}
-					
-					
-					if(isset($newWord[$base])){
-						$newWord[$base] .= "<br />".$thiscase;
-					}
-					else{
-						$newWord[$base] = $thiscase;
-					}
-				}
-			}
-		}
+        $Fetch = PDO_FetchAll($query, array($word));
+        $iFetch = count($Fetch);
+        $count_return += $iFetch;
+        if ($iFetch > 0) {
+            for ($i = 0; $i < $iFetch; $i++) {
+                $mean = $Fetch[$i]["mean"];
+                $dictid = $Fetch[$i]["dict_id"];
+                $dict_list[$dictid] = $Fetch[$i]["shortname"];
+                $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
+                $outXml = "<div class='dict_word'>";
+                $outXml = $outXml . "<a name='ref_dict_$dictid'></a>";
+                $outXml = $outXml . "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                $outXml = $outXml . "<div class='mean'>" . $mean . "</div>";
+                $outXml = $outXml . "</div>";
+                echo $outXml;
+            }
+        }
+        //去除尾查
+        $newWord = array();
+        for ($row = 0; $row < count($case); $row++) {
+            $len = mb_strlen($case[$row][1], "UTF-8");
+            $end = mb_substr($word, 0 - $len, null, "UTF-8");
+            if ($end == $case[$row][1]) {
+                $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $case[$row][0];
+                if ($base != $word) {
+                    $thiscase = "";
+                    $arrCase = explode('$', $case[$row][2]);
+                    foreach ($arrCase as $value) {
+                        $caseid = "grammar_" . str_replace('.', '', $value);
+                        $thiscase .= "<guide gid='$caseid'>$value</guide>";
+                    }
 
-		if(count($newWord)>0){
-			foreach($newWord as $x=>$x_value) {
-				$query = "SELECT dict.dict_id,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
-				$Fetch = PDO_FetchAll($query,array($x));
-				$iFetch=count($Fetch);
-				$count_return+=$iFetch;
-				if($iFetch>0){
-					$dict_list_a[] = array("word_$x",$x);
-					echo "<div style='font-size:120%;font-weight:700;'><a name='word_$x'></a>".$x."</div>" ;
-					//语法信息
-					foreach($_local->grammastr as $gr){
-						$x_value = str_replace($gr->id,$gr->value,$x_value);
-					}
-					echo "<div class='dict_find_gramma'>" . $x_value . "</div>";
-					for($i=0;$i<$iFetch;$i++){
-						$mean=$Fetch[$i]["mean"];
-						$dictid=$Fetch[$i]["dict_id"];
-						$dict_list[$dictid]=$Fetch[$i]["shortname"];
-						$dict_list_a[] = array("ref_dict_$dictid",$Fetch[$i]["shortname"]);
-						echo "<div class='dict_word'>";
-						echo "<a name='ref_dict_$dictid'></a>";
-						echo "<div class='dict'>".$Fetch[$i]["shortname"]."</div>";
-						echo "<div class='mean'>".$mean."</div>";
-						echo "</div>";
-					}
-				}			  
-			}
-		}
-		//去除尾查结束
-		
-		//查连读词
-		if($count_return<2){
-			echo "<div>Junction</div>";
-			$newWord=array();
-			for ($row = 0; $row < count($un); $row++) {
-				$len=mb_strlen($un[$row][1],"UTF-8");
-				$end=mb_substr($word, 0-$len,NULL,"UTF-8");
-				if($end==$un[$row][1]){
-					$base=mb_substr($word, 0,mb_strlen($word,"UTF-8")-$len,"UTF-8").$un[$row][0];
-						$arr_un=explode("+",$base);
-						foreach ($arr_un as $oneword)
-						{
-						  echo "<a onclick='dict_pre_word_click(\"$oneword\")'>$oneword</a> + ";
-						}
-						echo "<br />";
-				}
-			}		
-		}
-		
-		//查内容
-		if($count_return<2){
-			$word1=$org_word;
-			$wordInMean="%$org_word%";
-			echo "include $org_word:<br />";
-			$query = "SELECT dict.dict_id,dict.word,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where mean like ? limit 0,30";
-			$Fetch = PDO_FetchAll($query,array($wordInMean));
-			$iFetch=count($Fetch);
-			$count_return+=$iFetch;
-			if($iFetch>0){
-				for($i=0;$i<$iFetch;$i++){
-					$mean=$Fetch[$i]["mean"];
-					$pos=mb_stripos($mean,$word,0,"UTF-8");
-					if($pos){
-						if($pos>20){
-							$start=$pos-20;
-						}
-						else{
-							$start=0;
-						}
-						$newmean=mb_substr($mean,$start,100,"UTF-8");
-					}
-					else{
-						$newmean=$mean;
-					}
-					$pos=mb_stripos($newmean,$word1,0,"UTF-8");
-					$head=mb_substr($newmean,0,$pos,"UTF-8");
-					$mid=mb_substr($newmean,$pos,mb_strlen($word1,"UTF-8"),"UTF-8");
-					$end=mb_substr($newmean,$pos+mb_strlen($word1,"UTF-8"),NULL,"UTF-8");
-					$heigh_light_mean="$head<hl>$mid</hl>$end";
-					echo "<div class='dict_word'>";
-					echo "<div class='pali'>".$Fetch[$i]["word"]."</div>";
-					echo "<div class='dict'>".$Fetch[$i]["shortname"]."</div>";
-					echo "<div class='mean'>".$heigh_light_mean."</div>";
-					echo "</div>";
-				}
-			}		
-		}
-		
-		//拆复合词
-		
-		$splitWord=$word;
-		$part=array();
-		if($count_return<2){
-			echo "Try to split comp:<br>";
-			while(($split=mySplit($splitWord))!==FALSE){
-				array_push($part,$split[0]);
-				$splitWord=$split[1];
-			}
-			if(count($part)>0){
-				array_push($part,$splitWord);
-				$newPart=ltrim(array_reduce($part,"myfunction"),"+");
-				echo $newPart;
-			}
-		}
+                    if (isset($newWord[$base])) {
+                        $newWord[$base] .= "<br />" . $thiscase;
+                    } else {
+                        $newWord[$base] = $thiscase;
+                    }
+                }
+            }
+        }
 
+        if (count($newWord) > 0) {
+            foreach ($newWord as $x => $x_value) {
+                $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
+                $Fetch = PDO_FetchAll($query, array($x));
+                $iFetch = count($Fetch);
+                $count_return += $iFetch;
+                if ($iFetch > 0) {
+                    $dict_list_a[] = array("word_$x", $x);
+                    echo "<div style='font-size:120%;font-weight:700;'><a name='word_$x'></a>" . $x . "</div>";
+                    //语法信息
+                    foreach ($_local->grammastr as $gr) {
+                        $x_value = str_replace($gr->id, $gr->value, $x_value);
+                    }
+                    echo "<div class='dict_find_gramma'>" . $x_value . "</div>";
+                    for ($i = 0; $i < $iFetch; $i++) {
+                        $mean = $Fetch[$i]["mean"];
+                        $dictid = $Fetch[$i]["dict_id"];
+                        $dict_list[$dictid] = $Fetch[$i]["shortname"];
+                        $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
+                        echo "<div class='dict_word'>";
+                        echo "<a name='ref_dict_$dictid'></a>";
+                        echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                        echo "<div class='mean'>" . $mean . "</div>";
+                        echo "</div>";
+                    }
+                }
+            }
+        }
+        //去除尾查结束
 
-		echo "<div id='dictlist'>";
-		foreach($dict_list_a as $x_value) {
-			if(substr($x_value[0],0,4)=="word"){
-				echo "<div style='font-size:120%;font-weight:700;margin-top:15px;'>";
-				echo "<a href='#{$x_value[0]}'>$x_value[1]</a></div>";
-			}
-			else{
-				echo "<div><a href='#{$x_value[0]}'>$x_value[1]</a></div>";
-			}
-		  }		
-		echo "<div>";
+        //查连读词
+        if ($count_return < 2) {
+            echo "<div>Junction</div>";
+            $newWord = array();
+            for ($row = 0; $row < count($un); $row++) {
+                $len = mb_strlen($un[$row][1], "UTF-8");
+                $end = mb_substr($word, 0 - $len, null, "UTF-8");
+                if ($end == $un[$row][1]) {
+                    $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $un[$row][0];
+                    $arr_un = explode("+", $base);
+                    foreach ($arr_un as $oneword) {
+                        echo "<a onclick='dict_pre_word_click(\"$oneword\")'>$oneword</a> + ";
+                    }
+                    echo "<br />";
+                }
+            }
+        }
 
-		$arrWords = countWordInPali($word,true);
-		$weight = 0;
-		foreach($arrWords as $oneword){
-			$weight += $oneword["count"] * $oneword["len"];
-		}
-		//echo "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
-		//echo "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
-		$right_word_list .= "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
-		$right_word_list .= "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
-		foreach($arrWords as $oneword){
-			if($oneword["bold"]>0){
-				//echo "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
-				$right_word_list .= "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
-			}
-			else{
-				//echo "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
-				$right_word_list .= "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
-			}
-		}		
-		echo "</div>";
-		echo "</div>";
-		echo "</div>";
-		//参考字典查询结束
+        //查内容
+        if ($count_return < 2) {
+            $word1 = $org_word;
+            $wordInMean = "%$org_word%";
+            echo "include $org_word:<br />";
+            $query = "SELECT dict.dict_id,dict.word,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where mean like ? limit 0,30";
+            $Fetch = PDO_FetchAll($query, array($wordInMean));
+            $iFetch = count($Fetch);
+            $count_return += $iFetch;
+            if ($iFetch > 0) {
+                for ($i = 0; $i < $iFetch; $i++) {
+                    $mean = $Fetch[$i]["mean"];
+                    $pos = mb_stripos($mean, $word, 0, "UTF-8");
+                    if ($pos) {
+                        if ($pos > 20) {
+                            $start = $pos - 20;
+                        } else {
+                            $start = 0;
+                        }
+                        $newmean = mb_substr($mean, $start, 100, "UTF-8");
+                    } else {
+                        $newmean = $mean;
+                    }
+                    $pos = mb_stripos($newmean, $word1, 0, "UTF-8");
+                    $head = mb_substr($newmean, 0, $pos, "UTF-8");
+                    $mid = mb_substr($newmean, $pos, mb_strlen($word1, "UTF-8"), "UTF-8");
+                    $end = mb_substr($newmean, $pos + mb_strlen($word1, "UTF-8"), null, "UTF-8");
+                    $heigh_light_mean = "$head<hl>$mid</hl>$end";
+                    echo "<div class='dict_word'>";
+                    echo "<div class='pali'>" . $Fetch[$i]["word"] . "</div>";
+                    echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                    echo "<div class='mean'>" . $heigh_light_mean . "</div>";
+                    echo "</div>";
+                }
+            }
+        }
 
-		//用户词典编辑窗口
-		echo "<div id='dict_user' >";	
-		echo "<div><a href='word_statistics.php?word={$word}'>";
-		echo "<svg t='1596783175334' class='icon' style='font-size: xxx-large; fill: var(--link-hover-color); margin: 5px;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='7755' width='200' height='200'><path d='M1019.904 450.56L536.576 557.056l417.792 208.896C999.424 692.224 1024 606.208 1024 512c0-20.48 0-40.96-4.096-61.44z m-12.288-61.44C958.464 184.32 786.432 28.672 573.44 4.096L446.464 512l561.152-122.88zM737.28 970.752c73.728-36.864 139.264-90.112 188.416-159.744L507.904 602.112l229.376 368.64zM512 0C229.376 0 0 229.376 0 512s229.376 512 512 512c61.44 0 118.784-12.288 172.032-28.672L385.024 512 512 0z' p-id='7756'></path></svg>";
-		echo "<br>{$_local->gui->click_to_chart}</a></div>";
-		echo $right_word_list;
-		echo "<div class='dict_word' ><b>{$_local->gui->undone_function}</b>";
-		echo "<div class='' onclick=\"dict_show_edit()\">{$_local->gui->edit}</div>";		
-		echo "<div class='pali'>{$word}</div>";
+        //拆复合词
 
-		if($iFetch>0){
-			echo "<div id='user_word_edit' style='display:none'>";
-		}
-		else{
-			echo "<div id='user_word_edit'>";
-		}
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
-		echo "<select id=\"id_type\" name=\"type\" >";
-		foreach($_local->type_str as $type){
-			echo "<option value=\"{$type->id}\" >{$type->value}</option>";
-		}
-		echo "</select>";
-		echo "</fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' value=''/></fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' value=''/></fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' value=''/></fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea></textarea></fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' value=''/></fieldset>";
-		echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' value=''/></fieldset>";
-		echo "<div class=''><button>{$_local->gui->add_to} {$_local->gui->my_dictionary}</button></div>";
-		echo "</div>";
-		echo "</div>";	
-		echo "</div>";			
-		//查用户词典结束	
+        $splitWord = $word;
+        $part = array();
+        if ($count_return < 2) {
+            echo "Try to split comp:<br>";
+            while (($split = mySplit($splitWord)) !== false) {
+                array_push($part, $split[0]);
+                $splitWord = $split[1];
+            }
+            if (count($part) > 0) {
+                array_push($part, $splitWord);
+                $newPart = ltrim(array_reduce($part, "myfunction"), "+");
+                echo $newPart;
+            }
+        }
 
-		break;	
-}
+        echo "<div id='dictlist'>";
+        foreach ($dict_list_a as $x_value) {
+            if (substr($x_value[0], 0, 4) == "word") {
+                echo "<div style='font-size:120%;font-weight:700;margin-top:15px;'>";
+                echo "<a href='#{$x_value[0]}'>$x_value[1]</a></div>";
+            } else {
+                echo "<div><a href='#{$x_value[0]}'>$x_value[1]</a></div>";
+            }
+        }
+        echo "<div>";
+
+        $arrWords = countWordInPali($word, true);
+        $weight = 0;
+        foreach ($arrWords as $oneword) {
+            $weight += $oneword["count"] * $oneword["len"];
+        }
+        //echo "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
+        //echo "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
+        $right_word_list .= "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
+        $right_word_list .= "<div>{$_local->gui->real_declension}:" . count($arrWords) . " {$_local->gui->forms}</div>";
+        foreach ($arrWords as $oneword) {
+            if ($oneword["bold"] > 0) {
+                //echo "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
+                $right_word_list .= "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
+            } else {
+                //echo "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
+                $right_word_list .= "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
+            }
+        }
+        echo "</div>";
+        echo "</div>";
+        echo "</div>";
+        //参考字典查询结束
 
+        //用户词典编辑窗口
+        echo "<div id='dict_user' >";
+        echo "<div><a href='word_statistics.php?word={$word}'>";
+        echo "<svg t='1596783175334' class='icon' style='font-size: xxx-large; fill: var(--link-hover-color); margin: 5px;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='7755' width='200' height='200'><path d='M1019.904 450.56L536.576 557.056l417.792 208.896C999.424 692.224 1024 606.208 1024 512c0-20.48 0-40.96-4.096-61.44z m-12.288-61.44C958.464 184.32 786.432 28.672 573.44 4.096L446.464 512l561.152-122.88zM737.28 970.752c73.728-36.864 139.264-90.112 188.416-159.744L507.904 602.112l229.376 368.64zM512 0C229.376 0 0 229.376 0 512s229.376 512 512 512c61.44 0 118.784-12.288 172.032-28.672L385.024 512 512 0z' p-id='7756'></path></svg>";
+        echo "<br>{$_local->gui->click_to_chart}</a></div>";
+        echo $right_word_list;
+        echo "<div class='dict_word' ><b>{$_local->gui->undone_function}</b>";
+        echo "<div class='' onclick=\"dict_show_edit()\">{$_local->gui->edit}</div>";
+        echo "<div class='pali'>{$word}</div>";
 
-?>
+        if ($iFetch > 0) {
+            echo "<div id='user_word_edit' style='display:none'>";
+        } else {
+            echo "<div id='user_word_edit'>";
+        }
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
+        echo "<select id=\"id_type\" name=\"type\" >";
+        foreach ($_local->type_str as $type) {
+            echo "<option value=\"{$type->id}\" >{$type->value}</option>";
+        }
+        echo "</select>";
+        echo "</fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea></textarea></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' value=''/></fieldset>";
+        echo "<div class=''><button>{$_local->gui->add_to} {$_local->gui->my_dictionary}</button></div>";
+        echo "</div>";
+        echo "</div>";
+        echo "</div>";
+        //查用户词典结束
+
+        break;
+}

+ 1 - 1
app/dict/turbo_split.php

@@ -6,7 +6,7 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 // open word part db
 global $dbh;
-$dns = "sqlite:" . _FILE_DB_PART_;
+$dns = "" . _FILE_DB_PART_;
 $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 

+ 1 - 1
app/dict_builder/dict_find3.php

@@ -14,7 +14,7 @@ $dict_list=array();
 
 global $PDO;
 $dictFileName=_FILE_DB_REF_;
-PDO_Connect("sqlite:$dictFileName");
+PDO_Connect("$dictFileName");
 
 function isExsit($word){
 global $PDO;

+ 2 - 2
app/dict_builder/get_one_word.php

@@ -11,12 +11,12 @@ include "../public/_pdo.php";
 		}
 						
 		$dictFileName=_FILE_DB_REF_;
-		PDO_Connect("sqlite:$dictFileName");
+		PDO_Connect("$dictFileName");
 		$query = "SELECT * from dict where id = ? ";
 		$Fetch = PDO_FetchAll($query,array($word_id));
 		
 		$dictFileName=$dir_dict_3rd."all.db3";
-		PDO_Connect("sqlite:$dictFileName");
+		PDO_Connect("$dictFileName");
 		
 		foreach($Fetch as $word){
 			echo "<h3>".$word["paliword"]."</h3>";

+ 1 - 1
app/dict_builder/index - 副本.php

@@ -80,7 +80,7 @@ include "./_pdo.php";
 
 global $PDO;
 $dictFileName=$dir_dict_3rd."bhmf.db";
-PDO_Connect("sqlite:$dictFileName");
+PDO_Connect("$dictFileName");
 		$query = "SELECT * from dict where 1  limit 0,1000";
 		$Fetch = PDO_FetchAll($query);
 		$iFetch=count($Fetch);

+ 88 - 94
app/dict_builder/index.php

@@ -3,23 +3,20 @@ include "../path.php";
 include "../public/_pdo.php";
 global $PDO;
 
-if(isset($_GET['dict_id'])){
-	$dict_id=$_GET['dict_id'];
+if (isset($_GET['dict_id'])) {
+    $dict_id = $_GET['dict_id'];
+} else {
+    $dict_id = -1;
 }
-else{
-	$dict_id=-1;
+if (isset($_GET['page_no'])) {
+    $page_no = $_GET['page_no'];
+} else {
+    $page_no = 0;
 }
-if(isset($_GET['page_no'])){
-	$page_no=$_GET['page_no'];
-}
-else{
-	$page_no=0;
-}
-if(isset($_GET['page_size'])){
-	$page_size=$_GET['page_size'];
-}
-else{
-	$page_size=20;
+if (isset($_GET['page_size'])) {
+    $page_size = $_GET['page_size'];
+} else {
+    $page_size = 20;
 }
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -74,7 +71,7 @@ else{
 	.active{
 		border-top: 1px solid #9797ff;
 		border-bottom: 1px solid #9797ff;
-	}	
+	}
 
 	.status_2{
 		background-color:#d6d6d6;
@@ -107,7 +104,7 @@ else{
 		th {
 			border: 1px solid #D2D2D2;
 			vertical-align: baseline;
-			
+
 		}
 		tr.h {
 			background-color: #F5F5F5;
@@ -121,7 +118,7 @@ else{
 		margin: 5px;
 			display:none;
 		}
-		
+
 		#message_button{
 			text-align: center;
 		}
@@ -147,37 +144,34 @@ else{
 					<div>
 						<select onchange="dict_changed(this)">
 						<?php
-						
 
-		$dictFileName=_FILE_DB_REF_;
-		PDO_Connect("sqlite:$dictFileName");
-		$query = "SELECT * from info where 1  limit 0,100";
-		$Fetch = PDO_FetchAll($query);
-		$iFetch=count($Fetch);
-		if($iFetch>0){
-			if($dict_id==-1){
-				echo "<option value=\"-1\" selected >选择一本字典</option>";
-			}
-			for($i=0;$i<$iFetch;$i++){
-				if($Fetch[$i]["id"]==$dict_id){
-					$selected="selected";
-				}
-				else{
-					$selected="";
-				}
-				echo "selected : $selected<br>";
-				echo "<option value=\"".$Fetch[$i]["id"]."\" $selected >".$Fetch[$i]["shortname"]."</option>";
-			}
-		}
-		if($dict_id!=-1){
-			$query = "SELECT count(*) from dict where dict_id = ? ";
-			$dict_count = PDO_FetchOne($query,array($dict_id));
-			$totle_page=ceil($dict_count/$page_size);
-		}
-		else{
-			$totle_page=0;
-		}
-						?>
+$dictFileName = _FILE_DB_REF_;
+PDO_Connect("$dictFileName");
+$query = "SELECT * from info where 1  limit 0,100";
+$Fetch = PDO_FetchAll($query);
+$iFetch = count($Fetch);
+if ($iFetch > 0) {
+    if ($dict_id == -1) {
+        echo "<option value=\"-1\" selected >选择一本字典</option>";
+    }
+    for ($i = 0; $i < $iFetch; $i++) {
+        if ($Fetch[$i]["id"] == $dict_id) {
+            $selected = "selected";
+        } else {
+            $selected = "";
+        }
+        echo "selected : $selected<br>";
+        echo "<option value=\"" . $Fetch[$i]["id"] . "\" $selected >" . $Fetch[$i]["shortname"] . "</option>";
+    }
+}
+if ($dict_id != -1) {
+    $query = "SELECT count(*) from dict where dict_id = ? ";
+    $dict_count = PDO_FetchOne($query, array($dict_id));
+    $totle_page = ceil($dict_count / $page_size);
+} else {
+    $totle_page = 0;
+}
+?>
 						</select>
 					</div>
 					<div id="dict_ref_search_input_div">
@@ -187,23 +181,23 @@ else{
 						<div><span id="input_parts"><span></span></span></div>
 					</div>
 					<div id="dict_word_nav">
-					<a 
+					<a
 					<?php
-						if($page_no>0){
-							$prev_page = $page_no-1;
-							echo "href='index.php?dict_id=$dict_id&page_no=$prev_page&page_size=$page_size'";
-						}
-					?>
-					>上一页</a> 
+if ($page_no > 0) {
+    $prev_page = $page_no - 1;
+    echo "href='index.php?dict_id=$dict_id&page_no=$prev_page&page_size=$page_size'";
+}
+?>
+					>上一页</a>
 					<input type="input" value="<?php echo $page_no; ?>" onchange="goto_page(this,<?php echo $dict_id; ?>,<?php echo $totle_page; ?>)" style="width:4em;" />/
-					<span><?php echo $totle_page-1; ?></span>
-					<a 
+					<span><?php echo $totle_page - 1; ?></span>
+					<a
 					<?php
-						if($page_no<$totle_page){
-							$next_page=$page_no+1;
-							echo "href='index.php?dict_id=$dict_id&page_no=$next_page&page_size=$page_size'";
-						}
-					?>
+if ($page_no < $totle_page) {
+    $next_page = $page_no + 1;
+    echo "href='index.php?dict_id=$dict_id&page_no=$next_page&page_size=$page_size'";
+}
+?>
 
 					>下一页</a>
 					</div>
@@ -212,39 +206,39 @@ else{
 					<div id="dict_ref_search">
 						<div id="dict_ref_search_result">
 						<?php
-						if($dict_id!=-1){
-							$from=$page_no*$page_size;
-							$query = "SELECT id, paliword,status from dict where dict_id = ? limit ? , ? ";
-							$Fetch = PDO_FetchAll($query,array($dict_id,$from,$page_size));
-							foreach($Fetch as $word){
-								$class_status="status_".$word["status"];
-								$str_status="";
-								switch($word["status"]){
-									case 1:
-										$str_status="";
-									break;
-									case 2:
-										$str_status="[草]";
-									break;
-									case 3:
-										$str_status="[标]";
-									break;	
-									case 10:
-										$str_status="";
-									break;
-								}
+if ($dict_id != -1) {
+    $from = $page_no * $page_size;
+    $query = "SELECT id, paliword,status from dict where dict_id = ? limit ? , ? ";
+    $Fetch = PDO_FetchAll($query, array($dict_id, $from, $page_size));
+    foreach ($Fetch as $word) {
+        $class_status = "status_" . $word["status"];
+        $str_status = "";
+        switch ($word["status"]) {
+            case 1:
+                $str_status = "";
+                break;
+            case 2:
+                $str_status = "[草]";
+                break;
+            case 3:
+                $str_status = "[标]";
+                break;
+            case 10:
+                $str_status = "";
+                break;
+        }
 
-								echo  "<div id='word_".$word["id"]."' class='ref_word $class_status' onclick='res_word_selected(this,".$word["id"].")'>$str_status<span class='pali_word' >".$word["paliword"]."</div>";
-							}
+        echo "<div id='word_" . $word["id"] . "' class='ref_word $class_status' onclick='res_word_selected(this," . $word["id"] . ")'>$str_status<span class='pali_word' >" . $word["paliword"] . "</div>";
+    }
 
-						}						
-						?>
+}
+?>
 						</div>
 					</div>
 				</div>
 			</div>
 
-		
+
 		<div id="build-dict">
 			<div id="message">
 				<div id="message_text"></div>
@@ -263,10 +257,10 @@ else{
 				<textarea id="org_edit_text" onkeyup="org_edit_changed()" onchange="org_edit_changed()"></textarea>
 			</div>
 			<div id="word_table">
-			
-			</div>	
+
+			</div>
 		</div>
-		
+
 		<div id="right-bar">
 		<div id="right-bar-header">
 		</div>
@@ -282,14 +276,14 @@ else{
 		<button onclick="save_replace_table()">保存</button>
 		</div>
 		<textarea id="replace_table_main" class="replace_table" ></textarea>
-		<textarea id="replace_table_pali" class="replace_table" style="display:none;"></textarea>		
+		<textarea id="replace_table_pali" class="replace_table" style="display:none;"></textarea>
 		<textarea id="replace_table_type" class="replace_table" style="display:none;"></textarea>
 		<textarea id="replace_table_part" class="replace_table" style="display:none;"></textarea>
 
 		</div>
-				
+
 		</div>
 	</div>
-	
+
 </body>
 </html>

+ 61 - 72
app/dict_builder/save.php

@@ -2,86 +2,75 @@
 include "../path.php";
 include "../public/_pdo.php";
 
-if(isset($_POST['dict_id'])){
-	$dict_id=$_POST['dict_id'];
+if (isset($_POST['dict_id'])) {
+    $dict_id = $_POST['dict_id'];
+} else {
+    $dict_id = -1;
 }
-else{
-	$dict_id=-1;
+if (isset($_POST['word_id'])) {
+    $word_id = $_POST['word_id'];
+} else {
+    $word_id = -1;
 }
-if(isset($_POST['word_id'])){
-	$word_id=$_POST['word_id'];
+if (isset($_POST['data'])) {
+    $data = $_POST['data'];
+} else {
+    $data = "";
 }
-else{
-	$word_id=-1;
-}
-if(isset($_POST['data'])){
-	$data=$_POST['data'];
-}
-else{
-	$data="";
-}
-if(isset($_POST['word_status'])){
-	$status=$_POST['word_status'];
-}
-else{
-	$status="1";
+if (isset($_POST['word_status'])) {
+    $status = $_POST['word_status'];
+} else {
+    $status = "1";
 }
 
-		$dictFileName=_FILE_DB_REF_;
-		PDO_Connect("sqlite:$dictFileName");
-		$query = "update dict set status='$status' where id='$word_id'";
-		$stmt = @PDO_Execute($query);
-		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-			$error = PDO_ErrorInfo();
-			print_r($error[2]);
-		}
-				
+$dictFileName = _FILE_DB_REF_;
+PDO_Connect("$dictFileName");
+$query = "update dict set status='$status' where id='$word_id'";
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+}
 
+$dictFileName = $dir_dict_3rd . "all.db3";
+PDO_Connect("$dictFileName");
 
+$query = "DELETE FROM dict WHERE \"from\" = '$word_id' ";
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+} else {
 
-		$dictFileName=$dir_dict_3rd."all.db3";
-		PDO_Connect("sqlite:$dictFileName");
-		
-		$query = "DELETE FROM dict WHERE \"from\" = '$word_id' ";
-		$stmt = @PDO_Execute($query);
-		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-			$error = PDO_ErrorInfo();
-			print_r($error[2]);
-		}
-		else{
-		
-		}
-		$word_data=json_decode($data);	
-		//print_r($word_data);
-		//echo "pali:".$word_data[0]->pali."<br>";
-	// 开始一个事务,关闭自动提交
-	$PDO->beginTransaction();
-	$query="INSERT INTO dict ('id','pali','type','gramma','parent','mean','note','factors','factormean','dict_id','from') 
+}
+$word_data = json_decode($data);
+//print_r($word_data);
+//echo "pali:".$word_data[0]->pali."<br>";
+// 开始一个事务,关闭自动提交
+$PDO->beginTransaction();
+$query = "INSERT INTO dict ('id','pali','type','gramma','parent','mean','note','factors','factormean','dict_id','from')
 	        VALUES (NULL,?,?,?,?,?,?,?,?,?,?)";
-	$stmt = $PDO->prepare($query);
-
-	foreach($word_data as $value){
-		$newData=array($value->pali,
-					   $value->type,
-					   $value->gramma,
-					   $value->parent,
-					   $value->mean,
-					   $value->note,
-					   $value->factor,
-					   $value->factor_mean,
-					   $dict_id,
-					   $word_id);
-		$stmt->execute($newData);
-	}
+$stmt = $PDO->prepare($query);
 
-	// 提交更改 
-	$PDO->commit();
-	if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-		$error = PDO_ErrorInfo();
-		echo "error - $error[2] <br>";
-	}
-	else{
-		echo "成功提交".count($word_data)."条数据。";
-	}
+foreach ($word_data as $value) {
+    $newData = array($value->pali,
+        $value->type,
+        $value->gramma,
+        $value->parent,
+        $value->mean,
+        $value->note,
+        $value->factor,
+        $value->factor_mean,
+        $dict_id,
+        $word_id);
+    $stmt->execute($newData);
+}
 
-?>
+// 提交更改
+$PDO->commit();
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+} else {
+    echo "成功提交" . count($word_data) . "条数据。";
+}

+ 137 - 145
app/doc/coop.php

@@ -2,7 +2,7 @@
 	#coop_selector_title{
 		margin-top: 15px;
 		padding-top: 10px;
-		border-top: 1px solid var(--border-line-color);		
+		border-top: 1px solid var(--border-line-color);
 	}
 	#coop_u_list li{
 		display:flex;
@@ -11,156 +11,151 @@
 	</style>
 <?php
 /*
-*
+ *
 list (doc_id)
 add (doc_id ,userid)
 del (doc_id, userid)
 set (doc_id ,userid ,value)
-*
-*/
-    require_once "../path.php";
-    require_once "../public/_pdo.php";
-    require_once "../public/function.php";
-    require_once "../public/load_lang.php";
-    require_once "../ucenter/function.php";
-    require_once "../group/function.php";
+ *
+ */
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+require_once "../public/load_lang.php";
+require_once "../ucenter/function.php";
+require_once "../group/function.php";
 
+$userid = "";
+$isLogin = false;
+if ($_COOKIE["userid"]) {
+    $userid = $_COOKIE["userid"];
+    $isLogin = true;
+}
+if ($_GET["do"]) {
+    $_do = $_GET["do"];
+} else {
+    echo "Error:缺乏必要的参数 do";
+    exit;
+}
+if ($_GET["doc_id"]) {
+    $_doc_id = $_GET["doc_id"];
+} else {
+    echo "Error:缺乏必要的参数 doc_id";
+    exit;
+}
 
-    
-    $userid="";
-    $isLogin=false;
-    if($_COOKIE["userid"]){
-        $userid=$_COOKIE["userid"];
-        $isLogin = true;
-    }
-    if($_GET["do"]){
-        $_do=$_GET["do"];
-    }
-    else{
-        echo "Error:缺乏必要的参数 do";
-        exit;
-    }
-    if($_GET["doc_id"]){
-        $_doc_id=$_GET["doc_id"];
-    }
-    else{
-        echo "Error:缺乏必要的参数 doc_id";
-        exit;
-    } 
-
-    $powerlist["10"] = "仅阅读";
-    //$powerlist["20"] = "建议";
-    $powerlist["30"] = "可修改";
-    //$powerlist["40"] = "管理员";
+$powerlist["10"] = "仅阅读";
+//$powerlist["20"] = "建议";
+$powerlist["30"] = "可修改";
+//$powerlist["40"] = "管理员";
 
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+PDO_Connect("" . _FILE_DB_FILEINDEX_);
 
-        echo "<input id='doc_coop_docid' type='hidden' value='{$_doc_id}' />";
-        $query = "SELECT * from fileindex where id = ? ";
-        $Fetch = PDO_FetchAll($query,array($_doc_id));
-        $iFetch=count($Fetch);
-        if($iFetch>0){
+echo "<input id='doc_coop_docid' type='hidden' value='{$_doc_id}' />";
+$query = "SELECT * from fileindex where id = ? ";
+$Fetch = PDO_FetchAll($query, array($_doc_id));
+$iFetch = count($Fetch);
+if ($iFetch > 0) {
 
-            $owner = $Fetch[0]["user_id"];
-            $uid = $_COOKIE["uid"];
-            if($owner==$uid){
-                //自己的文档
-                switch($_do){
-                    case "list":
-                    break;
-                    case "add":
-                        $query="INSERT INTO power ('id','doc_id','user','power','status','create_time','modify_time','receive_time','type') 
+    $owner = $Fetch[0]["user_id"];
+    $uid = $_COOKIE["uid"];
+    if ($owner == $uid) {
+        //自己的文档
+        switch ($_do) {
+            case "list":
+                break;
+            case "add":
+                $query = "INSERT INTO power ('id','doc_id','user','power','status','create_time','modify_time','receive_time','type')
                         VALUES (?,?,?,?,?,?,?,?,?)";
-                        $stmt = $PDO->prepare($query);
-                        $stmt->execute( 
-                            array(UUID::v4(),
-                            $_GET["doc_id"],
-                            $_GET["user_id"],
-                            10,
-                            1,
-                            mTime(),
-                            mTime(),
-							mTime(),
-                            $_GET["type"]
-							)
-                        );
-                        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-                            $error = PDO_ErrorInfo();
-                            echo "error - $error[2] <br>";
-                        }
-                    break;
-                    case "del":
-                        $query="DELETE FROM power WHERE doc_id = ? AND user = ? ";
-                        $stmt = $PDO->prepare($query);
-                        $stmt->execute( 
-                            array($_GET["doc_id"],
-                            $_GET["user_id"])
-                        );
-                        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-                            $error = PDO_ErrorInfo();
-                            echo "error - $error[2] <br>";
-                        }
-                    break;
-                    case "set":
-                        $query="UPDATE power SET power = ? , modify_time = ? WHERE doc_id = ? AND user = ? ";
-                        $stmt = $PDO->prepare($query);
-                        $stmt->execute( 
-                            array($_GET["value"],
-                            mTime(),
-                            $_GET["doc_id"],
-                            $_GET["user_id"])
-                        );
-                        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-                            $error = PDO_ErrorInfo();
-                            echo "error - $error[2] <br>";
-                        }
-                    break;
-
+                $stmt = $PDO->prepare($query);
+                $stmt->execute(
+                    array(UUID::v4(),
+                        $_GET["doc_id"],
+                        $_GET["user_id"],
+                        10,
+                        1,
+                        mTime(),
+                        mTime(),
+                        mTime(),
+                        $_GET["type"],
+                    )
+                );
+                if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                    $error = PDO_ErrorInfo();
+                    echo "error - $error[2] <br>";
                 }
-                
-                $query = "SELECT * from power where doc_id = ? ";
-                $Fetch = PDO_FetchAll($query,array($_doc_id));
+                break;
+            case "del":
+                $query = "DELETE FROM power WHERE doc_id = ? AND user = ? ";
+                $stmt = $PDO->prepare($query);
+                $stmt->execute(
+                    array($_GET["doc_id"],
+                        $_GET["user_id"])
+                );
+                if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                    $error = PDO_ErrorInfo();
+                    echo "error - $error[2] <br>";
+                }
+                break;
+            case "set":
+                $query = "UPDATE power SET power = ? , modify_time = ? WHERE doc_id = ? AND user = ? ";
+                $stmt = $PDO->prepare($query);
+                $stmt->execute(
+                    array($_GET["value"],
+                        mTime(),
+                        $_GET["doc_id"],
+                        $_GET["user_id"])
+                );
+                if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                    $error = PDO_ErrorInfo();
+                    echo "error - $error[2] <br>";
+                }
+                break;
+
+        }
+
+        $query = "SELECT * from power where doc_id = ? ";
+        $Fetch = PDO_FetchAll($query, array($_doc_id));
 
-                echo "<ul id='coop_u_list'>";
-                foreach($Fetch as $row){
-					echo "<li>";
-					echo "<span>";
-					if($row["type"]==0){
-						//个人
-						echo "<svg class='icon' style='margin: 0 5px;'>";
-						echo '<use xlink:href="./svg/icon.svg#ic_person"></use>';
-						echo "</svg>";
-						echo ucenter_getA($row["user"],"username");
-					}
-					else if($row["type"]==1){
-						//群组
-						echo "<svg class='icon' style='margin: 0 5px;'>";
-						echo '<use xlink:href="./svg/icon.svg#ic_two_person"></use>';
-						echo "</svg>";
-						echo group_get_name($row["user"]);
-					}
-					echo "</span>";
-					echo "<span>";
-					
-                    echo "<select onchange=\"coop_power_change('{$row["user"]}',this)\">";
-                    foreach($powerlist as $key=>$value){
-                        echo "<option value='{$key}' ";
-                        if($row["power"]==$key){
-                            echo "selected";
-                        }
-                        echo ">{$value}</option>";
-                    }
-                    echo "</select>";
-					echo "<button onclick=\"coop_del('{$row["user"]}')\">".$_local->gui->delete."</button>";
-					echo "</span>";
-					
-                    echo "</li>";
+        echo "<ul id='coop_u_list'>";
+        foreach ($Fetch as $row) {
+            echo "<li>";
+            echo "<span>";
+            if ($row["type"] == 0) {
+                //个人
+                echo "<svg class='icon' style='margin: 0 5px;'>";
+                echo '<use xlink:href="./svg/icon.svg#ic_person"></use>';
+                echo "</svg>";
+                echo ucenter_getA($row["user"], "username");
+            } else if ($row["type"] == 1) {
+                //群组
+                echo "<svg class='icon' style='margin: 0 5px;'>";
+                echo '<use xlink:href="./svg/icon.svg#ic_two_person"></use>';
+                echo "</svg>";
+                echo group_get_name($row["user"]);
+            }
+            echo "</span>";
+            echo "<span>";
+
+            echo "<select onchange=\"coop_power_change('{$row["user"]}',this)\">";
+            foreach ($powerlist as $key => $value) {
+                echo "<option value='{$key}' ";
+                if ($row["power"] == $key) {
+                    echo "selected";
                 }
-                echo "</ul>";
-                ?>
+                echo ">{$value}</option>";
+            }
+            echo "</select>";
+            echo "<button onclick=\"coop_del('{$row["user"]}')\">" . $_local->gui->delete . "</button>";
+            echo "</span>";
+
+            echo "</li>";
+        }
+        echo "</ul>";
+        ?>
 				<div id="coop_selector_title">
-                <?php echo $_local->gui->add." ".$_local->gui->cooperators; ?>
-				<input type="radio" id="cooperator_type_user" name="cooperator_type" checked><?php echo $_local->gui->person; ?> 
+                <?php echo $_local->gui->add . " " . $_local->gui->cooperators; ?>
+				<input type="radio" id="cooperator_type_user" name="cooperator_type" checked><?php echo $_local->gui->person; ?>
 				<input type="radio" id="cooperator_type_group" name="cooperator_type"><?php echo $_local->gui->group; ?>
 				</div>
                 <div id="wiki_search" style="width:100%;">
@@ -169,14 +164,11 @@ set (doc_id ,userid ,value)
                     </div>
 			    </div>
                 <?php
-            }
-            else{
-                 //别人的的文档
-                 echo "<a href='fork.php?doc_id={$doc_id}'>[复刻]</a>";
-                
-            }
-        }
-
+} else {
+        //别人的的文档
+        echo "<a href='fork.php?doc_id={$doc_id}'>[复刻]</a>";
 
+    }
+}
 
 ?>

+ 1 - 1
app/doc/coopfilelist.php

@@ -15,7 +15,7 @@ else{
 	exit;
 }
 
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+    PDO_Connect(""._FILE_DB_FILEINDEX_);
     $query = "SELECT * from power where user = ? order by modify_time DESC";
     $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
     $result=array();

+ 40 - 45
app/doc/docinfo.php

@@ -1,52 +1,47 @@
 <?php
 /*
-*
-*
-*/
-    require_once "../path.php";
-    require_once "../public/_pdo.php";
-    require_once "../public/function.php";
-    require_once "../ucenter/function.php";
+ *
+ *
+ */
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+require_once "../ucenter/function.php";
 
-    $userid="";
-    $isLogin=false;
-    if($_COOKIE["userid"]){
-        $userid=$_COOKIE["userid"];
-        $isLogin = true;
-    }
+$userid = "";
+$isLogin = false;
+if ($_COOKIE["userid"]) {
+    $userid = $_COOKIE["userid"];
+    $isLogin = true;
+}
+
+PDO_Connect("" . _FILE_DB_FILEINDEX_);
+if (isset($_GET["id"])) {
 
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-    if(isset($_GET["id"])){
+    $doc_id = $_GET["id"];
+    $query = "SELECT * from fileindex where id = ? ";
+    $Fetch = PDO_FetchAll($query, array($doc_id));
+    $iFetch = count($Fetch);
+    if ($iFetch > 0) {
+        //文档信息
+        echo "<h2>";
+        echo "<a href='../ucenter/info.php?id={$Fetch[0]["user_id"]}'>" . ucenter_get($Fetch[0]["user_id"], "") . "</a>/";
+        echo "<a>{$Fetch[0]["title"]}</a>";
+        echo "</h2>";
+        echo "<div>" . _get_para_path($Fetch[0]["book"], $Fetch[0]["paragraph"]) . "</div>";
+        echo "<div>标签:</div>";
+        echo "<div>创建时间:{$Fetch[0]["create_time"]} / 更新时间:{$Fetch[0]["modify_time"]}</div>";
+        echo "<h3>简介</h3>";
+        echo "<a href='../pcdl/reader.php'>[阅读]</a>";
+        if ($owner == $uid) {
+            //自己的文档
+            echo "<a href='coop.php?id={$doc_id}'>[协作管理]</a>";
+        } else {
+            //别人的的文档
+            echo "<a href='fork.php?doc_id={$doc_id}'>[复刻]</a>";
 
-        $doc_id=$_GET["id"];
-        $query = "SELECT * from fileindex where id = ? ";
-        $Fetch = PDO_FetchAll($query,array($doc_id));
-        $iFetch=count($Fetch);
-        if($iFetch>0){
-            //文档信息
-            echo "<h2>";
-            echo "<a href='../ucenter/info.php?id={$Fetch[0]["user_id"]}'>".ucenter_get($Fetch[0]["user_id"],"")."</a>/";
-            echo "<a>{$Fetch[0]["title"]}</a>";
-            echo "</h2>";
-            echo "<div>"._get_para_path($Fetch[0]["book"],$Fetch[0]["paragraph"])."</div>";
-            echo "<div>标签:</div>";
-            echo "<div>创建时间:{$Fetch[0]["create_time"]} / 更新时间:{$Fetch[0]["modify_time"]}</div>";
-            echo "<h3>简介</h3>";
-            echo "<a href='../pcdl/reader.php'>[阅读]</a>";
-            if($owner==$uid){
-                //自己的文档
-                 echo "<a href='coop.php?id={$doc_id}'>[协作管理]</a>";
-            }
-            else{
-                 //别人的的文档
-                 echo "<a href='fork.php?doc_id={$doc_id}'>[复刻]</a>";
-                
-            }
         }
     }
-    else{
-        echo "无效的文档编号";
-    }
-
-
-?>
+} else {
+    echo "无效的文档编号";
+}

+ 4 - 4
app/doc/edit_wbw.php

@@ -9,7 +9,7 @@ require_once "../public/load_lang.php";
 $_book = $_POST["book"];
 $_para = json_decode($_POST["para"]);
 //判断单词数量 太大的不能加载
-PDO_Connect("sqlite:"._FILE_DB_PALITEXT_);
+PDO_Connect(""._FILE_DB_PALITEXT_);
 $params = array(1, 21, 63, 171);
 /*  创建一个填充了和params相同数量占位符的字符串 */
 $place_holders = implode(',', array_fill(0, count($_para), '?'));
@@ -40,7 +40,7 @@ echo "</fieldset>";
 echo "<fieldset>";
 echo "<legend>{$_local->gui->channel} ({$_local->gui->required})</legend>";
 echo "<div>";
-PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+PDO_Connect(""._FILE_DB_CHANNAL_);
 $query = "SELECT * from channal where owner = ?   limit 0,100";
 $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
 $i=0;
@@ -58,7 +58,7 @@ foreach($Fetch as $row){
     echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
     // 查询逐词解析库
-    PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+    PDO_Connect(""._FILE_DB_USER_WBW_);
     $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
     $FetchWBW = PDO_FetchOne($query);
     echo '</div>';
@@ -74,7 +74,7 @@ foreach($Fetch as $row){
     echo '</div>';
 
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-    PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+    PDO_Connect(""._FILE_DB_SENTENCE_);
     $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
     $FetchWBW = PDO_FetchOne($query);
     echo '</div>';

+ 398 - 407
app/doc/fork.php

@@ -1,389 +1,382 @@
 <?php
 /*拷贝其他人的文件
-*
-*
-*/
+ *
+ *
+ */
 require_once '../studio/index_head.php';
 ?>
 <body id="file_list_body" >
 <?php
-    require_once "../public/_pdo.php";
-    require_once "../public/function.php";
-	require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+require_once "../path.php";
 
-	require_once '../studio/index_tool_bar.php';
+require_once '../studio/index_tool_bar.php';
 
-	echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
+echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
 
-    if($_COOKIE["uid"]){
-        $uid=$_COOKIE["uid"];
+if ($_COOKIE["uid"]) {
+    $uid = $_COOKIE["uid"];
+} else {
+    echo "尚未登录";
+    echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
+    exit;
+}
+if (isset($_GET["doc_id"]) == false) {
+    echo "没有 文档编号";
+    exit;
+}
+PDO_Connect("" . _FILE_DB_FILEINDEX_);
+$doc_id = $_GET["doc_id"];
+$query = "select * from fileindex where id= ? ";
+$Fetch = PDO_FetchAll($query, array($doc_id));
+$iFetch = count($Fetch);
+if ($iFetch > 0) {
+    //文档信息
+    $mbook = $Fetch[0]["book"];
+    $paragraph = $Fetch[0]["paragraph"];
+}
+
+if (isset($_GET["channel"]) == false) {
+    echo '<div class="file_list_block">';
+    echo "<h2>选择一个空白的版风存储新的文档</h2>";
+    echo "<form action='fork.php' method='get'>";
+    echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+    PDO_Connect("" . _FILE_DB_CHANNAL_);
+    $query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+    $Fetch = PDO_FetchAll($query);
+    $i = 0;
+    foreach ($Fetch as $row) {
+        echo '<div class="file_list_row" style="padding:5px;display:flex;">';
+
+        echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+        echo '<input name="channel" value="' . $row["id"] . '" ';
+        if ($i == 0) {
+            echo "checked";
+        }
+        echo ' type="radio" />';
+        echo '</div>';
+        echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
+        echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        PDO_Connect("" . _FILE_DB_USER_WBW_);
+        $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $FetchWBW = PDO_FetchOne($query);
+        echo '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        if ($FetchWBW == 0) {
+            echo $_local->gui->blank;
+        } else {
+            echo $FetchWBW . $_local->gui->para;
+            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+        }
+        echo '</div>';
+
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        PDO_Connect("" . _FILE_DB_SENTENCE_);
+        $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $FetchWBW = PDO_FetchOne($query);
+        echo '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        if ($FetchWBW == 0) {
+            echo $_local->gui->blank;
+        } else {
+            echo $FetchWBW . $_local->gui->para;
+        }
+        echo '</div>';
+
+        echo '<div class="summary"  style="flex:1;padding-bottom:5px;">' . $row["status"] . '</div>';
+        echo '<div class="author"  style="flex:1;padding-bottom:5px;">' . $row["create_time"] . '</div>';
+
+        echo '</div>';
+        $i++;
     }
-    else{
-        echo "尚未登录";
-        echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
-        exit;
-	}
-	if(isset($_GET["doc_id"])==false){
-		echo "没有 文档编号";
-		exit;
-	}
-	PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-	$doc_id=$_GET["doc_id"];
-	$query = "select * from fileindex where id= ? ";
-	$Fetch = PDO_FetchAll($query,array($doc_id));
-	$iFetch=count($Fetch);
-	if($iFetch>0){
-		//文档信息
-		$mbook=$Fetch[0]["book"];
-		$paragraph=$Fetch[0]["paragraph"];
-	}
-
-	if(isset($_GET["channel"])==false){
-		echo '<div class="file_list_block">';
-		echo "<h2>选择一个空白的版风存储新的文档</h2>";
-		echo "<form action='fork.php' method='get'>";
-		echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
-		PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
-		$query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
-		$Fetch = PDO_FetchAll($query);
-		$i=0;
-		foreach($Fetch as $row){
-			echo '<div class="file_list_row" style="padding:5px;display:flex;">';
-		
-			echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-			echo '<input name="channel" value="'.$row["id"].'" ';
-			if($i==0){
-				echo "checked";
-			}
-			echo ' type="radio" />';
-			echo '</div>';
-			echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["name"].'</div>';
-			echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
-			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-			PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
-			$query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-			$FetchWBW = PDO_FetchOne($query);
-			echo '</div>';
-			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-			if($FetchWBW==0){
-				echo $_local->gui->blank;
-			}
-			else{
-				echo $FetchWBW.$_local->gui->para;
-				echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
-			}
-			echo '</div>';
-
-			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-			PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
-			$query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-			$FetchWBW = PDO_FetchOne($query);
-			echo '</div>';
-			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-			if($FetchWBW==0){
-				echo $_local->gui->blank;
-			}
-			else{
-				echo $FetchWBW.$_local->gui->para;
-			}
-			echo '</div>';
-
-			echo '<div class="summary"  style="flex:1;padding-bottom:5px;">'.$row["status"].'</div>';
-			echo '<div class="author"  style="flex:1;padding-bottom:5px;">'.$row["create_time"].'</div>';
-			
-			echo '</div>';
-			$i++;
-		}
-		echo "<input type='submit' />";
-		echo "</form>";
-		echo "</div>";
-		exit;
-	}
-    
-	//if(isset($_GET["doc_id"]))
-	{
-		PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-		$doc_id=$_GET["doc_id"];
-		$query = "select * from fileindex where id= ? ";
-		$Fetch = PDO_FetchAll($query,array($doc_id));
-		$iFetch=count($Fetch);
-        if($iFetch>0){
-            //文档信息
-            $orgFileInfo = $Fetch[0];
-            $owner=$Fetch[0]["user_id"];
-            $filename=$Fetch[0]["file_name"];
-            $title=$Fetch[0]["title"];
-            $tag=$Fetch[0]["tag"];
-            $mbook=$Fetch[0]["book"];
-            $paragraph=$Fetch[0]["paragraph"];
-            
-            if($owner==$uid){
-                //自己的文档
-                echo "这是自己的文档,不能复刻。";
-            }
-            else{
-                //别人的文档
-                //查询自己是否以前打开过
-                $query = "select * from fileindex where parent_id='{$doc_id}' and user_id='{$uid}' ";
-                $FetchSelf = PDO_FetchAll($query);
-                $iFetchSelf=count($FetchSelf);
-                if($iFetchSelf>0){
-                    //以前打开过
-                    echo "文档已经复刻";
-                    echo "正在<a href='../studio/editor.php?op=opendb&doc_id={$doc_id}'>打开</a>文档";
-                    echo "<script>";
-                    echo "window.location.assign(\"../studio/editor.php?op=opendb&doc_id={$doc_id}\");";
-                    echo "</script>";
-                }
-                else{
-                    //以前没打开过
-                    echo "<h3>共享的文档,正在fork...</h3>";
-                    echo "<div style='display:none;'>";
-                    //获取文件路径
-                    
-                    PDO_Connect("sqlite:"._FILE_DB_USERINFO_);
-                    $query = "select userid from user where id='{$owner}'";
-                    $FetchUid = PDO_FetchOne($query);
-                    if($FetchUid){
-                        //$source=$dir_user_base.$FetchUid.$dir_mydocument.$filename;
-                        //$dest=$dir_user_base.$userid.$dir_mydocument.$filename;
-                        //复制数据
-                        //打开逐词解析数据库
-                        $dns = "sqlite:"._FILE_DB_USER_WBW_;
-                        $dbhWBW = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-                        $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
-
-                        //打开译文数据库
-                        $dns = "sqlite:"._FILE_DB_SENTENCE_;
-                        $dbhSent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-                        $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 
-
-                        //逐词解析新数据数组
-                        $arrNewBlock = array();
-                        $arrNewBlockData = array();
-                        $arrBlockTransform = array();
-                        
-                        //译文新数据数组
-                        $arrSentNewBlock = array();
-                        $arrSentNewBlockData = array();
-                        $arrSentBlockTransform = array(); 
-
-                        $newDocBlockList=array();
-
-                        $blocks = json_decode($Fetch[0]["doc_block"]);
-                        for ($i=0;$i<count($blocks);$i++) {
-                            switch($blocks[$i]->type){
-                                case 1:
+    echo "<input type='submit' />";
+    echo "</form>";
+    echo "</div>";
+    exit;
+}
+
+//if(isset($_GET["doc_id"]))
+{
+    PDO_Connect("" . _FILE_DB_FILEINDEX_);
+    $doc_id = $_GET["doc_id"];
+    $query = "select * from fileindex where id= ? ";
+    $Fetch = PDO_FetchAll($query, array($doc_id));
+    $iFetch = count($Fetch);
+    if ($iFetch > 0) {
+        //文档信息
+        $orgFileInfo = $Fetch[0];
+        $owner = $Fetch[0]["user_id"];
+        $filename = $Fetch[0]["file_name"];
+        $title = $Fetch[0]["title"];
+        $tag = $Fetch[0]["tag"];
+        $mbook = $Fetch[0]["book"];
+        $paragraph = $Fetch[0]["paragraph"];
+
+        if ($owner == $uid) {
+            //自己的文档
+            echo "这是自己的文档,不能复刻。";
+        } else {
+            //别人的文档
+            //查询自己是否以前打开过
+            $query = "select * from fileindex where parent_id='{$doc_id}' and user_id='{$uid}' ";
+            $FetchSelf = PDO_FetchAll($query);
+            $iFetchSelf = count($FetchSelf);
+            if ($iFetchSelf > 0) {
+                //以前打开过
+                echo "文档已经复刻";
+                echo "正在<a href='../studio/editor.php?op=opendb&doc_id={$doc_id}'>打开</a>文档";
+                echo "<script>";
+                echo "window.location.assign(\"../studio/editor.php?op=opendb&doc_id={$doc_id}\");";
+                echo "</script>";
+            } else {
+                //以前没打开过
+                echo "<h3>共享的文档,正在fork...</h3>";
+                echo "<div style='display:none;'>";
+                //获取文件路径
+
+                PDO_Connect("" . _FILE_DB_USERINFO_);
+                $query = "select userid from user where id='{$owner}'";
+                $FetchUid = PDO_FetchOne($query);
+                if ($FetchUid) {
+                    //$source=$dir_user_base.$FetchUid.$dir_mydocument.$filename;
+                    //$dest=$dir_user_base.$userid.$dir_mydocument.$filename;
+                    //复制数据
+                    //打开逐词解析数据库
+                    $dns = "" . _FILE_DB_USER_WBW_;
+                    $dbhWBW = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+                    $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+                    //打开译文数据库
+                    $dns = "" . _FILE_DB_SENTENCE_;
+                    $dbhSent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+                    $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+                    //逐词解析新数据数组
+                    $arrNewBlock = array();
+                    $arrNewBlockData = array();
+                    $arrBlockTransform = array();
+
+                    //译文新数据数组
+                    $arrSentNewBlock = array();
+                    $arrSentNewBlockData = array();
+                    $arrSentBlockTransform = array();
+
+                    $newDocBlockList = array();
+
+                    $blocks = json_decode($Fetch[0]["doc_block"]);
+                    for ($i = 0; $i < count($blocks); $i++) {
+                        switch ($blocks[$i]->type) {
+                            case 1:
                                 break;
-                                case 2:
-                                    //译文
-                                    $blockid = $blocks[$i]->block_id;
-                                    $query = "select * from sent_block where id= ? ";
-                                    $stmt = $dbhSent->prepare($query);
-                                    $stmt->execute(array($blockid));
-                                    $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
-									$newBlockId = UUID::V4();
-									//不复刻译文
-                                    //$newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
-                                    $arrSentBlockTransform[$fBlock[0]["id"]] = $newBlockId;
-                                    if(count($fBlock)>0){
-										array_push( $arrSentNewBlock,
-													array($newBlockId,
-                                                          $fBlock[0]["id"],
-                                                          $fBlock[0]["book"],
-                                                          $fBlock[0]["paragraph"],
-                                                          $_COOKIE["userid"],
-                                                          $fBlock[0]["lang"],
-                                                          $fBlock[0]["author"],
-                                                          $fBlock[0]["editor"],
-                                                          $fBlock[0]["tag"],
-                                                          $fBlock[0]["status"],
-                                                          mTime(),
-                                                          mTime()
-                                                        ));
-                                    }
-
-                                    $query = "select * from sentence where block_id= ? ";
-                                    $stmtSent = $dbhSent->prepare($query);
-                                    $stmtSent->execute(array($fBlock[0]["id"]));
-                                    $fBlockData = $stmtSent->fetchAll(PDO::FETCH_ASSOC);
-                                    foreach($fBlockData as $value){
-										array_push( $arrSentNewBlockData,
-													array(UUID::V4(),
-														$arrSentBlockTransform[$value["block_id"]],
-														$value["book"],
-														$value["paragraph"],
-														$value["begin"],
-														$value["end"],
-														$value["channal"],
-														$value["tag"],
-														$value["author"],
-														$_COOKIE["userid"],
-														$value["text"],
-														$value["language"],
-														$value["ver"],
-														$value["status"],
-														mTime(),
-														mTime()
-													));
-
-                                    }
-                                    
+                            case 2:
+                                //译文
+                                $blockid = $blocks[$i]->block_id;
+                                $query = "select * from sent_block where id= ? ";
+                                $stmt = $dbhSent->prepare($query);
+                                $stmt->execute(array($blockid));
+                                $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
+                                $newBlockId = UUID::V4();
+                                //不复刻译文
+                                //$newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
+                                $arrSentBlockTransform[$fBlock[0]["id"]] = $newBlockId;
+                                if (count($fBlock) > 0) {
+                                    array_push($arrSentNewBlock,
+                                        array($newBlockId,
+                                            $fBlock[0]["id"],
+                                            $fBlock[0]["book"],
+                                            $fBlock[0]["paragraph"],
+                                            $_COOKIE["userid"],
+                                            $fBlock[0]["lang"],
+                                            $fBlock[0]["author"],
+                                            $fBlock[0]["editor"],
+                                            $fBlock[0]["tag"],
+                                            $fBlock[0]["status"],
+                                            mTime(),
+                                            mTime(),
+                                        ));
+                                }
+
+                                $query = "select * from sentence where block_id= ? ";
+                                $stmtSent = $dbhSent->prepare($query);
+                                $stmtSent->execute(array($fBlock[0]["id"]));
+                                $fBlockData = $stmtSent->fetchAll(PDO::FETCH_ASSOC);
+                                foreach ($fBlockData as $value) {
+                                    array_push($arrSentNewBlockData,
+                                        array(UUID::V4(),
+                                            $arrSentBlockTransform[$value["block_id"]],
+                                            $value["book"],
+                                            $value["paragraph"],
+                                            $value["begin"],
+                                            $value["end"],
+                                            $value["channal"],
+                                            $value["tag"],
+                                            $value["author"],
+                                            $_COOKIE["userid"],
+                                            $value["text"],
+                                            $value["language"],
+                                            $value["ver"],
+                                            $value["status"],
+                                            mTime(),
+                                            mTime(),
+                                        ));
+
+                                }
+
                                 break;
-                                case 3:
+                            case 3:
                                 break;
-                                case 4:
+                            case 4:
                                 break;
-                                case 5:
+                            case 5:
                                 break;
-								case 6: 
-									#逐词解析
-                                    $blockid = $blocks[$i]->block_id;
-                                    $query = "select * from wbw_block where id= ? ";
-                                    $stmt = $dbhWBW->prepare($query);
-                                    $stmt->execute(array($blockid));
-                                    $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
-                                    $newBlockId = UUID::V4();
-                                    $newDocBlockList[]=array('type' => 6,'block_id' => $newBlockId);
-                                    $arrBlockTransform[$fBlock[0]["id"]] = $newBlockId;
-                                    if(count($fBlock)>0){
-										array_push( $arrNewBlock,
-													array($newBlockId,
-														$fBlock[0]["id"],
-														$_GET["channel"],
-														$_COOKIE["userid"],
-														$fBlock[0]["book"],
-														$fBlock[0]["paragraph"],
-														$fBlock[0]["style"],
-														$fBlock[0]["lang"],
-														$fBlock[0]["status"],
-														mTime(),
-														mTime()
-													));
-                                    }
-
-                                    $query = "select * from wbw where block_id= ? ";
-                                    $stmtWBW = $dbhWBW->prepare($query);
-                                    $stmtWBW->execute(array($fBlock[0]["id"]));
-                                    $fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
-                                    foreach($fBlockData as $value){
-										array_push( $arrNewBlockData,
-													array(UUID::V4(),
-														$arrBlockTransform[$value["block_id"]],
-														$value["book"],
-														$value["paragraph"],
-														$value["wid"],
-														$value["word"],
-														$value["data"],
-														mTime(),
-														mTime(),
-														$value["status"],
-														$_COOKIE["userid"]
-													));
-
-                                    }
+                            case 6:
+                                #逐词解析
+                                $blockid = $blocks[$i]->block_id;
+                                $query = "select * from wbw_block where id= ? ";
+                                $stmt = $dbhWBW->prepare($query);
+                                $stmt->execute(array($blockid));
+                                $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
+                                $newBlockId = UUID::V4();
+                                $newDocBlockList[] = array('type' => 6, 'block_id' => $newBlockId);
+                                $arrBlockTransform[$fBlock[0]["id"]] = $newBlockId;
+                                if (count($fBlock) > 0) {
+                                    array_push($arrNewBlock,
+                                        array($newBlockId,
+                                            $fBlock[0]["id"],
+                                            $_GET["channel"],
+                                            $_COOKIE["userid"],
+                                            $fBlock[0]["book"],
+                                            $fBlock[0]["paragraph"],
+                                            $fBlock[0]["style"],
+                                            $fBlock[0]["lang"],
+                                            $fBlock[0]["status"],
+                                            mTime(),
+                                            mTime(),
+                                        ));
+                                }
+
+                                $query = "select * from wbw where block_id= ? ";
+                                $stmtWBW = $dbhWBW->prepare($query);
+                                $stmtWBW->execute(array($fBlock[0]["id"]));
+                                $fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
+                                foreach ($fBlockData as $value) {
+                                    array_push($arrNewBlockData,
+                                        array(UUID::V4(),
+                                            $arrBlockTransform[$value["block_id"]],
+                                            $value["book"],
+                                            $value["paragraph"],
+                                            $value["wid"],
+                                            $value["word"],
+                                            $value["data"],
+                                            mTime(),
+                                            mTime(),
+                                            $value["status"],
+                                            $_COOKIE["userid"],
+                                        ));
+
+                                }
                                 break;
-                                case 2:
+                            case 2:
 
                                 break;
-                            }
+                        }
 
+                    }
+                    //逐词解析block数据块
+
+                    if (count($arrNewBlock) > 0) {
+                        $dbhWBW->beginTransaction();
+                        $query = "INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                        $stmtNewBlock = $dbhWBW->prepare($query);
+                        foreach ($arrNewBlock as $oneParam) {
+                            $stmtNewBlock->execute($oneParam);
                         }
-                        //逐词解析block数据块
-                        
-                        if(count($arrNewBlock)>0){
-                            $dbhWBW->beginTransaction();
-                            $query="INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
-                            $stmtNewBlock = $dbhWBW->prepare($query);
-                            foreach($arrNewBlock as $oneParam){
-                                $stmtNewBlock->execute($oneParam);
-                            }
-                            // 提交更改 
-                            $dbhWBW->commit();
-                            if (!$stmtNewBlock || ($stmtNewBlock && $stmtNewBlock->errorCode() != 0)) {
-                                $error = $dbhWBW->errorInfo();
-                                echo "error - $error[2] <br>";
-                            }
-                            else{
-                                //逐词解析block块复刻成功
-                                $count=count($arrNewBlock);
-                                echo "wbw block $count recorders.<br/>";                  
-                            }
+                        // 提交更改
+                        $dbhWBW->commit();
+                        if (!$stmtNewBlock || ($stmtNewBlock && $stmtNewBlock->errorCode() != 0)) {
+                            $error = $dbhWBW->errorInfo();
+                            echo "error - $error[2] <br>";
+                        } else {
+                            //逐词解析block块复刻成功
+                            $count = count($arrNewBlock);
+                            echo "wbw block $count recorders.<br/>";
                         }
+                    }
 
-                        if(count($arrNewBlockData)>0){
-                            // 开始一个事务,逐词解析数据 关闭自动提交
-                            $dbhWBW->beginTransaction();
-                            $query="INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
-                            $stmtWbwData = $dbhWBW->prepare($query);
-                            foreach($arrNewBlockData as $oneParam){
-                                $stmtWbwData->execute($oneParam);
-                            }
-                            // 提交更改 
-                            $dbhWBW->commit();
-                            if (!$stmtWbwData || ($stmtWbwData && $stmtWbwData->errorCode() != 0)) {
-                                $error = $dbhWBW->errorInfo();
-                                echo "error - $error[2] <br>";
-                            }
-                            else{
-                                //逐词解析 数据 复刻成功
-                                $count=count($arrNewBlockData);
-                                echo "new wbw $count recorders.";
-                            }   
+                    if (count($arrNewBlockData) > 0) {
+                        // 开始一个事务,逐词解析数据 关闭自动提交
+                        $dbhWBW->beginTransaction();
+                        $query = "INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                        $stmtWbwData = $dbhWBW->prepare($query);
+                        foreach ($arrNewBlockData as $oneParam) {
+                            $stmtWbwData->execute($oneParam);
                         }
-						
-						//不复刻译文
-                        
-                        //译文 block数据块
-                        /*
-                        if(count($arrSentNewBlock)>0){
-                            $dbhSent->beginTransaction();
-                            $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
-                            $stmtSentNewBlock = $dbhSent->prepare($query);
-                            foreach($arrSentNewBlock as $oneParam){
-                                //print_r($oneParam);
-                                $stmtSentNewBlock->execute($oneParam);
-                            }
-                            // 提交更改 
-                            $dbhSent->commit();
-                            if (!$stmtSentNewBlock || ($stmtSentNewBlock && $stmtSentNewBlock->errorCode() != 0)) {
-                                $error = $dbhSent->errorInfo();
-                                echo "error - $error[2] <br>";
-                            }
-                            else{
-                                //译文 block块复刻成功
-                                $count=count($arrNewBlock);
-                                echo "wbw block $count recorders.<br/>";                  
-                            }
+                        // 提交更改
+                        $dbhWBW->commit();
+                        if (!$stmtWbwData || ($stmtWbwData && $stmtWbwData->errorCode() != 0)) {
+                            $error = $dbhWBW->errorInfo();
+                            echo "error - $error[2] <br>";
+                        } else {
+                            //逐词解析 数据 复刻成功
+                            $count = count($arrNewBlockData);
+                            echo "new wbw $count recorders.";
                         }
+                    }
 
-                        if(count($arrSentNewBlockData)>0){
-                            // 开始一个事务,逐词解析数据 关闭自动提交
-                            $dbhSent->beginTransaction();
-                            $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','channal','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
-                            $stmtSentData = $dbhSent->prepare($query);
-                            foreach($arrSentNewBlockData as $oneParam){
-                                $stmtSentData->execute($oneParam);
-                            }
-                            // 提交更改 
-                            $dbhSent->commit();
-                            if (!$stmtSentData || ($stmtSentData && $stmtSentData->errorCode() != 0)) {
-                                $error = $dbhSent->errorInfo();
-                                echo "error - $error[2] <br>";
-                            }
-                            else{
-                                //译文 数据 复刻成功
-                                $count=count($arrSentNewBlockData);
-                                echo "new translation $count recorders.";
-                            }   
-                        }
-                        */
+                    //不复刻译文
+
+                    //译文 block数据块
+                    /*
+                    if(count($arrSentNewBlock)>0){
+                    $dbhSent->beginTransaction();
+                    $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
+                    $stmtSentNewBlock = $dbhSent->prepare($query);
+                    foreach($arrSentNewBlock as $oneParam){
+                    //print_r($oneParam);
+                    $stmtSentNewBlock->execute($oneParam);
+                    }
+                    // 提交更改
+                    $dbhSent->commit();
+                    if (!$stmtSentNewBlock || ($stmtSentNewBlock && $stmtSentNewBlock->errorCode() != 0)) {
+                    $error = $dbhSent->errorInfo();
+                    echo "error - $error[2] <br>";
+                    }
+                    else{
+                    //译文 block块复刻成功
+                    $count=count($arrNewBlock);
+                    echo "wbw block $count recorders.<br/>";
+                    }
+                    }
 
-                        //插入记录到文件索引
-                        $filesize=0;
-                        //服务器端文件列表
-                        PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-                        $query="INSERT INTO fileindex ('id',
+                    if(count($arrSentNewBlockData)>0){
+                    // 开始一个事务,逐词解析数据 关闭自动提交
+                    $dbhSent->beginTransaction();
+                    $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','channal','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
+                    $stmtSentData = $dbhSent->prepare($query);
+                    foreach($arrSentNewBlockData as $oneParam){
+                    $stmtSentData->execute($oneParam);
+                    }
+                    // 提交更改
+                    $dbhSent->commit();
+                    if (!$stmtSentData || ($stmtSentData && $stmtSentData->errorCode() != 0)) {
+                    $error = $dbhSent->errorInfo();
+                    echo "error - $error[2] <br>";
+                    }
+                    else{
+                    //译文 数据 复刻成功
+                    $count=count($arrSentNewBlockData);
+                    echo "new translation $count recorders.";
+                    }
+                    }
+                     */
+
+                    //插入记录到文件索引
+                    $filesize = 0;
+                    //服务器端文件列表
+                    PDO_Connect("" . _FILE_DB_FILEINDEX_);
+                    $query = "INSERT INTO fileindex ('id',
                                                        'parent_id',
                                                        'user_id',
                                                        'book',
@@ -400,60 +393,58 @@ require_once '../studio/index_head.php';
                                                        'doc_info',
                                                        'doc_block',
                                                        'receive_time'
-                                                       ) 
+                                                       )
                                         VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
-                        $stmt = $PDO->prepare($query);
-                        $newDocId = UUID::v4();
-                        $newDocInfo = $orgFileInfo;
-                        $newDocInfo["id"] = $newDocId;
-                        $newDocInfo["parent_id"] = $orgFileInfo["id"];
-                        $newDocInfo["user_id"] = $_COOKIE["uid"];
-                        $newDocInfo["doc_block"] = json_encode($newDocBlockList, JSON_UNESCAPED_UNICODE); 
-                        $newData=array($newDocInfo["id"],
-                                       $newDocInfo["parent_id"],
-                                       $newDocInfo["user_id"],
-                                       $newDocInfo["book"],
-                                       $newDocInfo["paragraph"],
-                                       $newDocInfo["file_name"],
-                                       $newDocInfo["title"],
-                                       $newDocInfo["tag"],
-                                       $newDocInfo["status"],
-                                       mTime(),
-                                       mTime(),
-                                       mTime(),
-                                       $newDocInfo["file_size"], 
-                                       $newDocInfo["share"], 
-                                       $newDocInfo["doc_info"], 
-                                       $newDocInfo["doc_block"], 
-                                       mTime()
-                                    );
-                        $stmt->execute($newData);
-                        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-                            $error = PDO_ErrorInfo();
-                            echo "error - $error[2] <br>";
-                        }
-                        else{
-                            //文档列表插入成功
-                            
-                            echo "doc list updata 1 recorders.";
-                            echo "</div>";
-                            echo "<h3>复刻成功</h3>";
-                            echo "正在<a href='../studio/editor.php?op=opendb&doc_id={$newDocId}'>打开</a>文档";
-                            echo "<script>";
-                            echo "window.location.assign(\"../studio/editor.php?op=opendb&fileid={$newDocId}\");";
-                            echo "</script>";
-                        } 
-                    }
-                    else{
-                        echo "无效的文档id";
+                    $stmt = $PDO->prepare($query);
+                    $newDocId = UUID::v4();
+                    $newDocInfo = $orgFileInfo;
+                    $newDocInfo["id"] = $newDocId;
+                    $newDocInfo["parent_id"] = $orgFileInfo["id"];
+                    $newDocInfo["user_id"] = $_COOKIE["uid"];
+                    $newDocInfo["doc_block"] = json_encode($newDocBlockList, JSON_UNESCAPED_UNICODE);
+                    $newData = array($newDocInfo["id"],
+                        $newDocInfo["parent_id"],
+                        $newDocInfo["user_id"],
+                        $newDocInfo["book"],
+                        $newDocInfo["paragraph"],
+                        $newDocInfo["file_name"],
+                        $newDocInfo["title"],
+                        $newDocInfo["tag"],
+                        $newDocInfo["status"],
+                        mTime(),
+                        mTime(),
+                        mTime(),
+                        $newDocInfo["file_size"],
+                        $newDocInfo["share"],
+                        $newDocInfo["doc_info"],
+                        $newDocInfo["doc_block"],
+                        mTime(),
+                    );
+                    $stmt->execute($newData);
+                    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                        $error = PDO_ErrorInfo();
+                        echo "error - $error[2] <br>";
+                    } else {
+                        //文档列表插入成功
+
+                        echo "doc list updata 1 recorders.";
+                        echo "</div>";
+                        echo "<h3>复刻成功</h3>";
+                        echo "正在<a href='../studio/editor.php?op=opendb&doc_id={$newDocId}'>打开</a>文档";
+                        echo "<script>";
+                        echo "window.location.assign(\"../studio/editor.php?op=opendb&fileid={$newDocId}\");";
+                        echo "</script>";
                     }
-                    
+                } else {
+                    echo "无效的文档id";
                 }
+
             }
         }
     }
+}
 
-	echo "</div>";
+echo "</div>";
 ?>
 
 </body>

+ 69 - 75
app/doc/load_channal_para.php

@@ -1,93 +1,87 @@
 <?php
 /*
 get xml doc from db
-*/
+ */
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-if(isset($_POST["book"])){
-	$book=$_POST["book"];
-}
-else{
-	echo "error: no book id";
-	exit;
+if (isset($_POST["book"])) {
+    $book = $_POST["book"];
+} else {
+    echo "error: no book id";
+    exit;
 }
 
-if(isset($_POST["para"])){
-	$paralist=explode(",",$_POST["para"]);
-}
-else{
-	exit;
+if (isset($_POST["para"])) {
+    $paralist = explode(",", $_POST["para"]);
+} else {
+    exit;
 }
 
-if(isset($_POST["channal"])){
-	$channal=$_POST["channal"];
-}
-else{
-	exit;
+if (isset($_POST["channal"])) {
+    $channal = $_POST["channal"];
+} else {
+    exit;
 }
 
-	echo '<?xml version="1.0" encoding="UTF-8"?>';
-	echo "<set>\n";
-	echo "    <head>\n";
-	echo "        <type>pcdsset</type>\n";
-	echo "        <mode>package</mode>\n";
-	echo "        <ver>1</ver>\n";
-	echo "        <toc></toc>\n";
-	echo "        <style></style>\n";
-	echo "        <title>{$book}-{$paralist[0]}</title>\n";
-	echo "    </head>\n";
-	echo "\n<dict></dict>\n";
-	echo "<message></message>\n";
-	echo "<body>\n";
-	
-	$dh_wbw = new PDO("sqlite:"._FILE_DB_USER_WBW_, "", "",array(PDO::ATTR_PERSISTENT=>true));
-    $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-	
-	foreach($paralist as $para){
+echo '<?xml version="1.0" encoding="UTF-8"?>';
+echo "<set>\n";
+echo "    <head>\n";
+echo "        <type>pcdsset</type>\n";
+echo "        <mode>package</mode>\n";
+echo "        <ver>1</ver>\n";
+echo "        <toc></toc>\n";
+echo "        <style></style>\n";
+echo "        <title>{$book}-{$paralist[0]}</title>\n";
+echo "    </head>\n";
+echo "\n<dict></dict>\n";
+echo "<message></message>\n";
+echo "<body>\n";
 
-				$albumId = UUID::v4();
-				$query="SELECT * FROM wbw_block WHERE channal=? AND book = ? AND paragraph = ?  ";
-				$stmt = $dh_wbw->prepare($query);
-				$stmt->execute(array($channal,$book,$para));
-				$FetchBlock = $stmt->fetch(PDO::FETCH_ASSOC);
-				if($FetchBlock){
-					echo "\n<block>";
-					echo "<info>\n";
-					
-					echo "<type>wbw</type>";
-					echo "<book>{$book}</book>";
-					echo "<paragraph>{$para}</paragraph>";
-					echo "<level>100</level>";
-					echo "<title></title>";
-					echo "<album_id></album_id>";
-					echo "<album_guid></album_guid>";
-					echo "<author>{$FetchBlock["owner"]}</author>";
-					echo "<language>{$FetchBlock["lang"]}</language>";
-					echo "<version>1</version>";
-					echo "<edition>1</edition>";
-					echo "<id>{$FetchBlock["id"]}</id>";
-					echo "</info>\n";		
+$dh_wbw = new PDO("" . _FILE_DB_USER_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-					echo "<data>\n";
-					$block_id = $FetchBlock["id"];
-					$query="select * from wbw where block_id= ? ";
-					$stmt = $dh_wbw->prepare($query);
-					$stmt->execute(array($block_id));
-					$wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
-					foreach($wbw_data as $word){
-						echo $word["data"];	
-						echo "\r\n";	
-					}
-					echo "</data>";
-					echo "</block>\n";
-				}
+foreach ($paralist as $para) {
 
-	}
-				
-	echo "</body>\n";
-	echo "</set>";
+    $albumId = UUID::v4();
+    $query = "SELECT * FROM wbw_block WHERE channal=? AND book = ? AND paragraph = ?  ";
+    $stmt = $dh_wbw->prepare($query);
+    $stmt->execute(array($channal, $book, $para));
+    $FetchBlock = $stmt->fetch(PDO::FETCH_ASSOC);
+    if ($FetchBlock) {
+        echo "\n<block>";
+        echo "<info>\n";
 
+        echo "<type>wbw</type>";
+        echo "<book>{$book}</book>";
+        echo "<paragraph>{$para}</paragraph>";
+        echo "<level>100</level>";
+        echo "<title></title>";
+        echo "<album_id></album_id>";
+        echo "<album_guid></album_guid>";
+        echo "<author>{$FetchBlock["owner"]}</author>";
+        echo "<language>{$FetchBlock["lang"]}</language>";
+        echo "<version>1</version>";
+        echo "<edition>1</edition>";
+        echo "<id>{$FetchBlock["id"]}</id>";
+        echo "</info>\n";
+
+        echo "<data>\n";
+        $block_id = $FetchBlock["id"];
+        $query = "select * from wbw where block_id= ? ";
+        $stmt = $dh_wbw->prepare($query);
+        $stmt->execute(array($block_id));
+        $wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
+        foreach ($wbw_data as $word) {
+            echo $word["data"];
+            echo "\r\n";
+        }
+        echo "</data>";
+        echo "</block>\n";
+    }
+
+}
 
-?>
+echo "</body>\n";
+echo "</set>";

+ 252 - 269
app/doc/pcs2db.php

@@ -2,7 +2,7 @@
 /*
 转换pcs 到数据库格式
 
-*/
+ */
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
@@ -13,118 +13,113 @@ echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
 
 echo "<h2>转换PCS 到数据库格式</h2>";
 
-if($_COOKIE["uid"]){
-	$uid=$_COOKIE["uid"];
+if ($_COOKIE["uid"]) {
+    $uid = $_COOKIE["uid"];
+} else {
+    echo "尚未登录";
+    echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
+    exit;
 }
-else{
-	echo "尚未登录";
-	echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
-	exit;
+if (isset($_GET["doc_id"]) == false) {
+    echo "没有 文档编号";
+    exit;
 }
-if(isset($_GET["doc_id"])==false){
-	echo "没有 文档编号";
-	exit;
-}
-PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-$doc_id=$_GET["doc_id"];
+PDO_Connect("" . _FILE_DB_FILEINDEX_);
+$doc_id = $_GET["doc_id"];
 $query = "SELECT * from fileindex where id= ? ";
-$Fetch = PDO_FetchAll($query,array($doc_id));
-$iFetch=count($Fetch);
-if($iFetch>0){
-	//文档信息
-	$mbook=$Fetch[0]["book"];
-	$paragraph=$Fetch[0]["paragraph"];
+$Fetch = PDO_FetchAll($query, array($doc_id));
+$iFetch = count($Fetch);
+if ($iFetch > 0) {
+    //文档信息
+    $mbook = $Fetch[0]["book"];
+    $paragraph = $Fetch[0]["paragraph"];
 }
 
-if(isset($_GET["channel"])==false){
-	echo '<div class="file_list_block">';
-	echo "<h2>选择一个空白的版风存储新的文档</h2>";
-	echo "<form action='pcs2db.php' method='get'>";
-	echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
-	PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
-	$query = "SELECT * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
-	$Fetch = PDO_FetchAll($query);
-	$i=0;
-	foreach($Fetch as $row){
-		echo '<div class="file_list_row" style="padding:5px;display:flex;">';
-	
-		echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-		echo '<input name="channel" value="'.$row["id"].'" ';
-		if($i==0){
-			echo "checked";
-		}
-		echo ' type="radio" />';
-		echo '</div>';
-		echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["name"].'</div>';
-		echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
-		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-		PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
-		$query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-		$FetchWBW = PDO_FetchOne($query);
-		echo '</div>';
-		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-		if($FetchWBW==0){
-			echo $_local->gui->blank;
-		}
-		else{
-			echo $FetchWBW.$_local->gui->para;
-			echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
-		}
-		echo '</div>';
-
-		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-		PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
-		$query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-		$FetchWBW = PDO_FetchOne($query);
-		echo '</div>';
-		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-		if($FetchWBW==0){
-			echo $_local->gui->blank;
-		}
-		else{
-			echo $FetchWBW.$_local->gui->para;
-		}
-		echo '</div>';
-
-		echo '<div class="summary"  style="flex:1;padding-bottom:5px;">'.$row["status"].'</div>';
-		echo '<div class="author"  style="flex:1;padding-bottom:5px;">'.$row["create_time"].'</div>';
-		
-		echo '</div>';
-		$i++;
-	}
-	echo "<input type='submit' />";
-	echo "</form>";
-	echo "</div>";
-	exit;
+if (isset($_GET["channel"]) == false) {
+    echo '<div class="file_list_block">';
+    echo "<h2>选择一个空白的版风存储新的文档</h2>";
+    echo "<form action='pcs2db.php' method='get'>";
+    echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+    PDO_Connect("" . _FILE_DB_CHANNAL_);
+    $query = "SELECT * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+    $Fetch = PDO_FetchAll($query);
+    $i = 0;
+    foreach ($Fetch as $row) {
+        echo '<div class="file_list_row" style="padding:5px;display:flex;">';
+
+        echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+        echo '<input name="channel" value="' . $row["id"] . '" ';
+        if ($i == 0) {
+            echo "checked";
+        }
+        echo ' type="radio" />';
+        echo '</div>';
+        echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
+        echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        PDO_Connect("" . _FILE_DB_USER_WBW_);
+        $query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $FetchWBW = PDO_FetchOne($query);
+        echo '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        if ($FetchWBW == 0) {
+            echo $_local->gui->blank;
+        } else {
+            echo $FetchWBW . $_local->gui->para;
+            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+        }
+        echo '</div>';
+
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        PDO_Connect("" . _FILE_DB_SENTENCE_);
+        $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $FetchWBW = PDO_FetchOne($query);
+        echo '</div>';
+        echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+        if ($FetchWBW == 0) {
+            echo $_local->gui->blank;
+        } else {
+            echo $FetchWBW . $_local->gui->para;
+        }
+        echo '</div>';
+
+        echo '<div class="summary"  style="flex:1;padding-bottom:5px;">' . $row["status"] . '</div>';
+        echo '<div class="author"  style="flex:1;padding-bottom:5px;">' . $row["create_time"] . '</div>';
+
+        echo '</div>';
+        $i++;
+    }
+    echo "<input type='submit' />";
+    echo "</form>";
+    echo "</div>";
+    exit;
 }
 
-$dir = _DIR_USER_DOC_.'/'.$_COOKIE["userid"]._DIR_MYDOCUMENT_;
-PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+$dir = _DIR_USER_DOC_ . '/' . $_COOKIE["userid"] . _DIR_MYDOCUMENT_;
+PDO_Connect("" . _FILE_DB_FILEINDEX_);
 $query = "SELECT file_name, doc_info, modify_time from fileindex where id=? ";
-$Fetch = PDO_FetchRow($query,array($_GET["doc_id"]));
+$Fetch = PDO_FetchRow($query, array($_GET["doc_id"]));
 
-if($Fetch===false){
-	echo "文件不存在";
-    exit;    
-}
-else{
+if ($Fetch === false) {
+    echo "文件不存在";
+    exit;
+} else {
     $file_modify_time = $Fetch["modify_time"];
-    if(empty($Fetch["doc_info"])){
-        $file = $dir.'/'.$Fetch["file_name"];    
-    }
-    else{
-		echo "已经是数据库格式了。无需转换";
-		exit;
+    if (empty($Fetch["doc_info"])) {
+        $file = $dir . '/' . $Fetch["file_name"];
+    } else {
+        echo "已经是数据库格式了。无需转换";
+        exit;
     }
 }
-if(!file_exists($file)){
-	echo "文件不存在";
-	exit;
+if (!file_exists($file)) {
+    echo "文件不存在";
+    exit;
 }
 $xml = simplexml_load_file($file);
-if($xml==false){
-	echo "载入pcs文件错误";
-	exit;
+if ($xml == false) {
+    echo "载入pcs文件错误";
+    exit;
 }
 $xml_head = $xml->xpath('//head')[0];
 $strHead = "<head>";
@@ -141,127 +136,124 @@ $strHead .= "</head>";
 
 $dataBlock = $xml->xpath('//block');
 
-
 {
 
     //复制数据
     //打开逐词解析数据库
-    $dns = "sqlite:"._FILE_DB_USER_WBW_;
-    $dbhWBW = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-    $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+    $dns = "" . _FILE_DB_USER_WBW_;
+    $dbhWBW = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     //打开译文数据库
-    $dns = "sqlite:"._FILE_DB_SENTENCE_;
-    $dbhSent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-    $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 
+    $dns = "" . _FILE_DB_SENTENCE_;
+    $dbhSent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     //逐词解析新数据数组
     $arrNewBlock = array();
     $arrNewBlockData = array();
     $arrBlockTransform = array();
-    
+
     //译文新数据数组
     $arrSentNewBlock = array();
     $arrSentNewBlockData = array();
-    $arrSentBlockTransform = array(); 
+    $arrSentBlockTransform = array();
 
-    $newDocBlockList=array();
-    foreach($dataBlock as $block){
-        switch($block->info->type){
+    $newDocBlockList = array();
+    foreach ($dataBlock as $block) {
+        switch ($block->info->type) {
             case "translate":
-                echo "wbw:".$block->info->book."<br>";
-            break;
+                echo "wbw:" . $block->info->book . "<br>";
+                break;
             case "wbw":
-                echo "translate:".$block->info->book."<br>";
-            break;
+                echo "translate:" . $block->info->book . "<br>";
+                break;
         }
     }
 
-    foreach($dataBlock as $block) {
-        switch($block->info->type){
+    foreach ($dataBlock as $block) {
+        switch ($block->info->type) {
             case 1:
-            break;
+                break;
             case "translate":
                 //译文
-				$blockid = UUID::V4();
-				//译文不加入块列表 因为译文用channel解决 不需要渲染译文块
+                $blockid = UUID::V4();
+                //译文不加入块列表 因为译文用channel解决 不需要渲染译文块
                 //$newDocBlockList[]=array('type' => 2,'block_id' => $blockid);
                 $arrSentBlockTransform["{$blockid}"] = $blockid;
                 //if(count($fBlock)>0)
                 {
-                    array_push( $arrSentNewBlock,array($blockid,
-                                                    "",
-                                                    $block->info->book,
-                                                    $block->info->paragraph,
-                                                    $_COOKIE["userid"],
-                                                    $block->info->language,
-                                                    $block->info->author,
-                                                    "",
-                                                    "",
-                                                    "1",
-                                                    $file_modify_time,
-                                                    mTime()
-                                                ));
+                    array_push($arrSentNewBlock, array($blockid,
+                        "",
+                        $block->info->book,
+                        $block->info->paragraph,
+                        $_COOKIE["userid"],
+                        $block->info->language,
+                        $block->info->author,
+                        "",
+                        "",
+                        "1",
+                        $file_modify_time,
+                        mTime(),
+                    ));
                 }
-                foreach($block->data->children() as $sen){
-                    if(isset($sen->begin)){
-                        $sent_begin=$sen->begin;
+                foreach ($block->data->children() as $sen) {
+                    if (isset($sen->begin)) {
+                        $sent_begin = $sen->begin;
+                    } else {
+                        $sent_begin = "";
                     }
-                    else{
-                        $sent_begin="";
+                    if (isset($sen->end)) {
+                        $sent_end = $sen->end;
+                    } else {
+                        $sent_end = "";
                     }
-                    if(isset($sen->end)){
-                        $sent_end=$sen->end;
-                    }
-                    else{
-                        $sent_end="";
-                    }
-                    if(isset($sen->text) && strlen(trim($sen->text))>0){
-                        $paraText=$sen->text;
-                        if( $block->info->level>0 &&  $block->info->level<8){
-                            $toc.=$sen->text;
-						}
-						array_push( $arrSentNewBlockData,
-									array(UUID::V4(),
-										$blockid,
-										$block->info->book,
-										$block->info->paragraph,
-										$sent_begin,
-										$sent_end,
-										"",
-										$block->info->author,
-										$_COOKIE["userid"],
-										$paraText,
-										mb_strlen($paraText,"UTF-8"),
-										$block->info->language,
-										"1",
-										"7",
-										$file_modify_time,
-										mTime(),
-										mTime(),
-										$_GET["channel"]
-									));						
+                    if (isset($sen->text) && strlen(trim($sen->text)) > 0) {
+                        $paraText = $sen->text;
+                        if ($block->info->level > 0 && $block->info->level < 8) {
+                            $toc .= $sen->text;
+                        }
+                        array_push($arrSentNewBlockData,
+                            array(UUID::V4(),
+                                $blockid,
+                                $block->info->book,
+                                $block->info->paragraph,
+                                $sent_begin,
+                                $sent_end,
+                                "",
+                                $block->info->author,
+                                $_COOKIE["userid"],
+                                $paraText,
+                                mb_strlen($paraText, "UTF-8"),
+                                $block->info->language,
+                                "1",
+                                "7",
+                                $file_modify_time,
+                                mTime(),
+                                mTime(),
+                                $_GET["channel"],
+                            ));
                     }
                 }
-            break;
+                break;
             case "wbw":
                 $blockid = UUID::V4();
-                $newDocBlockList[]=array('type' => 6,'block_id' => $blockid);
+                $newDocBlockList[] = array('type' => 6, 'block_id' => $blockid);
                 $arrBlockTransform["{$blockid}"] = $blockid;
                 {
-					array_push( $arrNewBlock,
-								array($blockid,
-								"",
-								$_GET["channel"],
-								$_COOKIE["userid"],
-								$block->info->book,
-								$block->info->paragraph,
-								"",
-								$block->info->language,
-								"",
-								$file_modify_time,
-								mTime()
-							));
+                    array_push($arrNewBlock,
+                        array($blockid,
+                            "",
+                            $_GET["channel"],
+                            $_COOKIE["userid"],
+                            $block->info->book,
+                            $block->info->paragraph,
+                            "",
+                            $block->info->language,
+                            "",
+                            $file_modify_time,
+                            mTime(),
+                        ));
                 }
 
                 $currWordId = "";
@@ -269,13 +261,13 @@ $dataBlock = $xml->xpath('//block');
                 $currWordStatus = "";
                 $sWordData = "";
                 $iWordCount = 0;
-                foreach($block->data->children() as $word){
-                    $word_id = explode("-",$word->id)[2];
-                    $arrWordId = explode("_",$word_id);
+                foreach ($block->data->children() as $word) {
+                    $word_id = explode("-", $word->id)[2];
+                    $arrWordId = explode("_", $word_id);
                     $realWordId = $arrWordId[0];
-                    if($realWordId != $currWordId){
-                        if($iWordCount>0){
-                            array_push( $arrNewBlockData,array(UUID::V4(),
+                    if ($realWordId != $currWordId) {
+                        if ($iWordCount > 0) {
+                            array_push($arrNewBlockData, array(UUID::V4(),
                                 $blockid,
                                 $block->info->book,
                                 $block->info->paragraph,
@@ -285,7 +277,7 @@ $dataBlock = $xml->xpath('//block');
                                 $file_modify_time,
                                 mTime(),
                                 $currWordStatus,
-                                $_COOKIE["userid"]
+                                $_COOKIE["userid"],
                             ));
                             $sWordData = "";
                         }
@@ -293,7 +285,7 @@ $dataBlock = $xml->xpath('//block');
                         $currWordReal = $word->real;
                         $currWordStatus = $word->status;
                     }
-                    
+
                     $sWordData .= "<word>";
                     $sWordData .= "<pali>{$word->pali}</pali>";
                     $sWordData .= "<real>{$word->real}</real>";
@@ -308,51 +300,49 @@ $dataBlock = $xml->xpath('//block');
                     $sWordData .= "<style>{$word->style}</style>";
                     $sWordData .= "<status>{$word->status}</status>";
                     $sWordData .= "<parent>{$word->parent}</parent>";
-                    if(isset($word->bmc)){
+                    if (isset($word->bmc)) {
                         $sWordData .= "<bmc>{$word->bmc}</bmc>";
                     }
-                    if(isset($word->bmt)){
+                    if (isset($word->bmt)) {
                         $sWordData .= "<bmt>{$word->bmt}</bmt>";
                     }
-                    if(isset($word->un)){
+                    if (isset($word->un)) {
                         $sWordData .= "<un>{$word->un}</un>";
                     }
-                    if(isset($word->lock)){
+                    if (isset($word->lock)) {
                         $sWordData .= "<lock>{$word->lock}</lock>";
                     }
                     $sWordData .= "</word>";
 
-
-                     $iWordCount++;
+                    $iWordCount++;
                 }
-				array_push( $arrNewBlockData,
-							array(UUID::V4(),
-							$blockid,
-							$block->info->book,
-							$block->info->paragraph,
-							$word_id,
-							$word->real,
-							$sWordData,
-							$file_modify_time,
-							mTime(),
-							$word->status,
-							$_COOKIE["userid"]
-            			));
-            break;
+                array_push($arrNewBlockData,
+                    array(UUID::V4(),
+                        $blockid,
+                        $block->info->book,
+                        $block->info->paragraph,
+                        $word_id,
+                        $word->real,
+                        $sWordData,
+                        $file_modify_time,
+                        mTime(),
+                        $word->status,
+                        $_COOKIE["userid"],
+                    ));
+                break;
             case 2:
 
-            break;
+                break;
         }
 
     }
-    
-    //逐词解析block数据块结束
 
+    //逐词解析block数据块结束
 
-	#插入逐词解析块数据
-    if(count($arrNewBlock)>0){
+    #插入逐词解析块数据
+    if (count($arrNewBlock) > 0) {
         $dbhWBW->beginTransaction();
-        $query="INSERT INTO wbw_block (
+        $query = "INSERT INTO wbw_block (
 										'id',
 										'parent_id',
 										'channal',
@@ -364,97 +354,91 @@ $dataBlock = $xml->xpath('//block');
 										'status',
 										'modify_time',
 										'receive_time'
-										) 
+										)
 										VALUES (?,?,?,?,?,?,?,?,?,?,?)";
         $stmtNewBlock = $dbhWBW->prepare($query);
-        foreach($arrNewBlock as $oneParam){
+        foreach ($arrNewBlock as $oneParam) {
             $stmtNewBlock->execute($oneParam);
         }
-        // 提交更改 
+        // 提交更改
         $dbhWBW->commit();
         if (!$stmtNewBlock || ($stmtNewBlock && $stmtNewBlock->errorCode() != 0)) {
             $error = $dbhWBW->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             //逐词解析block块复刻成功
-            $count=count($arrNewBlock);
-            echo "wbw block $count recorders.<br/>";                  
+            $count = count($arrNewBlock);
+            echo "wbw block $count recorders.<br/>";
         }
     }
 
-    if(count($arrNewBlockData)>0){
+    if (count($arrNewBlockData) > 0) {
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhWBW->beginTransaction();
-        $query="INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+        $query = "INSERT INTO wbw ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
         $stmtWbwData = $dbhWBW->prepare($query);
-        foreach($arrNewBlockData as $oneParam){
+        foreach ($arrNewBlockData as $oneParam) {
             $stmtWbwData->execute($oneParam);
         }
-        // 提交更改 
+        // 提交更改
         $dbhWBW->commit();
         if (!$stmtWbwData || ($stmtWbwData && $stmtWbwData->errorCode() != 0)) {
             $error = $dbhWBW->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             //逐词解析 数据 复刻成功
-            $count=count($arrNewBlockData);
+            $count = count($arrNewBlockData);
             echo "new wbw $count recorders.";
-        }   
+        }
     }
-    
-    
+
     //译文 block数据块
-    
-    if(count($arrSentNewBlock)>0){
+
+    if (count($arrSentNewBlock) > 0) {
         $dbhSent->beginTransaction();
-        $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
+        $query = "INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
         $stmtSentNewBlock = $dbhSent->prepare($query);
-        foreach($arrSentNewBlock as $oneParam){
+        foreach ($arrSentNewBlock as $oneParam) {
             //print_r($oneParam);
             $stmtSentNewBlock->execute($oneParam);
         }
         // 提交更改
         $dbhSent->commit();
-        if (!$stmtSentNewBlock || ($stmtSentNewBlock && $stmtSentNewBlock->errorCode() != 0)){
+        if (!$stmtSentNewBlock || ($stmtSentNewBlock && $stmtSentNewBlock->errorCode() != 0)) {
             $error = $dbhSent->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             //译文 block块复刻成功
-            $count=count($arrNewBlock);
-            echo "wbw block $count recorders.<br/>";                  
+            $count = count($arrNewBlock);
+            echo "wbw block $count recorders.<br/>";
         }
     }
 
-    if(count($arrSentNewBlockData)>0){
+    if (count($arrSentNewBlockData) > 0) {
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhSent->beginTransaction();
-        $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','strlen','language','ver','status','modify_time','receive_time','create_time','channal') VALUES (? , ? , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
+        $query = "INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','strlen','language','ver','status','modify_time','receive_time','create_time','channal') VALUES (? , ? , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
         $stmtSentData = $dbhSent->prepare($query);
-        foreach($arrSentNewBlockData as $oneParam){
+        foreach ($arrSentNewBlockData as $oneParam) {
             $stmtSentData->execute($oneParam);
         }
-        // 提交更改 
+        // 提交更改
         $dbhSent->commit();
         if (!$stmtSentData || ($stmtSentData && $stmtSentData->errorCode() != 0)) {
             $error = $dbhSent->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             //译文 数据 复刻成功
-            $count=count($arrSentNewBlockData);
+            $count = count($arrSentNewBlockData);
             echo "new translation $count recorders.";
-        }   
+        }
     }
-    
 
     //插入记录到文件索引
-    $filesize=0;
+    $filesize = 0;
     //服务器端文件列表
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-    $query="INSERT INTO fileindex ('id',
+    PDO_Connect("" . _FILE_DB_FILEINDEX_);
+    $query = "INSERT INTO fileindex ('id',
                                    'parent_id',
                                    'user_id',
                                    'book',
@@ -471,30 +455,29 @@ $dataBlock = $xml->xpath('//block');
                                    'doc_info',
                                    'doc_block',
                                    'receive_time'
-                                   ) 
+                                   )
                     VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
     $stmt = $PDO->prepare($query);
-    $query="UPDATE 'fileindex' SET 'doc_info' = ? , 'doc_block' = ?  WHERE id = ? ";
-	$stmt = $PDO->prepare($query);
-    $newData=array(
-                   $strHead,
-                   json_encode($newDocBlockList, JSON_UNESCAPED_UNICODE), 
-                   $_GET["doc_id"]
-                );
+    $query = "UPDATE 'fileindex' SET 'doc_info' = ? , 'doc_block' = ?  WHERE id = ? ";
+    $stmt = $PDO->prepare($query);
+    $newData = array(
+        $strHead,
+        json_encode($newDocBlockList, JSON_UNESCAPED_UNICODE),
+        $_GET["doc_id"],
+    );
     $stmt->execute($newData);
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
         echo "error - $error[2] <br>";
-    }
-    else{
+    } else {
         //文档列表插入成功
         echo "doc list updata 1 recorders.";
         echo "<a href='../studio/editor.php?op=opendb&doc_id={$_GET["doc_id"]}'>在编辑器中打开</a>";
-    }          
-                
+    }
+
 }
 ?>
 
 </div>
 </body>
-</html>
+</html>

+ 29 - 31
app/fullcalendar/examples/php/get-date.php

@@ -4,36 +4,34 @@
 require_once "../../../path.php";
 require_once "../../../public/_pdo.php";
 
-function get_teacher_course($teacher_id){
-
-		$teacher = "  ";
-
-	global $PDO;
-	PDO_Connect("sqlite:"._FILE_DB_COURSE_);
-	
-	$query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
-
-	$Fetch = PDO_FetchAll($query,array($teacher_id));
-	
-	$output = array();
-	foreach ($Fetch as $key => $couse) {
-		# code...
-		$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
-		$fAllLesson = PDO_FetchAll($query);
-		foreach ($fAllLesson as  $lesson) {
-			$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
-			$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
-			$output[]=array("id"=>$lesson["id"],
-										"title"=>$couse["title"],
-										"url"=>"../../course/lesson.php?id=".$lesson["id"],
-										"start"=> $start,
-										"end"=>$end
-									);
-		}
-	}
-	return($output);
-	
-}
+function get_teacher_course($teacher_id)
+{
+
+    $teacher = "  ";
+
+    global $PDO;
+    PDO_Connect("" . _FILE_DB_COURSE_);
 
+    $query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
 
-?>
+    $Fetch = PDO_FetchAll($query, array($teacher_id));
+
+    $output = array();
+    foreach ($Fetch as $key => $couse) {
+        # code...
+        $query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
+        $fAllLesson = PDO_FetchAll($query);
+        foreach ($fAllLesson as $lesson) {
+            $start = date("Y-m-d\TH:i:s+00:00", $lesson["date"] / 1000);
+            $end = date("Y-m-d\TH:i:s+00:00", $lesson["date"] / 1000 + $lesson["duration"]);
+            $output[] = array("id" => $lesson["id"],
+                "title" => $couse["title"],
+                "url" => "../../course/lesson.php?id=" . $lesson["id"],
+                "start" => $start,
+                "end" => $end,
+            );
+        }
+    }
+    return ($output);
+
+}

+ 30 - 34
app/group/function.php

@@ -1,65 +1,61 @@
 <?php
 
-
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
-function group_get_name($id){
-	if(isset($id)){
-		PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-		$query = "SELECT name FROM group_info  WHERE id=?";
-		$Fetch = PDO_FetchRow($query,array($id));
-		if($Fetch){
-			return $Fetch["name"];
-		}
-		else{
-			return "";
-		}
-	}
-	else{
-		return "";
-	}
+function group_get_name($id)
+{
+    if (isset($id)) {
+        PDO_Connect("" . _FILE_DB_GROUP_);
+        $query = "SELECT name FROM group_info  WHERE id=?";
+        $Fetch = PDO_FetchRow($query, array($id));
+        if ($Fetch) {
+            return $Fetch["name"];
+        } else {
+            return "";
+        }
+    } else {
+        return "";
+    }
 }
 
 class GroupInfo
 {
     private $dbh;
     private $buffer;
-    public function __construct() {
-        $dns = "sqlite:"._FILE_DB_GROUP_;
-        $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+    public function __construct()
+    {
+        $dns = "" . _FILE_DB_GROUP_;
+        $this->dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
         $buffer = array();
     }
 
-    public function getName($id){
-        if(empty($id)){
+    public function getName($id)
+    {
+        if (empty($id)) {
             return "";
         }
-        if(isset($buffer[$id])){
+        if (isset($buffer[$id])) {
             return $buffer[$id];
         }
-        if($this->dbh){
+        if ($this->dbh) {
             $query = "SELECT name FROM group_info WHERE id= ? ";
             $stmt = $this->dbh->prepare($query);
             $stmt->execute(array($id));
             $user = $stmt->fetch(PDO::FETCH_ASSOC);
-            if($user){
+            if ($user) {
                 $buffer[$id] = $user["name"];
                 return $buffer[$id];
-            }
-            else{
-                $buffer[$id] ="";
+            } else {
+                $buffer[$id] = "";
                 return $buffer[$id];
-            }            
-        }
-        else{
-            $buffer[$id] ="";
+            }
+        } else {
+            $buffer[$id] = "";
             return $buffer[$id];
         }
     }
 }
-
-?>

+ 35 - 38
app/group/get.php

@@ -7,44 +7,41 @@ require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
 $output = array();
-if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-    $id=$_GET["id"];
+if (isset($_GET["id"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
+    $id = $_GET["id"];
     $query = "SELECT * FROM group_info  WHERE id = ? ";
-	$Fetch = PDO_FetchRow($query,array($id));
-	if($Fetch){
-		$output["info"] = $Fetch;
-		if($Fetch["parent"]==0 ){
-			#顶级组 列出小组
-			$query = "SELECT * FROM group_info  WHERE parent = ? ";
-			$FetchList = PDO_FetchAll($query,array($id));
-			$output["children"] = $FetchList;
-		}
-		else{
-			$output["children"] = array();
-			$query = "SELECT * FROM group_info  WHERE id = ? ";
-			$parent_group = PDO_FetchRow($query,array($Fetch["parent"]));
-			$output["parent"] = $parent_group;
-		}
-		#列出组文件
-		{
-			PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-			$query = "SELECT * FROM power  WHERE user = ? ";
-			$fileList = PDO_FetchAll($query,array($id));
-			foreach ($fileList as $key => $value) {
-				# code...
-				$query = "SELECT title FROM fileindex  WHERE id = ? ";
-				$file = PDO_FetchRow($query,array($value["doc_id"]));
-				if($file){
-					$fileList[$key]["title"]=$file["title"];
-				}
-				else{
-					$fileList[$key]["title"]="";
-				}
-			}
-			$output["file"] = $fileList;
-		}
-	}
+    $Fetch = PDO_FetchRow($query, array($id));
+    if ($Fetch) {
+        $output["info"] = $Fetch;
+        if ($Fetch["parent"] == 0) {
+            #顶级组 列出小组
+            $query = "SELECT * FROM group_info  WHERE parent = ? ";
+            $FetchList = PDO_FetchAll($query, array($id));
+            $output["children"] = $FetchList;
+        } else {
+            $output["children"] = array();
+            $query = "SELECT * FROM group_info  WHERE id = ? ";
+            $parent_group = PDO_FetchRow($query, array($Fetch["parent"]));
+            $output["parent"] = $parent_group;
+        }
+        #列出组文件
+        {
+            PDO_Connect("" . _FILE_DB_FILEINDEX_);
+            $query = "SELECT * FROM power  WHERE user = ? ";
+            $fileList = PDO_FetchAll($query, array($id));
+            foreach ($fileList as $key => $value) {
+                # code...
+                $query = "SELECT title FROM fileindex  WHERE id = ? ";
+                $file = PDO_FetchRow($query, array($value["doc_id"]));
+                if ($file) {
+                    $fileList[$key]["title"] = $file["title"];
+                } else {
+                    $fileList[$key]["title"] = "";
+                }
+            }
+            $output["file"] = $fileList;
+        }
+    }
 }
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-?>

+ 9 - 10
app/group/get_name.php

@@ -7,16 +7,15 @@ require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
 $output = array();
-if(isset($_GET["name"])){
-    PDO_Connect("sqlite:"._FILE_DB_GROUP_);
+if (isset($_GET["name"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
     $query = "SELECT * FROM group_info  WHERE name like ? and parent=0 limit 0,5";
-	$Fetch = PDO_FetchAll($query,array("%".$_GET["name"]."%"));
+    $Fetch = PDO_FetchAll($query, array("%" . $_GET["name"] . "%"));
 
-	$user_info  = new UserInfo();
-	foreach ($Fetch as $key => $value) {
-		# code...
-		$Fetch[$key]["username"] = $user_info->getName($value["owner"]);
-	}
-	echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
+    $user_info = new UserInfo();
+    foreach ($Fetch as $key => $value) {
+        # code...
+        $Fetch[$key]["username"] = $user_info->getName($value["owner"]);
+    }
+    echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 }
-?>

+ 229 - 238
app/group/group.php

@@ -11,7 +11,7 @@ require_once '../public/_pdo.php';
 <style>
 	#group_index {
 		background-color: var(--btn-border-color);
-		
+
 	}
 	#group_index:hover{
 		background-color: var(--btn-border-color);
@@ -21,294 +21,285 @@ require_once '../public/_pdo.php';
 	</style>
 		<!-- tool bar begin-->
 		<?php
-		require_once '../studio/index_tool_bar.php';
-		?>
+require_once '../studio/index_tool_bar.php';
+?>
 		<!--tool bar end -->
 		<script>
-			document.getElementById("id_language").value="<?php echo($currLanguage); ?>";
+			document.getElementById("id_language").value="<?php echo ($currLanguage); ?>";
 		</script>
 	<div class="index_inner">
-			
+
 		<div class="fun_block">
 			<div id="userfilelist">
 			<?php
-			if(isset($_GET["list"])){
-				$list=$_GET["list"];
-			}
-			else{
-				$list="group";
-			}
+if (isset($_GET["list"])) {
+    $list = $_GET["list"];
+} else {
+    $list = "group";
+}
+
+PDO_Connect("" . _FILE_DB_GROUP_);
+switch ($list) {
+    case "group":
+        echo "<div class='group_path'>Group</div>";
+        $query = "select * from \"group_member\" where user_id='{$UID}' ";
+        $Fetch = PDO_FetchAll($query);
+        $iFetch = count($Fetch);
+        $sGroupId = "('";
+        if ($iFetch > 0) {
+            foreach ($Fetch as $group_id) {
+                $sGroupId .= "{$group_id["group_id"]}','";
+            }
+            $sGroupId = substr($sGroupId, 0, -2);
+            $sGroupId .= ")";
+            $query = "select * from \"group_info\" where id in {$sGroupId} ";
+            $Fetch = PDO_FetchAll($query);
+            foreach ($Fetch as $group) {
+                echo "<div><a href=\"group.php?list=project&group={$group["id"]}\">{$group["name"]}</a>";
+                echo "<a href=\"group.php?list=group_info&group={$group["id"]}\"> [详情]</a></div>";
+            }
+        }
+        break;
+    case "group_info":
+        echo "<div><a href=\"group.php?list=group\">返回Back</a></div>";
+        if (isset($_GET["group"])) {
+            $group = $_GET["group"];
+        } else {
+            $group = "0";
+        }
+        $query = "select * from \"group_info\" where id = '{$group}' ";
+        $Fetch = PDO_FetchAll($query);
+        $group_name = $Fetch[0]["name"];
+        if (count($Fetch) > 0) {
+
+            echo "<H2>{$group_name}</H2>";
+            echo "<table>";
+            echo "<tr><td>建立Create Time</td><td>{$Fetch[0]["create_time"]}</td></tr>";
+            echo "<tr><td>文件Files</td><td>{$Fetch[0]["file_number"]}</td></tr>";
+            echo "<tr><td>成员Member</td><td>{$Fetch[0]["member_number"]}</td></tr>";
+            $query = "select user_id from \"group_member\" where group_id = '{$group}' ";
+            $Fetch = PDO_FetchAll($query);
+            $sUserId = "('";
+            foreach ($Fetch as $user) {
+                $sUserId .= "{$user["user_id"]}','";
+            }
+            $sUserId = substr($sUserId, 0, -2);
+            $sUserId .= ")";
+
+            $query = "select nickname from \"user\" where id in {$sUserId} ";
+
+            $userlist = PDO_FetchAll($query);
+
+            echo "<tr><td></td><td>";
+            foreach ($userlist as $user) {
+                echo "{$user["nickname"]}<br>";
+            }
+            echo "</td></tr>";
+            echo "</table>";
+        }
 
-			PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-			switch($list){
-				case "group":
-					echo "<div class='group_path'>Group</div>";
-					$query="select * from \"group_member\" where user_id='{$UID}' ";
-					$Fetch = PDO_FetchAll($query);
-					$iFetch=count($Fetch);
-					$sGroupId="('";
-					if($iFetch>0){
-						foreach($Fetch as $group_id){
-							$sGroupId .= "{$group_id["group_id"]}','";
-						}
-						$sGroupId = substr($sGroupId,0,-2);
-						$sGroupId .= ")";
-						$query="select * from \"group_info\" where id in {$sGroupId} ";
-						$Fetch = PDO_FetchAll($query);
-						foreach($Fetch as $group){
-							echo "<div><a href=\"group.php?list=project&group={$group["id"]}\">{$group["name"]}</a>";
-							echo "<a href=\"group.php?list=group_info&group={$group["id"]}\"> [详情]</a></div>";
-						}
-					}
-					break;
-				case "group_info":
-					echo "<div><a href=\"group.php?list=group\">返回Back</a></div>";
-					if(isset($_GET["group"])){
-						$group=$_GET["group"];
-					}
-					else{
-						$group="0";
-					}
-					$query="select * from \"group_info\" where id = '{$group}' ";
-					$Fetch = PDO_FetchAll($query);
-					$group_name=$Fetch[0]["name"];
-					if(count($Fetch)>0){
-						
-						
-						echo "<H2>{$group_name}</H2>";
-						echo "<table>";
-						echo "<tr><td>建立Create Time</td><td>{$Fetch[0]["create_time"]}</td></tr>";
-						echo "<tr><td>文件Files</td><td>{$Fetch[0]["file_number"]}</td></tr>";
-						echo "<tr><td>成员Member</td><td>{$Fetch[0]["member_number"]}</td></tr>";
-						$query="select user_id from \"group_member\" where group_id = '{$group}' ";
-						$Fetch = PDO_FetchAll($query);
-						$sUserId="('";
-						foreach($Fetch as $user){
-							$sUserId .= "{$user["user_id"]}','";
-						}
-						$sUserId = substr($sUserId,0,-2);
-						$sUserId .= ")";
-						
-						$query="select nickname from \"user\" where id in {$sUserId} ";
+        break;
+    case "project";
 
-						$userlist = PDO_FetchAll($query);	
-						
-						echo "<tr><td></td><td>";
-						foreach($userlist as $user){
-							echo "{$user["nickname"]}<br>";
-						}
-						echo "</td></tr>";
-						echo "</table>";
-					}
+        if (isset($_GET["group"])) {
+            $group = $_GET["group"];
+        } else {
+            $group = "0";
+        }
+        $query = "select group_name from \"group_member\" where group_id = \"{$group}\" AND user_id=\"{$UID}\"";
+        $group_name = PDO_FetchOne($query);
+        if ($group_name == "") {
+            $query = "select name from \"group_info\" where group_id = \"{$group}\" ";
+            $group_name = PDO_FetchOne($query);
+        }
 
-					break;
-				case "project";
+        echo "<div class='group_path'>";
+        echo "<a href='group.php?list=group'>群组Group</a> >> {$group_name}";
+        echo "</div>";
+        $query = "select file_id from \"group_file_power\" where group_id = \"{$group}\" AND user_id='{$UID}' group by file_id";
+        $Fetch = PDO_FetchAll($query);
+        $sFileId = "('";
+        foreach ($Fetch as $file) {
+            $sFileId .= "{$file["file_id"]}','";
+        }
+        $sFileId = substr($sFileId, 0, -2);
+        $sFileId .= ")";
+        $query = "select project , count(*) as co from \"group_file\" where id in {$sFileId} group by project";
+        $Fetch = PDO_FetchAll($query);
+        echo "<table>";
+        echo "<tr><td>Project</td><td>File Number</td></tr>";
+        foreach ($Fetch as $project) {
+            echo "<tr class='group_file_list'>";
+            echo "<td ><a href=\"group.php?list=file&group={$group}&project={$project["project"]}\">{$project["project"]}</a></td>";
+            echo "<td>{$project["co"]}</td> ";
+            echo "</tr>";
+        }
+        echo "</table>";
+        break;
+    case "file":
 
-					if(isset($_GET["group"])){
-						$group=$_GET["group"];
-					}
-					else{
-						$group="0";
-					}
-					$query="select group_name from \"group_member\" where group_id = \"{$group}\" AND user_id=\"{$UID}\"";
-					$group_name = PDO_FetchOne($query);
-					if($group_name == ""){
-						$query="select name from \"group_info\" where group_id = \"{$group}\" ";
-						$group_name = PDO_FetchOne($query);
-					}
-					
-					echo "<div class='group_path'>";
-					echo "<a href='group.php?list=group'>群组Group</a> >> {$group_name}";
-					echo "</div>";				
-					$query="select file_id from \"group_file_power\" where group_id = \"{$group}\" AND user_id='{$UID}' group by file_id";
-					$Fetch = PDO_FetchAll($query);
-					$sFileId="('";
-					foreach($Fetch as $file){
-						$sFileId .= "{$file["file_id"]}','";
-					}
-					$sFileId = substr($sFileId,0,-2);
-					$sFileId .= ")";
-					$query="select project , count(*) as co from \"group_file\" where id in {$sFileId} group by project";
-					$Fetch = PDO_FetchAll($query);
-					echo "<table>";
-					echo "<tr><td>Project</td><td>File Number</td></tr>";
-					foreach($Fetch as $project){
-						echo "<tr class='group_file_list'>";
-						echo "<td ><a href=\"group.php?list=file&group={$group}&project={$project["project"]}\">{$project["project"]}</a></td>";
-						echo "<td>{$project["co"]}</td> ";
-						echo "</tr>";
-					}	
-					echo "</table>";
-				break;
-				case "file":
+        if (isset($_GET["group"])) {
+            $group = $_GET["group"];
+        } else {
+            $group = "0";
+        }
+        if (isset($_GET["project"])) {
+            $project = $_GET["project"];
+        } else {
+            $project = "0";
+        }
+        $query = "select group_name from \"group_member\" where group_id = \"{$group}\" AND user_id=\"{$UID}\"";
+        $group_name = PDO_FetchOne($query);
+        if ($group_name == "") {
+            $query = "select name from \"group_info\" where group_id = \"{$group}\" ";
+            $group_name = PDO_FetchOne($query);
+        }
 
-					if(isset($_GET["group"])){
-						$group=$_GET["group"];
-					}
-					else{
-						$group="0";
-					}
-					if(isset($_GET["project"])){
-						$project=$_GET["project"];
-					}
-					else{
-						$project="0";
-					}
-					$query="select group_name from \"group_member\" where group_id = \"{$group}\" AND user_id=\"{$UID}\"";
-					$group_name = PDO_FetchOne($query);
-					if($group_name == ""){
-						$query="select name from \"group_info\" where group_id = \"{$group}\" ";
-						$group_name = PDO_FetchOne($query);
-					}
-					
-					echo "<div class='group_path'>";
-					echo "<a href='group.php?list=group'>群组Group</a> >> ";
-					echo "<a href=\"group.php?list=project&group={$group}\">{$group_name}</a> >> ";
-					echo "{$project}";
-					echo "</div>";
-					
-				?>
+        echo "<div class='group_path'>";
+        echo "<a href='group.php?list=group'>群组Group</a> >> ";
+        echo "<a href=\"group.php?list=project&group={$group}\">{$group_name}</a> >> ";
+        echo "{$project}";
+        echo "</div>";
+
+        ?>
 							<div  id="file_filter">
 				<div style="display:flex;justify-content: space-between;">
 					<div>
 						<select id="id_index_status"  onchange="showUserFilaList()">
 							<option value="all" >
-								<?php echo $_local->gui->all;//全部?>
+								<?php echo $_local->gui->all; //全部 ?>
 							</option>
 							<option value="share" >
-								<?php echo $_local->gui->shared;//已共享?>
+								<?php echo $_local->gui->shared; //已共享 ?>
 							</option>
 							<option value="recycle" >
-								<?php echo $_local->gui->recycle_bin;//回收站?>
+								<?php echo $_local->gui->recycle_bin; //回收站 ?>
 							</option>
-						</select>					
+						</select>
 					</div>
-					<div><?php echo $_local->gui->order_by;//排序方式?>
+					<div><?php echo $_local->gui->order_by; //排序方式 ?>
 						<select id="id_index_orderby"  onchange="showUserFilaList()">
-							<option value="accese_time" ><?php echo $_local->gui->accessed;//訪問?></option>
-							<option value="modify_time" ><?php echo $_local->gui->modified;//修改?></option>
-							<option value="create_time" ><?php echo $_local->gui->created;//創建?></option>
-							<option value="title" ><?php echo $_local->gui->title;//標題?></option>
-						</select>					
+							<option value="accese_time" ><?php echo $_local->gui->accessed; //訪問 ?></option>
+							<option value="modify_time" ><?php echo $_local->gui->modified; //修改 ?></option>
+							<option value="create_time" ><?php echo $_local->gui->created; //創建 ?></option>
+							<option value="title" ><?php echo $_local->gui->title; //標題 ?></option>
+						</select>
 						<select id="id_index_order"  onchange="showUserFilaList()">
-							<option value="DESC" ><?php echo $_local->gui->desc;//降序?></option>
-							<option value="ASC" ><?php echo $_local->gui->asc;;//升序?></option>
-						</select>	
+							<option value="DESC" ><?php echo $_local->gui->desc; //降序 ?></option>
+							<option value="ASC" ><?php echo $_local->gui->asc; //升序 ?></option>
+						</select>
 						<button id="file_select" onclick="mydoc_file_select(true)">
 							选择
 						</button>
 					</div>
 				</div>
 				<div>
-				<input id="keyword" type="input"  placeholder=<?php echo $_local->gui->title.$_local->gui->search;?>  onkeyup="file_search_keyup()"/>
+				<input id="keyword" type="input"  placeholder=<?php echo $_local->gui->title . $_local->gui->search; ?>  onkeyup="file_search_keyup()"/>
 				</div>
 
 			</div>
-			
+
 			<div id="file_tools" style="display:none;">
 				<div  style="display:flex;justify-content: space-between;">
 					<div>
 						<span id="button_group_nomal" >
-						<button onclick="file_del()"><?php echo $_local->gui->delete;//刪除?></button>
-						<button onclick="file_share(true)"><?php echo $_local->gui->share;//共享?></button>
-						<button onclick="file_share(false)"><?php echo $_local->gui->undo_shared;//取消共享?></button>
+						<button onclick="file_del()"><?php echo $_local->gui->delete; //刪除 ?></button>
+						<button onclick="file_share(true)"><?php echo $_local->gui->share; //共享 ?></button>
+						<button onclick="file_share(false)"><?php echo $_local->gui->undo_shared; //取消共享 ?></button>
 						</span>
 						<span id="button_group_recycle" style="dispaly:none">
-						<button onclick="file_remove()" style="background-color:red;"><?php echo $_local->gui->completely_delete;//彻底删除?></button>
-						<button onclick="file_remove_all()"><?php echo $_local->gui->empty_the_recycle_bin;//清空回收站?></button>
+						<button onclick="file_remove()" style="background-color:red;"><?php echo $_local->gui->completely_delete; //彻底删除 ?></button>
+						<button onclick="file_remove_all()"><?php echo $_local->gui->empty_the_recycle_bin; //清空回收站 ?></button>
 						</span>
 					</div>
 					<div>
-						<button onclick="mydoc_file_select(false)"><?php echo $_local->gui->cancel;//取消?></button>
+						<button onclick="mydoc_file_select(false)"><?php echo $_local->gui->cancel; //取消 ?></button>
 					</div>
 				</div>
 			</div>
-			
+
 				<?php
-					$query="select * from \"group_process\" where group_id = \"{$group}\" ";
-					$stage = PDO_FetchAll($query);
-					$aStage = array();
-					echo "<button>全部All</button>";
-					foreach($stage as $one){
-						$aStage[$one["stage"]]=$one["name"];
-						echo "<button>{$one["name"]}</button>";
-					}
-					
-					$query="select file_id from \"group_file_power\" where group_id = \"{$group}\" AND user_id='{$UID}' group by file_id";
-					$Fetch = PDO_FetchAll($query);
-					$sFileId="('";
-					foreach($Fetch as $file){
-						$sFileId .= "{$file["file_id"]}','";
-					}
-					$sFileId = substr($sFileId,0,-2);
-					$sFileId .= ")";
-					$query="select * from \"group_file\" where id in {$sFileId} AND project = \"{$project}\"";
-					$Fetch = PDO_FetchAll($query);
-					echo "<table>";
-					echo "<tr><td>Title</td><td>File Size</td><td>Date</td><td>Stage</td><td></td></tr>";
-					foreach($Fetch as $file){
-						echo "<tr class='group_file_list'>";
-						echo "<td class='group_file_title'><a href=\"group.php?list=stage&file={$file["id"]}\">{$file["file_title"]}</a></td>";
-						echo "<td>{$file["file_size"]}</td> ";
-						echo "<td>{$file["modify_time"]}</td> ";
-						$stage_name=$aStage["{$file["stage"]}"];
-						echo "<td><span class='tag'>{$stage_name}</span></td>";
-						echo "<td><a href=\"group.php?list=stage&file={$file["id"]}\">详情Details</a></td>";
-						echo "</tr>";
-					}	
-					echo "</table>";
-				break;
-				case "stage":
-					if(isset($_GET["file"])){
-						$file_id=$_GET["file"];
-					}
-					else{
-						$file_id="0";
-					}
-					$query="select * from \"group_file\" where id = {$file_id} ";
-					$Fetch = PDO_FetchAll($query);
-					$group_id=$Fetch[0]["group_id"];
-					$file_title=$Fetch[0]["file_title"];
-					$project = $Fetch[0]["project"];
-					$curr_stage=$Fetch[0]["stage"];
-					$query="select name from \"group_info\" where id = \"{$group_id}\" ";
-					$group_name = PDO_FetchOne($query);
-					$query="select group_name from \"group_member\" where group_id = \"{$group_id}\" AND user_id='{$UID}'  ";
-					$my_group_name = PDO_FetchOne($query);
-					if(empty($my_group_name)){
-						$my_group_name = $group_name;
-					}
-					$query="select * from \"group_process\" where group_id = \"{$group_id}\" ";
-					$stage = PDO_FetchAll($query);
-					echo "<div class='group_path'>";
-					echo "<a href=\"group.php?list=group\">群组Group</a> / ";
-					echo "<a href=\"group.php?list=project&group={$group_id}\">{$my_group_name}</a> / ";
-					echo "<a href=\"group.php?list=file&group={$group_id}&project={$project}\">{$project}</a>";
-					echo "</div>";
-					echo "<h2>{$file_title}</h2>";
-					foreach($stage as $one){
-						echo "<button>{$one["stage"]}</button>{$one["name"]}-";
-						if($one["stage"]<$curr_stage){
-							echo "<span style='color:green'>{$_local->gui->already_over}</span>";
-						}
-						else if($one["stage"]==$curr_stage){
-							echo "{$_local->gui->in_progress}<button>完成Done</button>";
-						}
-						else{
-							echo "尚未开始 Not Ready";
-						}
-						echo"<br>";
-					}	
-				break;
-			}
-			?>
+$query = "select * from \"group_process\" where group_id = \"{$group}\" ";
+        $stage = PDO_FetchAll($query);
+        $aStage = array();
+        echo "<button>全部All</button>";
+        foreach ($stage as $one) {
+            $aStage[$one["stage"]] = $one["name"];
+            echo "<button>{$one["name"]}</button>";
+        }
+
+        $query = "select file_id from \"group_file_power\" where group_id = \"{$group}\" AND user_id='{$UID}' group by file_id";
+        $Fetch = PDO_FetchAll($query);
+        $sFileId = "('";
+        foreach ($Fetch as $file) {
+            $sFileId .= "{$file["file_id"]}','";
+        }
+        $sFileId = substr($sFileId, 0, -2);
+        $sFileId .= ")";
+        $query = "select * from \"group_file\" where id in {$sFileId} AND project = \"{$project}\"";
+        $Fetch = PDO_FetchAll($query);
+        echo "<table>";
+        echo "<tr><td>Title</td><td>File Size</td><td>Date</td><td>Stage</td><td></td></tr>";
+        foreach ($Fetch as $file) {
+            echo "<tr class='group_file_list'>";
+            echo "<td class='group_file_title'><a href=\"group.php?list=stage&file={$file["id"]}\">{$file["file_title"]}</a></td>";
+            echo "<td>{$file["file_size"]}</td> ";
+            echo "<td>{$file["modify_time"]}</td> ";
+            $stage_name = $aStage["{$file["stage"]}"];
+            echo "<td><span class='tag'>{$stage_name}</span></td>";
+            echo "<td><a href=\"group.php?list=stage&file={$file["id"]}\">详情Details</a></td>";
+            echo "</tr>";
+        }
+        echo "</table>";
+        break;
+    case "stage":
+        if (isset($_GET["file"])) {
+            $file_id = $_GET["file"];
+        } else {
+            $file_id = "0";
+        }
+        $query = "select * from \"group_file\" where id = {$file_id} ";
+        $Fetch = PDO_FetchAll($query);
+        $group_id = $Fetch[0]["group_id"];
+        $file_title = $Fetch[0]["file_title"];
+        $project = $Fetch[0]["project"];
+        $curr_stage = $Fetch[0]["stage"];
+        $query = "select name from \"group_info\" where id = \"{$group_id}\" ";
+        $group_name = PDO_FetchOne($query);
+        $query = "select group_name from \"group_member\" where group_id = \"{$group_id}\" AND user_id='{$UID}'  ";
+        $my_group_name = PDO_FetchOne($query);
+        if (empty($my_group_name)) {
+            $my_group_name = $group_name;
+        }
+        $query = "select * from \"group_process\" where group_id = \"{$group_id}\" ";
+        $stage = PDO_FetchAll($query);
+        echo "<div class='group_path'>";
+        echo "<a href=\"group.php?list=group\">群组Group</a> / ";
+        echo "<a href=\"group.php?list=project&group={$group_id}\">{$my_group_name}</a> / ";
+        echo "<a href=\"group.php?list=file&group={$group_id}&project={$project}\">{$project}</a>";
+        echo "</div>";
+        echo "<h2>{$file_title}</h2>";
+        foreach ($stage as $one) {
+            echo "<button>{$one["stage"]}</button>{$one["name"]}-";
+            if ($one["stage"] < $curr_stage) {
+                echo "<span style='color:green'>{$_local->gui->already_over}</span>";
+            } else if ($one["stage"] == $curr_stage) {
+                echo "{$_local->gui->in_progress}<button>完成Done</button>";
+            } else {
+                echo "尚未开始 Not Ready";
+            }
+            echo "<br>";
+        }
+        break;
+}
+?>
 			</div>
-			
+
 		</div>
-		
+
 	</div>
 <div class="foot_div">
-<?php echo $_local->gui->poweredby;?>
+<?php echo $_local->gui->poweredby; ?>
 </div>
 </body>
 </html>

+ 38 - 40
app/group/group_del.php

@@ -3,47 +3,45 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
-$respond=array("status"=>0,"message"=>"");
-if(isset($_COOKIE["userid"]) && isset($_POST["groupid"])){
-	PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-	#TODO 先查是否有删除权限
-	$query="SELECT parent from group_info where id=? and creator=? ";
-	$gInfo = PDO_FetchRow($query,array($_POST["groupid"],$_COOKIE["userid"]));
-	if($gInfo){
-		#删除group info
-		$query="DELETE from group_info where id=? and creator=? ";
-		PDO_Execute($query,array($_POST["groupid"],$_COOKIE["userid"]));
-		#删除 组员
-		$query="DELETE from group_member where group_id=? ";
-		PDO_Execute($query,array($_POST["groupid"]));
-		#删除到此组的分享
+$respond = array("status" => 0, "message" => "");
+if (isset($_COOKIE["userid"]) && isset($_POST["groupid"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
+    #TODO 先查是否有删除权限
+    $query = "SELECT parent from group_info where id=? and creator=? ";
+    $gInfo = PDO_FetchRow($query, array($_POST["groupid"], $_COOKIE["userid"]));
+    if ($gInfo) {
+        #删除group info
+        $query = "DELETE from group_info where id=? and creator=? ";
+        PDO_Execute($query, array($_POST["groupid"], $_COOKIE["userid"]));
+        #删除 组员
+        $query = "DELETE from group_member where group_id=? ";
+        PDO_Execute($query, array($_POST["groupid"]));
+        #删除到此组的分享
 
-		#查询是否有子项目
-		$query="SELECT id from group_info where parent=? ";
-		$project = PDO_FetchAll($query,array($_POST["groupid"]));
-		if(count($project)){
-			$arrProject = array();
-			foreach ($project as $key => $value) {
-				# code...
-				$arrProject[] = $value["id"];
-			}
-			$place_holders = implode(',', array_fill(0, count($arrProject), '?'));
-			#删除 parent info
-			$query="DELETE from group_info where id IN ($place_holders) ";
-			PDO_Execute($query,$arrProject);
-			#删除 parent 组员
-			$query="DELETE from group_member where group_id IN ($place_holders) ";
-			PDO_Execute($query,$arrProject);
-			#删除到此组的分享
-		}
-	}
-	else{
-		$respond['status']=1;
-		$respond['message']="no power to delete ";
-		echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-		exit;
-	}
+        #查询是否有子项目
+        $query = "SELECT id from group_info where parent=? ";
+        $project = PDO_FetchAll($query, array($_POST["groupid"]));
+        if (count($project)) {
+            $arrProject = array();
+            foreach ($project as $key => $value) {
+                # code...
+                $arrProject[] = $value["id"];
+            }
+            $place_holders = implode(',', array_fill(0, count($arrProject), '?'));
+            #删除 parent info
+            $query = "DELETE from group_info where id IN ($place_holders) ";
+            PDO_Execute($query, $arrProject);
+            #删除 parent 组员
+            $query = "DELETE from group_member where group_id IN ($place_holders) ";
+            PDO_Execute($query, $arrProject);
+            #删除到此组的分享
+        }
+    } else {
+        $respond['status'] = 1;
+        $respond['message'] = "no power to delete ";
+        echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+        exit;
+    }
 }
 
 echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-?>

+ 5 - 9
app/group/list.php

@@ -6,13 +6,9 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
+//没有id 列出 我的群组
+PDO_Connect("" . _FILE_DB_GROUP_);
+$query = "SELECT group_name,group_id,power FROM group_member  WHERE level = 0 and user_id=?";
+$Fetch = PDO_FetchAll($query, array($_COOKIE["userid"]));
 
-	//没有id 列出 我的群组
-    PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-    $query = "SELECT group_name,group_id,power FROM group_member  WHERE level = 0 and user_id=?";
-	$Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
-	
-    echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
-
-
-?>
+echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);

+ 8 - 9
app/group/list_member.php

@@ -7,17 +7,16 @@ require_once '../public/function.php';
 require_once '../ucenter/function.php';
 
 $output = array();
-if(isset($_GET["id"])){
-    PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-    $id=$_GET["id"];
+if (isset($_GET["id"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
+    $id = $_GET["id"];
     $query = "SELECT user_id FROM group_member  WHERE group_id = ? ";
-	$output = PDO_FetchAll($query,array($id));
-	$userinfo = new UserInfo();
-	foreach ($output as $key => $value) {
-		# code...
+    $output = PDO_FetchAll($query, array($id));
+    $userinfo = new UserInfo();
+    foreach ($output as $key => $value) {
+        # code...
         $user = $userinfo->getName($value["user_id"]);
         $output[$key]["user_info"] = $user;
-	}
+    }
 }
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-?>

+ 1 - 1
app/group/member_del.php

@@ -11,7 +11,7 @@ if (!isset($_COOKIE["userid"])) {
     exit;
 }
 if (isset($_POST["groupid"])) {
-    PDO_Connect("sqlite:" . _FILE_DB_GROUP_);
+    PDO_Connect("" . _FILE_DB_GROUP_);
     $mypower = 100;
     # 先查是否有删人权限
     $query = "SELECT * from group_info where id=?";

+ 48 - 50
app/group/member_put.php

@@ -3,57 +3,55 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
-$respond=array("status"=>0,"message"=>"");
-if(isset($_COOKIE["userid"]) && isset($_POST["groupid"])){
-	PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-	#TODO 先查是否有加人权限
-	$query="SELECT power from group_member where user_id=? and group_id=? ";
-	$power = PDO_FetchRow($query,array($_COOKIE["userid"],$_POST["groupid"]));
-	if($power){
-		if($power["power"]>1){
-			$respond['status']=1;
-			$respond['message']="no power to add memeber";
-			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-			exit;
-		}
-	}
-	
-	$query="SELECT * from group_info where id=?";
-	$fc = PDO_FetchRow($query,array($_POST["groupid"]));
-	if($fc){
-		if($fc["parent"]==0){
-			$level = 0;
-		}
-		else{
-			$level = 1;
-			#子小组要插入两条记录 第一条插入父层级
-			$query="SELECT * from group_info where id=?";
-			$g_parent = PDO_FetchRow($query,array($fc["id"]));
-			$query="INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )  VALUES  (  ? , ? , ? , ? , ?  ,? ) ";
-			$sth = $PDO->prepare($query);
-			$sth->execute(array($_POST["userid"] ,$fc["parent"], 2 , $$g_parent["name"], 0 ,1 ));
-			$respond=array("status"=>0,"message"=>"");
-			if (!$sth || ($sth && $sth->errorCode() != 0)) {
-				$error = PDO_ErrorInfo();
-				$respond['status']=1;
-				$respond['message']=$error[2];
-			}
-		}
-	}
-	#查询这个
-	$query="SELECT * from group_info where id=?";
-	$g_curr = PDO_FetchRow($query,array($_POST["groupid"]));
+$respond = array("status" => 0, "message" => "");
+if (isset($_COOKIE["userid"]) && isset($_POST["groupid"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
+    #TODO 先查是否有加人权限
+    $query = "SELECT power from group_member where user_id=? and group_id=? ";
+    $power = PDO_FetchRow($query, array($_COOKIE["userid"], $_POST["groupid"]));
+    if ($power) {
+        if ($power["power"] > 1) {
+            $respond['status'] = 1;
+            $respond['message'] = "no power to add memeber";
+            echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+            exit;
+        }
+    }
 
-	$query="INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )  
+    $query = "SELECT * from group_info where id=?";
+    $fc = PDO_FetchRow($query, array($_POST["groupid"]));
+    if ($fc) {
+        if ($fc["parent"] == 0) {
+            $level = 0;
+        } else {
+            $level = 1;
+            #子小组要插入两条记录 第一条插入父层级
+            $query = "SELECT * from group_info where id=?";
+            $g_parent = PDO_FetchRow($query, array($fc["id"]));
+            $query = "INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )  VALUES  (  ? , ? , ? , ? , ?  ,? ) ";
+            $sth = $PDO->prepare($query);
+            $sth->execute(array($_POST["userid"], $fc["parent"], 2, $$g_parent["name"], 0, 1));
+            $respond = array("status" => 0, "message" => "");
+            if (!$sth || ($sth && $sth->errorCode() != 0)) {
+                $error = PDO_ErrorInfo();
+                $respond['status'] = 1;
+                $respond['message'] = $error[2];
+            }
+        }
+    }
+    #查询这个
+    $query = "SELECT * from group_info where id=?";
+    $g_curr = PDO_FetchRow($query, array($_POST["groupid"]));
+
+    $query = "INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )
 		VALUES  (  ? , ? , ? , ? , ?  ,? ) ";
-	$sth = $PDO->prepare($query);
-	$sth->execute(array($_POST["userid"] ,$_POST["groupid"], 2 , $g_curr["name"], $level ,1 ));
-	$respond=array("status"=>0,"message"=>"");
-	if (!$sth || ($sth && $sth->errorCode() != 0)) {
-		$error = PDO_ErrorInfo();
-		$respond['status']=1;
-		$respond['message']=$error[2];
-	}	
+    $sth = $PDO->prepare($query);
+    $sth->execute(array($_POST["userid"], $_POST["groupid"], 2, $g_curr["name"], $level, 1));
+    $respond = array("status" => 0, "message" => "");
+    if (!$sth || ($sth && $sth->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status'] = 1;
+        $respond['message'] = $error[2];
+    }
 }
 echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-?>

+ 29 - 31
app/group/my_group_put.php

@@ -4,39 +4,37 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
-$respond=array("status"=>0,"message"=>"");
-if(isset($_COOKIE["userid"])){
-	PDO_Connect("sqlite:"._FILE_DB_GROUP_);
-	$query="INSERT INTO group_info ( id,  parent  , name  , description ,  status , creator ,create_time )  
+$respond = array("status" => 0, "message" => "");
+if (isset($_COOKIE["userid"])) {
+    PDO_Connect("" . _FILE_DB_GROUP_);
+    $query = "INSERT INTO group_info ( id,  parent  , name  , description ,  status , creator ,create_time )
 	                       VALUES  ( ?, ? , ? , ? , ? , ?  ,? ) ";
-	$sth = $PDO->prepare($query);
-	$newid = UUID::v4();
-	$sth->execute(array( $newid,$_POST["parent"], $_POST["name"], "" ,1 ,$_COOKIE["userid"] , mTime() ));
-	$respond=array("status"=>0,"message"=>"");
-	if (!$sth || ($sth && $sth->errorCode() != 0)) {
-		$error = PDO_ErrorInfo();
-		$respond['status']=1;
-		$respond['message']=$error[2];
-	}	
+    $sth = $PDO->prepare($query);
+    $newid = UUID::v4();
+    $sth->execute(array($newid, $_POST["parent"], $_POST["name"], "", 1, $_COOKIE["userid"], mTime()));
+    $respond = array("status" => 0, "message" => "");
+    if (!$sth || ($sth && $sth->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status'] = 1;
+        $respond['message'] = $error[2];
+    }
 
-	$query="INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )  
+    $query = "INSERT INTO group_member (  user_id  , group_id  , power , group_name , level ,  status )
 		VALUES  (  ? , ? , ? , ? , ?  ,? ) ";
-	$sth = $PDO->prepare($query);
-	if($_POST["parent"]==0){
-		$level = 0;
-		$power = 0;
-	}
-	else{
-		$level = 1;
-		$power = 1;
-	}
-	$sth->execute(array($_COOKIE["userid"] ,$newid, $power , $_POST["name"], $level ,1 ));
-	$respond=array("status"=>0,"message"=>"");
-	if (!$sth || ($sth && $sth->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	$respond['status']=1;
-	$respond['message']=$error[2];
-	}
+    $sth = $PDO->prepare($query);
+    if ($_POST["parent"] == 0) {
+        $level = 0;
+        $power = 0;
+    } else {
+        $level = 1;
+        $power = 1;
+    }
+    $sth->execute(array($_COOKIE["userid"], $newid, $power, $_POST["name"], $level, 1));
+    $respond = array("status" => 0, "message" => "");
+    if (!$sth || ($sth && $sth->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status'] = 1;
+        $respond['message'] = $error[2];
+    }
 }
 echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-?>

+ 15 - 16
app/hostsetting/function.php

@@ -4,14 +4,16 @@ require_once '../path.php';
 class Hostsetting
 {
     public $dbh;
-    public function __construct() {
-        $dns = "sqlite:"._FILE_DB_HOSTSETTING_;
-        $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+    public function __construct()
+    {
+        $dns = "" . _FILE_DB_HOSTSETTING_;
+        $this->dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
     }
 
-    public function get($key){
-        if($this->dbh){
+    public function get($key)
+    {
+        if ($this->dbh) {
             $query = "SELECT value FROM setting WHERE key= ? ";
             $stmt = $this->dbh->prepare($query);
             $stmt->execute(array($key));
@@ -21,28 +23,25 @@ class Hostsetting
             } else {
                 return false;
             }
-        }
-        else{
+        } else {
             return false;
         }
     }
 
-    public function set($key,$value){
-        if($this->dbh){
+    public function set($key, $value)
+    {
+        if ($this->dbh) {
             $query = "UPDATE setting SET value = ?  WHERE key= ? ";
             $stmt = $this->dbh->prepare($query);
-            $stmt->execute(array($value,$key));
+            $stmt->execute(array($value, $key));
             if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
                 $error = PDO_ErrorInfo();
                 return false;
-            }
-            else{
+            } else {
                 return true;
             }
-        }
-        else{
+        } else {
             return false;
         }
     }
 }
-?>

+ 62 - 65
app/install/db_create.php

@@ -10,8 +10,8 @@ require_once "install_head.php";
 <p><a href="index.php">Home</a></p>
 <?php
 include "./_pdo.php";
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_create.php" method="get">
 From: <input type="text" name="from"><br>
 To: <input type="text" name="to"><br>
@@ -22,85 +22,82 @@ Res: <input type="text" name="res"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$res=$_GET["res"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$res = $_GET["res"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from - $to @ $res</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
-
-$dirLog=_DIR_LOG_."/";
 
-$dirDb="db/$res/";
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirXmlBase="xml/";
-$dirXml=$outputFileNameHead."/";
+$dirLog = _DIR_LOG_ . "/";
 
+$dirDb = "db/$res/";
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
 
+$dirXmlBase = "xml/";
+$dirXml = $outputFileNameHead . "/";
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
 
-$arrInserString=array();
-$db_file = $dirDb.$bookId."_".$res.".db3";
-PDO_Connect("sqlite:$db_file");
-switch($res){
-	case "translate":
-		$query="CREATE TABLE 'data' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'paragraph' INTEGER, 'language'  TEXT, 'anchor' TEXT, 'text' TEXT, 'author' TEXT, 'editor' TEXT, 'revision' TEXT, 'edition' INTEGER, 'subver' INTEGER,'time' DATETIME DEFAULT CURRENT_TIMESTAMP)";
-		break;
-	case "note":
-		$query="CREATE TABLE 'data' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'paragraph' INTEGER, 'language'  TEXT, 'anchor' TEXT, 'text' TEXT, 'author' TEXT, 'editor' TEXT, 'revision' TEXT, 'edition' INTEGER, 'subver' INTEGER,'time' DATETIME DEFAULT CURRENT_TIMESTAMP)";
-		break;
-	}
-	
-	$stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-        exit;
-    }
+$arrInserString = array();
+$db_file = $dirDb . $bookId . "_" . $res . ".db3";
+PDO_Connect("$db_file");
+switch ($res) {
+    case "translate":
+        $query = "CREATE TABLE 'data' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'paragraph' INTEGER, 'language'  TEXT, 'anchor' TEXT, 'text' TEXT, 'author' TEXT, 'editor' TEXT, 'revision' TEXT, 'edition' INTEGER, 'subver' INTEGER,'time' DATETIME DEFAULT CURRENT_TIMESTAMP)";
+        break;
+    case "note":
+        $query = "CREATE TABLE 'data' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'paragraph' INTEGER, 'language'  TEXT, 'anchor' TEXT, 'text' TEXT, 'author' TEXT, 'editor' TEXT, 'revision' TEXT, 'edition' INTEGER, 'subver' INTEGER,'time' DATETIME DEFAULT CURRENT_TIMESTAMP)";
+        break;
+}
 
-$query="CREATE INDEX 'search' ON \"data\" (\"paragraph\",\"language\",\"author\", \"editor\", \"revision\", \"edition\", \"subver\" , \"time\" )";
-    $stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-        $log=$log."$from, $FileName, error, $error[2] \r\n";
-    }
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+    exit;
+}
 
+$query = "CREATE INDEX 'search' ON \"data\" (\"paragraph\",\"language\",\"author\", \"editor\", \"revision\", \"edition\", \"subver\" , \"time\" )";
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+}
 
-	
-	$myLogFile = fopen($dirLog."create_db.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen($dirLog . "create_db.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_create.php?res=".$res."&from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_create.php?res=" . $res . "&from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 117 - 121
app/install/db_insert_bold.php

@@ -15,8 +15,8 @@ require_once "install_head.php";
 include "./_pdo.php";
 include "../path.php";
 
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_insert_bold.php" method="get">
 From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
@@ -26,157 +26,153 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
-function getWordEn($strIn){
-	$search  = array('ā', 'ī', 'ū', 'ṅ', 'ñ' , 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
-	$replace = array('a', 'i', 'u', 'n', 'n' , 't', 'd', 'n', 'l', 'm');
-	return(str_replace($search,$replace,$strIn));
+function getWordEn($strIn)
+{
+    $search = array('ā', 'ī', 'ū', 'ṅ', 'ñ', 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
+    $replace = array('a', 'i', 'u', 'n', 'n', 't', 'd', 'n', 'l', 'm');
+    return (str_replace($search, $replace, $strIn));
 }
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
 
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirLog=_DIR_LOG_;
+$dirLog = _DIR_LOG_;
 
 //输出文件夹
-$dirDb=_DIR_PALICANON_."/";
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
-
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirXml=$outputFileNameHead."/";
+$dirDb = _DIR_PALICANON_ . "/";
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
-$currChapter="";
-$currParNum="";
-$arrAllWords[0]=array("id","wid","book","paragraph","word","real","type","gramma","mean","note","part","partmean","bmc","bmt","un","style","vri","sya","si","ka","pi","pa","kam");
-$g_wordCounter=0;
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
+$currChapter = "";
+$currParNum = "";
+$arrAllWords[0] = array("id", "wid", "book", "paragraph", "word", "real", "type", "gramma", "mean", "note", "part", "partmean", "bmc", "bmt", "un", "style", "vri", "sya", "si", "ka", "pi", "pa", "kam");
+$g_wordCounter = 0;
 
-$arrUnPart[0]="word";
-$g_unPartCounter=-1;
+$arrUnPart[0] = "word";
+$g_unPartCounter = -1;
 
 /*去掉标点符号的统计*/
-$arrAllPaliWordsCount=array();
-$g_paliWordCounter=0;
-$g_wordCounterInSutta=0;
-$g_paliWordCountCounter=0;
-
+$arrAllPaliWordsCount = array();
+$g_paliWordCounter = 0;
+$g_wordCounterInSutta = 0;
+$g_paliWordCountCounter = 0;
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
 
-$arrInserString=array();
+$arrInserString = array();
 $db_file = _FILE_DB_BOLD_;
-PDO_Connect("sqlite:$db_file");
+PDO_Connect("$db_file");
 
 // 打开文件并读取数据
-if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		$params=$data;
-		$arrInserString[count($arrInserString)]=$params;
-	}
-	fclose($fp);
-	echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
-}
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        $params = $data;
+        $arrInserString[count($arrInserString)] = $params;
+    }
+    fclose($fp);
+    echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query="INSERT INTO bold ('id','book','paragraph','word','word2','word_en') VALUES (NULL,?,?,?,?,?)";
+$query = "INSERT INTO bold ('id','book','paragraph','word','word2','word_en') VALUES (NULL,?,?,?,?,?)";
 $stmt = $PDO->prepare($query);
-$allcount=1;
-$count=0;
-$count1=0;
-$sen="";
-$sen1="";
-$sen_en="";
-$sen_count=0;
-$book="";
-$paragraph="";
-foreach($arrInserString as $oneParam){
-	if($oneParam[15]=="bld" ){
-		if($oneParam[5]!=""){
-			$sen_count++;
-		}
-		$sen.=$oneParam[4]." ";
-		$sen1.=$oneParam[5]." ";
-		$book=substr($oneParam[2],1);
-		$paragraph=$oneParam[3];
-		if($oneParam[5]!=""){
-			$newWord=array($book,$paragraph,$oneParam[4],$oneParam[5],getWordEn($oneParam[5]));
-			$stmt->execute($newWord);
-			$count++;
-			$allcount++;
-		}
-	}
-	else{
-		if($sen_count>1){
-			$sen=rtrim($sen);
-			$sen1=rtrim($sen1);
-			$sen_en=getWordEn($sen1);			
-			$newWord=array($book,$paragraph,$sen,$sen1,$sen_en);
-			$stmt->execute($newWord);
-			$count1++;		
-			$allcount++;
-			$sen="";
-			$sen1="";
-			$sen_en="";			
-			$sen_count=0;
-		}
-		else{	
-			$sen="";
-			$sen1="";
-			$sen_en="";			
-			$sen_count=0;
-		}
-	}
+$allcount = 1;
+$count = 0;
+$count1 = 0;
+$sen = "";
+$sen1 = "";
+$sen_en = "";
+$sen_count = 0;
+$book = "";
+$paragraph = "";
+foreach ($arrInserString as $oneParam) {
+    if ($oneParam[15] == "bld") {
+        if ($oneParam[5] != "") {
+            $sen_count++;
+        }
+        $sen .= $oneParam[4] . " ";
+        $sen1 .= $oneParam[5] . " ";
+        $book = substr($oneParam[2], 1);
+        $paragraph = $oneParam[3];
+        if ($oneParam[5] != "") {
+            $newWord = array($book, $paragraph, $oneParam[4], $oneParam[5], getWordEn($oneParam[5]));
+            $stmt->execute($newWord);
+            $count++;
+            $allcount++;
+        }
+    } else {
+        if ($sen_count > 1) {
+            $sen = rtrim($sen);
+            $sen1 = rtrim($sen1);
+            $sen_en = getWordEn($sen1);
+            $newWord = array($book, $paragraph, $sen, $sen1, $sen_en);
+            $stmt->execute($newWord);
+            $count1++;
+            $allcount++;
+            $sen = "";
+            $sen1 = "";
+            $sen_en = "";
+            $sen_count = 0;
+        } else {
+            $sen = "";
+            $sen1 = "";
+            $sen_en = "";
+            $sen_count = 0;
+        }
+    }
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	echo "updata $count-$count1 recorders.";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    echo "updata $count-$count1 recorders.";
 }
 
-	$myLogFile = fopen($dirLog."insert_bold.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen($dirLog . "insert_bold.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_bold.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_bold.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 58 - 62
app/install/db_insert_bookword_from_csv.php

@@ -10,8 +10,8 @@ require_once "install_head.php";
 <?php
 include "./_pdo.php";
 include "../path.php";
-if(isset($_GET["from"])==false){
-?>
+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>
@@ -21,81 +21,77 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
+$from = $_GET["from"];
+$to = $_GET["to"];
 
-$dirLog=_DIR_LOG_."/";
-$dirXmlBase=_DIR_PALI_CSV_."/";
+$dirLog = _DIR_LOG_ . "/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$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));
+$dns = "" . _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++;
-		}        
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
     }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
+}
 
-		// 开始一个事务,关闭自动提交
-		$dbh_word_index->beginTransaction();
-		$query="INSERT INTO bookword ('book','wordindex','count') VALUES ( ? , ? , ?  )";
-		$stmt = $dbh_word_index->prepare($query);
+$bookword = array();
 
-        foreach ($bookword as $key => $value) {
-            $stmt->execute(array($book,$key,$value));
+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;
         }
-		// 提交更改 
-		$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";
-		}		
-
 
+        $count++;
+    }
+}
 
-	$myLogFile = fopen($dirLog."insert_index.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
-	
+// 开始一个事务,关闭自动提交
+$dbh_word_index->beginTransaction();
+$query = "INSERT INTO bookword ('book','wordindex','count') VALUES ( ? , ? , ?  )";
+$stmt = $dbh_word_index->prepare($query);
 
-if($from>=$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
+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";
 }
-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];
+
+$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>

+ 258 - 279
app/install/db_insert_index.php

@@ -11,8 +11,8 @@ require_once "install_head.php";
 <?php
 include "./_pdo.php";
 include "../path.php";
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_insert_index.php" method="get">
 From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
@@ -22,318 +22,297 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-
-
+$from = $_GET["from"];
+$to = $_GET["to"];
 
-$dirLog=_DIR_LOG_."/";
-$dirDb="db/";
-$dirXmlBase=_DIR_PALI_CSV_."/";
+$dirLog = _DIR_LOG_ . "/";
+$dirDb = "db/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
 //已经存在的词
-$g_wordCounter=0;
-$g_wordIndexCounter=0;
-$iAllWordIndex=array();
-$sAllWord=array();
+$g_wordCounter = 0;
+$g_wordIndexCounter = 0;
+$iAllWordIndex = array();
+$sAllWord = array();
 //新加入的词
 $wordindex_max_index = 0;
 $aNewWordIndex = array(); //词内容
 $sNewWord = array(); //词头索引
 
 global $dbh_word_index;
-$dns = "sqlite:"._FILE_DB_WORD_INDEX_;
-$dbh_word_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_WORD_INDEX_;
+$dbh_word_index = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_word_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 $query = "select id from wordindex where 1 order by id DESC ";
-	$stmt = $dbh_word_index->prepare($query);
-	$stmt->execute(array());
-	$id  = $stmt->fetch(PDO::FETCH_ASSOC);
-	if($id === FALSE){
-		$wordindex_max_index = 0;
-	}
-	else{
-		$wordindex_max_index =$id["id"];
-	}
-	$db_file = _FILE_DB_PALI_INDEX_;
-	PDO_Connect("sqlite:$db_file");
-	$query = "select id from word where 1 order by id DESC ";
-	$stmt = $PDO->prepare($query);
-	$stmt->execute(array());
-	$id  = $stmt->fetch(PDO::FETCH_ASSOC);	
-	if($id === FALSE){
-		$g_wordCounter = 0;
-	}
-	else{
-		$g_wordCounter = $id["id"];
-	}
-function dict_lookup($word){
-	global $dbh_word_index;
-	$query = "select * from wordindex where \"word\" = ? ";
-	$stmt = $dbh_word_index->prepare($query);
-	$stmt->execute(array($word));
-    return $stmt->fetch(PDO::FETCH_ASSOC);	
+$stmt = $dbh_word_index->prepare($query);
+$stmt->execute(array());
+$id = $stmt->fetch(PDO::FETCH_ASSOC);
+if ($id === false) {
+    $wordindex_max_index = 0;
+} else {
+    $wordindex_max_index = $id["id"];
 }
-
-function getWordEn($strIn){
-	$out=$strIn;
-	$out=str_replace("ā","a",$out);
-	$out=str_replace("ī","i",$out);
-	$out=str_replace("ū","u",$out);
-	$out=str_replace("ṅ","n",$out);
-	$out=str_replace("ñ","n",$out);
-	$out=str_replace("ṭ","t",$out);
-	$out=str_replace("ḍ","d",$out);
-	$out=str_replace("ṇ","n",$out);
-	$out=str_replace("ḷ","l",$out);
-	$out=str_replace("ṃ","m",$out);
-	return($out);
+$db_file = _FILE_DB_PALI_INDEX_;
+PDO_Connect("$db_file");
+$query = "select id from word where 1 order by id DESC ";
+$stmt = $PDO->prepare($query);
+$stmt->execute(array());
+$id = $stmt->fetch(PDO::FETCH_ASSOC);
+if ($id === false) {
+    $g_wordCounter = 0;
+} else {
+    $g_wordCounter = $id["id"];
+}
+function dict_lookup($word)
+{
+    global $dbh_word_index;
+    $query = "select * from wordindex where \"word\" = ? ";
+    $stmt = $dbh_word_index->prepare($query);
+    $stmt->execute(array($word));
+    return $stmt->fetch(PDO::FETCH_ASSOC);
 }
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+function getWordEn($strIn)
+{
+    $out = $strIn;
+    $out = str_replace("ā", "a", $out);
+    $out = str_replace("ī", "i", $out);
+    $out = str_replace("ū", "u", $out);
+    $out = str_replace("ṅ", "n", $out);
+    $out = str_replace("ñ", "n", $out);
+    $out = str_replace("ṭ", "t", $out);
+    $out = str_replace("ḍ", "d", $out);
+    $out = str_replace("ṇ", "n", $out);
+    $out = str_replace("ḷ", "l", $out);
+    $out = str_replace("ṃ", "m", $out);
+    return ($out);
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
 
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
+}
 
-	
 //for($iFile=$from;$iFile<=$to;$iFile++)
-$iFile=$from;
+$iFile = $from;
 {
 
-	$FileName=$filelist[$iFile][1].".htm";
-	$fileId=$filelist[$iFile][0];
-
-	$inputFileName=$FileName;
-	$outputFileNameHead=$filelist[$iFile][1];
-	$bookId=$filelist[$iFile][2];
-
-	$dirXml=$outputFileNameHead."/";
-
-	$xmlfile = $inputFileName;
-	echo "doing:".$xmlfile."<br>";
-	$log=$log."$iFile,$FileName,open\r\n";
-
-	$arrInserString=array();
-
-	// 打开文件并读取数据
-	$irow=0;
-	if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-		while(($data=fgetcsv($fp,0,','))!==FALSE){
-			$irow++;
-			if($irow>1){
-				$params=$data;
-				$arrInserString[]=$params;
-			}
-		}
-		fclose($fp);
-		echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
-	}
-	else{
-		echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
-	}
-	
-
-	// 开始一个事务,关闭自动提交
-	$PDO->beginTransaction();
-	$query="INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
-	$stmt = $PDO->prepare($query);
-	$count=0;
-	$count1=0;
-	$sen="";
-	$sen1="";
-	$sen_en="";
-	$sen_count=0;
-	$book="";
-	$paragraph="";
-	foreach($arrInserString as $oneParam){
-		if($oneParam[5]!=""){
-			$g_wordCounter++;
-			$book=substr($oneParam[2],1);
-			$paragraph=$oneParam[3];
-			$word=$oneParam[5];
-			if($oneParam[15]=="bld" ){
-				$bold=1;
-			}
-			else{
-				$bold=0;
-			}			
-			
-			if(isset($sAllWord[$word])){
-				//已经存在的词
-				$wordindex=$sAllWord[$word];
-				
-				$iAllWordIndex[$wordindex][1]++;
-				if($bold==1){
-					$iAllWordIndex[$wordindex][3]++;
-				}
-				else{
-					$iAllWordIndex[$wordindex][2]++;
-				}
-				
-			}
-			else if(isset($sNewWord[$word])){
-				//是新家入的词
-				$wordindex=$sNewWord[$word];
-				
-				$aNewWordIndex[$wordindex][1]++;
-				if($bold==1){
-					$aNewWordIndex[$wordindex][3]++;
-				}
-				else{
-					$aNewWordIndex[$wordindex][2]++;
-				}
-			}
-			else if(($lookup=dict_lookup($word)) !== FALSE){
-				//在数据库中找到
-				$wordindex=$lookup["id"];
-				$sAllWord[$word]=$wordindex;
-				$iAllWordIndex[$wordindex][0]=$word;
-				
-				$iAllWordIndex[$wordindex][1]=$lookup["count"] + 1;//all word count
-				if($bold==1){
-					$iAllWordIndex[$wordindex][2] = $lookup["normal"] ;
-					$iAllWordIndex[$wordindex][3] = $lookup["bold"] + 1;
-				}
-				else{
-					$iAllWordIndex[$wordindex][2] = $lookup["normal"] + 1;
-					$iAllWordIndex[$wordindex][3] = $lookup["bold"] ;
-				}
-			}
-			else{
-				//数据库里也没找到 怎么办呢?我想呀想 想呀想
-				$wordindex=$wordindex_max_index + 1;
-				$sNewWord[$word]=$wordindex;
-				
-				$aNewWordIndex[$wordindex][0]=$word;
-				
-				$aNewWordIndex[$wordindex][1]=1;//all word count
-				if($bold==1){
-					$aNewWordIndex[$wordindex][2]=0;
-					$aNewWordIndex[$wordindex][3]=1;
-				}
-				else{
-					$aNewWordIndex[$wordindex][2]=1;
-					$aNewWordIndex[$wordindex][3]=0;
-				}
-				
-				$wordindex_max_index++;
-			}
-		
-	
-			$newWord=array($g_wordCounter,$book,$paragraph,$wordindex,$bold);
-			$stmt->execute($newWord);
-			$count++;
-		}
-
-	}
-	
-	// 提交更改 
-	$PDO->commit();
-	if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-		$error = PDO_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";
-	}
+    $FileName = $filelist[$iFile][1] . ".htm";
+    $fileId = $filelist[$iFile][0];
+
+    $inputFileName = $FileName;
+    $outputFileNameHead = $filelist[$iFile][1];
+    $bookId = $filelist[$iFile][2];
+
+    $dirXml = $outputFileNameHead . "/";
+
+    $xmlfile = $inputFileName;
+    echo "doing:" . $xmlfile . "<br>";
+    $log = $log . "$iFile,$FileName,open\r\n";
+
+    $arrInserString = array();
+
+    // 打开文件并读取数据
+    $irow = 0;
+    if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+        while (($data = fgetcsv($fp, 0, ',')) !== false) {
+            $irow++;
+            if ($irow > 1) {
+                $params = $data;
+                $arrInserString[] = $params;
+            }
+        }
+        fclose($fp);
+        echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+    } else {
+        echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
+    }
+
+    // 开始一个事务,关闭自动提交
+    $PDO->beginTransaction();
+    $query = "INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
+    $stmt = $PDO->prepare($query);
+    $count = 0;
+    $count1 = 0;
+    $sen = "";
+    $sen1 = "";
+    $sen_en = "";
+    $sen_count = 0;
+    $book = "";
+    $paragraph = "";
+    foreach ($arrInserString as $oneParam) {
+        if ($oneParam[5] != "") {
+            $g_wordCounter++;
+            $book = substr($oneParam[2], 1);
+            $paragraph = $oneParam[3];
+            $word = $oneParam[5];
+            if ($oneParam[15] == "bld") {
+                $bold = 1;
+            } else {
+                $bold = 0;
+            }
+
+            if (isset($sAllWord[$word])) {
+                //已经存在的词
+                $wordindex = $sAllWord[$word];
+
+                $iAllWordIndex[$wordindex][1]++;
+                if ($bold == 1) {
+                    $iAllWordIndex[$wordindex][3]++;
+                } else {
+                    $iAllWordIndex[$wordindex][2]++;
+                }
+
+            } else if (isset($sNewWord[$word])) {
+                //是新家入的词
+                $wordindex = $sNewWord[$word];
+
+                $aNewWordIndex[$wordindex][1]++;
+                if ($bold == 1) {
+                    $aNewWordIndex[$wordindex][3]++;
+                } else {
+                    $aNewWordIndex[$wordindex][2]++;
+                }
+            } else if (($lookup = dict_lookup($word)) !== false) {
+                //在数据库中找到
+                $wordindex = $lookup["id"];
+                $sAllWord[$word] = $wordindex;
+                $iAllWordIndex[$wordindex][0] = $word;
+
+                $iAllWordIndex[$wordindex][1] = $lookup["count"] + 1; //all word count
+                if ($bold == 1) {
+                    $iAllWordIndex[$wordindex][2] = $lookup["normal"];
+                    $iAllWordIndex[$wordindex][3] = $lookup["bold"] + 1;
+                } else {
+                    $iAllWordIndex[$wordindex][2] = $lookup["normal"] + 1;
+                    $iAllWordIndex[$wordindex][3] = $lookup["bold"];
+                }
+            } else {
+                //数据库里也没找到 怎么办呢?我想呀想 想呀想
+                $wordindex = $wordindex_max_index + 1;
+                $sNewWord[$word] = $wordindex;
+
+                $aNewWordIndex[$wordindex][0] = $word;
+
+                $aNewWordIndex[$wordindex][1] = 1; //all word count
+                if ($bold == 1) {
+                    $aNewWordIndex[$wordindex][2] = 0;
+                    $aNewWordIndex[$wordindex][3] = 1;
+                } else {
+                    $aNewWordIndex[$wordindex][2] = 1;
+                    $aNewWordIndex[$wordindex][3] = 0;
+                }
+
+                $wordindex_max_index++;
+            }
+
+            $newWord = array($g_wordCounter, $book, $paragraph, $wordindex, $bold);
+            $stmt->execute($newWord);
+            $count++;
+        }
+
+    }
+
+    // 提交更改
+    $PDO->commit();
+    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+        $error = PDO_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";
+    }
 
 }
 //更新单词索引表
 
 //首先插入新的词
-	// 开始一个事务,关闭自动提交
-	$dbh_word_index->beginTransaction();
-	$query="INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES ( ? , ? , ? , ? , ? , ? , ? , ? )";
-	$stmt = $dbh_word_index->prepare($query);
-	
-	echo "INSERT:".count($aNewWordIndex)."words<br>";
-	foreach($aNewWordIndex as $wIndex => $info){
-		$wordindex=$iword;
-		$newWord=array(
-								$wIndex,
-								$info[0],
-								getWordEn($info[0]),
-								$info[1],
-								$info[2],
-								$info[3],
-								0,
-								mb_strlen($info[0],"UTF-8")
-							);
-		$stmt->execute($newWord);
-	}
-	// 提交更改 
-	$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 iword recorders.<br />";
-		$log.="updata iword recorders.\r\n";
-	}
-	
+// 开始一个事务,关闭自动提交
+$dbh_word_index->beginTransaction();
+$query = "INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES ( ? , ? , ? , ? , ? , ? , ? , ? )";
+$stmt = $dbh_word_index->prepare($query);
+
+echo "INSERT:" . count($aNewWordIndex) . "words<br>";
+foreach ($aNewWordIndex as $wIndex => $info) {
+    $wordindex = $iword;
+    $newWord = array(
+        $wIndex,
+        $info[0],
+        getWordEn($info[0]),
+        $info[1],
+        $info[2],
+        $info[3],
+        0,
+        mb_strlen($info[0], "UTF-8"),
+    );
+    $stmt->execute($newWord);
+}
+// 提交更改
+$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 iword recorders.<br />";
+    $log .= "updata iword recorders.\r\n";
+}
 
 //然后修改已经有的词
-	// 开始一个事务,关闭自动提交
-	$dbh_word_index->beginTransaction();
-	$query="UPDATE wordindex SET count = ? , normal = ? , bold = ?   where  id = ?  ";
-	$stmt = $dbh_word_index->prepare($query);
-	
-	echo "UPDATE:".count($iAllWordIndex)."words<br>";
-	foreach($iAllWordIndex as $wIndex => $info){
-		$wordindex=$iword;
-		$newWord=array(
-								$info[1],
-								$info[2],
-								$info[3],
-								$wIndex
-							);
-		$stmt->execute($newWord);
-	}
-	// 提交更改 
-	$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 iword recorders.<br />";
-		$log.="updata iword recorders.\r\n";
-	}
-
-
-
-	$myLogFile = fopen($dirLog."insert_index.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
-	
+// 开始一个事务,关闭自动提交
+$dbh_word_index->beginTransaction();
+$query = "UPDATE wordindex SET count = ? , normal = ? , bold = ?   where  id = ?  ";
+$stmt = $dbh_word_index->prepare($query);
+
+echo "UPDATE:" . count($iAllWordIndex) . "words<br>";
+foreach ($iAllWordIndex as $wIndex => $info) {
+    $wordindex = $iword;
+    $newWord = array(
+        $info[1],
+        $info[2],
+        $info[3],
+        $wIndex,
+    );
+    $stmt->execute($newWord);
+}
+// 提交更改
+$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 iword recorders.<br />";
+    $log .= "updata iword recorders.\r\n";
+}
+
+$myLogFile = fopen($dirLog . "insert_index.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 
 ?>
 
 
-<?php 
+<?php
 
-if($from>=$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_index.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+if ($from >= $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_index.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 193 - 207
app/install/db_insert_index_once.php

@@ -2,227 +2,213 @@
 require_once "install_head.php";
 include "./_pdo.php";
 
-if (PHP_SAPI  == "cli") {
-	echo $argc;
-	if($argc>=3){
-		$from=$argv[1];
-		$to=$argv[2];
-		echo "From: {$from} To:{$to}";
-	}
-	else if($argc>=1){
-		$from=0;
-		$to = 216;
-		echo "生成全部217本书";
-	}
-	else{
-		echo "参数错误";
-		exit;
-	}
-
-}
-else{
-	echo "<!DOCTYPE html><html><head></head>";
-	echo "<body><h2>Insert to Index</h2>";
-
-	if(isset($_GET["from"])==false){
-		echo '<form action="db_insert_index_once.php" method="get">';
-		echo 'From: <input type="text" name="from" value="0"><br>';
-		echo 'To: <input type="text" name="to" value="216"><br>';
-		echo '<input type="submit">';
-		echo '</form>';
-		exit;
-	}
-	else{
-		$from=$_GET["from"];
-		$to=$_GET["to"];
-	}
+if (PHP_SAPI == "cli") {
+    echo $argc;
+    if ($argc >= 3) {
+        $from = $argv[1];
+        $to = $argv[2];
+        echo "From: {$from} To:{$to}";
+    } else if ($argc >= 1) {
+        $from = 0;
+        $to = 216;
+        echo "生成全部217本书";
+    } else {
+        echo "参数错误";
+        exit;
+    }
+
+} else {
+    echo "<!DOCTYPE html><html><head></head>";
+    echo "<body><h2>Insert to Index</h2>";
+
+    if (isset($_GET["from"]) == false) {
+        echo '<form action="db_insert_index_once.php" method="get">';
+        echo 'From: <input type="text" name="from" value="0"><br>';
+        echo 'To: <input type="text" name="to" value="216"><br>';
+        echo '<input type="submit">';
+        echo '</form>';
+        exit;
+    } else {
+        $from = $_GET["from"];
+        $to = $_GET["to"];
+    }
 }
 
+$g_wordCounter = 0;
+$g_wordIndexCounter = 0;
+$iAllWordIndex = array();
+$sAllWord = array();
 
-$g_wordCounter=0;
-$g_wordIndexCounter=0;
-$iAllWordIndex=array();
-$sAllWord=array();
-
-$dirLog=_DIR_LOG_."/";
+$dirLog = _DIR_LOG_ . "/";
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
-function getWordEn($strIn){
-	$out=$strIn;
-	$out=str_replace("ā","a",$out);
-	$out=str_replace("ī","i",$out);
-	$out=str_replace("ū","u",$out);
-	$out=str_replace("ṅ","n",$out);
-	$out=str_replace("ñ","n",$out);
-	$out=str_replace("ṭ","t",$out);
-	$out=str_replace("ḍ","d",$out);
-	$out=str_replace("ṇ","n",$out);
-	$out=str_replace("ḷ","l",$out);
-	$out=str_replace("ṃ","m",$out);
-	return($out);
+function getWordEn($strIn)
+{
+    $out = $strIn;
+    $out = str_replace("ā", "a", $out);
+    $out = str_replace("ī", "i", $out);
+    $out = str_replace("ū", "u", $out);
+    $out = str_replace("ṅ", "n", $out);
+    $out = str_replace("ñ", "n", $out);
+    $out = str_replace("ṭ", "t", $out);
+    $out = str_replace("ḍ", "d", $out);
+    $out = str_replace("ṇ", "n", $out);
+    $out = str_replace("ḷ", "l", $out);
+    $out = str_replace("ṃ", "m", $out);
+    return ($out);
 }
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
+}
+
+$db_file = _FILE_DB_INDEX_;
+PDO_Connect("$db_file");
 
-	$db_file = _FILE_DB_INDEX_;
-	PDO_Connect("sqlite:$db_file");
-	
-for($iFile=$from;$iFile<=$to;$iFile++){
+for ($iFile = $from; $iFile <= $to; $iFile++) {
     echo "<h3>{$iFile}</h3>";
-	$FileName=$filelist[$iFile][1].".htm";
-	$fileId=$filelist[$iFile][0];
-
-	$inputFileName=$FileName;
-	$outputFileNameHead=$filelist[$iFile][1];
-	$bookId=$filelist[$iFile][2];
-
-	$dirXml=$outputFileNameHead."/";
-
-	$xmlfile = $inputFileName;
-	echo "doing:".$xmlfile."<br>";
-	$log=$log."$iFile,$FileName,open\r\n";
-
-	$arrInserString=array();
-
-
-	// 打开文件并读取数据
-	$irow=0;
-	if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-		while(($data=fgetcsv($fp,0,','))!==FALSE){
-			$irow++;
-			if($irow>1){
-				$params=$data;
-				$arrInserString[count($arrInserString)]=$params;
-			}
-		}
-		fclose($fp);
-		echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
-	}
-	else{
-		echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
-	}
-	
-
-	// 开始一个事务,关闭自动提交
-	$PDO->beginTransaction();
-	$query="INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
-	$stmt = $PDO->prepare($query);
-	$count=0;
-	$count1=0;
-	$sen="";
-	$sen1="";
-	$sen_en="";
-	$sen_count=0;
-	$book="";
-	$paragraph="";
-	foreach($arrInserString as $oneParam){	
-		if($oneParam[5]!=""){
-			$g_wordCounter++;
-			$book=substr($oneParam[2],1);
-			$paragraph=$oneParam[3];
-			$word=$oneParam[5];
-			if($oneParam[15]=="bld" ){
-				$bold=1;
-			}
-			else{
-				$bold=0;
-			}			
-			
-			if(isset($sAllWord[$word])){
-				$wordindex=$sAllWord[$word];
-				
-				$iAllWordIndex[$wordindex][1]++;
-				if($bold==1){
-					$iAllWordIndex[$wordindex][3]++;
-				}
-				else{
-					$iAllWordIndex[$wordindex][2]++;
-				}
-				
-			}
-			else{
-				$wordindex=$g_wordIndexCounter;
-				$sAllWord[$word]=$g_wordIndexCounter;
-				
-				$iAllWordIndex[$g_wordIndexCounter][0]=$word;
-				
-				$iAllWordIndex[$g_wordIndexCounter][1]=1;//all word count
-				if($bold==1){
-					$iAllWordIndex[$g_wordIndexCounter][2]=0;
-					$iAllWordIndex[$g_wordIndexCounter][3]=1;
-				}
-				else{
-					$iAllWordIndex[$g_wordIndexCounter][2]=1;
-					$iAllWordIndex[$g_wordIndexCounter][3]=0;
-				}
-				
-				$g_wordIndexCounter++;
-			}
-		
-	
-			$newWord=array($g_wordCounter,$book,$paragraph,$wordindex,$bold);
-			$stmt->execute($newWord);
-			$count++;
-		}
-
-	}
-	
-	// 提交更改 
-	$PDO->commit();
-	if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-		$error = PDO_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";
-	}
+    $FileName = $filelist[$iFile][1] . ".htm";
+    $fileId = $filelist[$iFile][0];
+
+    $inputFileName = $FileName;
+    $outputFileNameHead = $filelist[$iFile][1];
+    $bookId = $filelist[$iFile][2];
+
+    $dirXml = $outputFileNameHead . "/";
+
+    $xmlfile = $inputFileName;
+    echo "doing:" . $xmlfile . "<br>";
+    $log = $log . "$iFile,$FileName,open\r\n";
+
+    $arrInserString = array();
+
+    // 打开文件并读取数据
+    $irow = 0;
+    if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+        while (($data = fgetcsv($fp, 0, ',')) !== false) {
+            $irow++;
+            if ($irow > 1) {
+                $params = $data;
+                $arrInserString[count($arrInserString)] = $params;
+            }
+        }
+        fclose($fp);
+        echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+    } else {
+        echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
+    }
+
+    // 开始一个事务,关闭自动提交
+    $PDO->beginTransaction();
+    $query = "INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
+    $stmt = $PDO->prepare($query);
+    $count = 0;
+    $count1 = 0;
+    $sen = "";
+    $sen1 = "";
+    $sen_en = "";
+    $sen_count = 0;
+    $book = "";
+    $paragraph = "";
+    foreach ($arrInserString as $oneParam) {
+        if ($oneParam[5] != "") {
+            $g_wordCounter++;
+            $book = substr($oneParam[2], 1);
+            $paragraph = $oneParam[3];
+            $word = $oneParam[5];
+            if ($oneParam[15] == "bld") {
+                $bold = 1;
+            } else {
+                $bold = 0;
+            }
+
+            if (isset($sAllWord[$word])) {
+                $wordindex = $sAllWord[$word];
+
+                $iAllWordIndex[$wordindex][1]++;
+                if ($bold == 1) {
+                    $iAllWordIndex[$wordindex][3]++;
+                } else {
+                    $iAllWordIndex[$wordindex][2]++;
+                }
+
+            } else {
+                $wordindex = $g_wordIndexCounter;
+                $sAllWord[$word] = $g_wordIndexCounter;
+
+                $iAllWordIndex[$g_wordIndexCounter][0] = $word;
+
+                $iAllWordIndex[$g_wordIndexCounter][1] = 1; //all word count
+                if ($bold == 1) {
+                    $iAllWordIndex[$g_wordIndexCounter][2] = 0;
+                    $iAllWordIndex[$g_wordIndexCounter][3] = 1;
+                } else {
+                    $iAllWordIndex[$g_wordIndexCounter][2] = 1;
+                    $iAllWordIndex[$g_wordIndexCounter][3] = 0;
+                }
+
+                $g_wordIndexCounter++;
+            }
+
+            $newWord = array($g_wordCounter, $book, $paragraph, $wordindex, $bold);
+            $stmt->execute($newWord);
+            $count++;
+        }
+
+    }
+
+    // 提交更改
+    $PDO->commit();
+    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+        $error = PDO_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";
+    }
 
 }
 
-	// 开始一个事务,关闭自动提交
-	$PDO->beginTransaction();
-	$query="INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES (?,?,?,?,?,?,?,?)";
-	$stmt = $PDO->prepare($query);
-	
-	echo count($iAllWordIndex)."words<br>";
-	for($iword=0;$iword<count($iAllWordIndex);$iword++){
-		$wordindex=$iword;
-		$newWord=array($wordindex,$iAllWordIndex[$iword][0],getWordEn($iAllWordIndex[$iword][0]),$iAllWordIndex[$iword][1],$iAllWordIndex[$iword][2],$iAllWordIndex[$iword][3],0,mb_strlen($iAllWordIndex[$iword][0],"UTF-8"));
-		//echo "<br>{$newWord[0]}-{$newWord[1]}-{$newWord[2]}-{$newWord[3]}-{$newWord[4]}-{$newWord[5]}-<br />";
-		$stmt->execute($newWord);
-	}
-
-	
-	// 提交更改 
-	$PDO->commit();
-	if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-		$error = PDO_ErrorInfo();
-		echo "error - $error[2] <br>";
-		$log.="$from, $FileName, error, $error[2] \r\n";
-	}
-	else{
-		echo "updata iword recorders.<br />";
-		$log.="updata iword recorders.\r\n";
-	}			
-	
-	$myLogFile = fopen($dirLog."insert_index.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
-	
-	
-	echo "<h2>齐活!功德无量!all done!</h2>";	
+// 开始一个事务,关闭自动提交
+$PDO->beginTransaction();
+$query = "INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES (?,?,?,?,?,?,?,?)";
+$stmt = $PDO->prepare($query);
+
+echo count($iAllWordIndex) . "words<br>";
+for ($iword = 0; $iword < count($iAllWordIndex); $iword++) {
+    $wordindex = $iword;
+    $newWord = array($wordindex, $iAllWordIndex[$iword][0], getWordEn($iAllWordIndex[$iword][0]), $iAllWordIndex[$iword][1], $iAllWordIndex[$iword][2], $iAllWordIndex[$iword][3], 0, mb_strlen($iAllWordIndex[$iword][0], "UTF-8"));
+    //echo "<br>{$newWord[0]}-{$newWord[1]}-{$newWord[2]}-{$newWord[3]}-{$newWord[4]}-{$newWord[5]}-<br />";
+    $stmt->execute($newWord);
+}
+
+// 提交更改
+$PDO->commit();
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+    $log .= "$from, $FileName, error, $error[2] \r\n";
+} else {
+    echo "updata iword recorders.<br />";
+    $log .= "updata iword recorders.\r\n";
+}
+
+$myLogFile = fopen($dirLog . "insert_index.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
+
+echo "<h2>齐活!功德无量!all done!</h2>";
 ?>
 
 

+ 116 - 123
app/install/db_insert_page_index.php

@@ -3,139 +3,132 @@
 require_once "./_pdo.php";
 require_once "../path.php";
 
-if (PHP_SAPI  == "cli") {
-	echo $argc;
-	if($argc>=3){
-		$from=$argv[1];
-		$to=$argv[2];
-		echo "From: {$from} To:{$to}";
-	}
-	else if($argc>=1){
-		$from=0;
-		$to = 216;
-		echo "生成全部217本书";
-	}
-	else{
-		echo "参数错误";
-		exit;
-	}
-
-}
-else{
-	echo "<!DOCTYPE html><html><head></head>";
-	echo "<body><h2>Insert to Index</h2>";
-
-	if(isset($_GET["from"])==false){
-		echo '<form action="db_insert_index_once.php" method="get">';
-		echo 'From: <input type="text" name="from" value="0"><br>';
-		echo 'To: <input type="text" name="to" value="216"><br>';
-		echo '<input type="submit">';
-		echo '</form>';
-		exit;
-	}
-	else{
-		$from=$_GET["from"];
-		$to=$_GET["to"];
-	}
+if (PHP_SAPI == "cli") {
+    echo $argc;
+    if ($argc >= 3) {
+        $from = $argv[1];
+        $to = $argv[2];
+        echo "From: {$from} To:{$to}";
+    } else if ($argc >= 1) {
+        $from = 0;
+        $to = 216;
+        echo "生成全部217本书";
+    } else {
+        echo "参数错误";
+        exit;
+    }
+
+} else {
+    echo "<!DOCTYPE html><html><head></head>";
+    echo "<body><h2>Insert to Index</h2>";
+
+    if (isset($_GET["from"]) == false) {
+        echo '<form action="db_insert_index_once.php" method="get">';
+        echo 'From: <input type="text" name="from" value="0"><br>';
+        echo 'To: <input type="text" name="to" value="216"><br>';
+        echo '<input type="submit">';
+        echo '</form>';
+        exit;
+    } else {
+        $from = $_GET["from"];
+        $to = $_GET["to"];
+    }
 }
 
+$g_wordCounter = 0;
+$g_wordIndexCounter = 0;
+$iAllWordIndex = array();
+$sAllWord = array();
 
-$g_wordCounter=0;
-$g_wordIndexCounter=0;
-$iAllWordIndex=array();
-$sAllWord=array();
-
-$dirLog=_DIR_LOG_."/";
+$dirLog = _DIR_LOG_ . "/";
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "\n <h2>$from</h2>";
 
-
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-	
-for($iFile=$from;$iFile<=$to;$iFile++){
+
+for ($iFile = $from; $iFile <= $to; $iFile++) {
     echo "<h3>{$iFile}</h3>";
-	$FileName=$filelist[$iFile][1].".htm";
-	$fileId=$filelist[$iFile][0];
-
-	$inputFileName=$FileName;
-	$outputFileNameHead=$filelist[$iFile][1];
-	$bookId=$filelist[$iFile][2];
-
-	$dirXml=$outputFileNameHead."/";
-
-	$xmlfile = $inputFileName;
-	echo "doing:".$xmlfile."<br>";
-	$log=$log."$iFile,$FileName,open\r\n";
-
-	$arrInserString=array();
-
-	$db_file = _FILE_DB_PAGE_INDEX_;
-	PDO_Connect("sqlite:$db_file");
-	// 打开文件并读取数据
-	$irow=0;
-	if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-		// 开始一个事务,关闭自动提交
-		$PDO->beginTransaction();
-		$query="INSERT INTO m ('book','para','page1','page2') VALUES (?,?,?,?)";
-		$stmt = $PDO->prepare($query);
-
-		$currPage=array(0,0);
-		$currPara = 0;
-		while(($data=fgetcsv($fp,0,','))!==FALSE){
-			$irow++;
-			if($irow>1){
-				if($data[6]==".ctl." && mb_substr($data[5],0,1,"UTF-8")=="M"){
-					$sPage= mb_substr($data[5],1,6,"UTF-8");
-					$aPage = explode(".",$sPage);
-					if(count($aPage)==2){
-						$currPage = $aPage;
-					}
-					else{
-						echo "错误的页码: {$data[5]} \n ";
-					}
-				}
-				$para = $data[3];
-				if($currPara!=$data[3]){
-					$currPara=(int)$data[3];
-					$book = mb_substr($data[2],1, null ,"UTF-8");
-					$para = $currPara;
-					$page1 = $currPage[0];
-					$page2 = $currPage[1];
-					$stmt->execute(array($book,$para,$page1,$page2));
-				}
-			}
-				
-		}
-
-		// 提交更改 
-		$PDO->commit();
-		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-			$error = PDO_ErrorInfo();
-			echo "error - $error[2] <br>";
-			$log.="$from, $FileName, error, $error[2] \r\n";
-		}
-		else{
-			echo "updata  recorders.<br />";
-			$log.="updata  recorders.\r\n";
-		}
-		fclose($fp);
-		echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>\n";
-	}
-	else{
-		echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
-	}
+    $FileName = $filelist[$iFile][1] . ".htm";
+    $fileId = $filelist[$iFile][0];
+
+    $inputFileName = $FileName;
+    $outputFileNameHead = $filelist[$iFile][1];
+    $bookId = $filelist[$iFile][2];
+
+    $dirXml = $outputFileNameHead . "/";
+
+    $xmlfile = $inputFileName;
+    echo "doing:" . $xmlfile . "<br>";
+    $log = $log . "$iFile,$FileName,open\r\n";
+
+    $arrInserString = array();
+
+    $db_file = _FILE_DB_PAGE_INDEX_;
+    PDO_Connect("$db_file");
+    // 打开文件并读取数据
+    $irow = 0;
+    if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+        // 开始一个事务,关闭自动提交
+        $PDO->beginTransaction();
+        $query = "INSERT INTO m ('book','para','page1','page2') VALUES (?,?,?,?)";
+        $stmt = $PDO->prepare($query);
+
+        $currPage = array(0, 0);
+        $currPara = 0;
+        while (($data = fgetcsv($fp, 0, ',')) !== false) {
+            $irow++;
+            if ($irow > 1) {
+                if ($data[6] == ".ctl." && mb_substr($data[5], 0, 1, "UTF-8") == "M") {
+                    $sPage = mb_substr($data[5], 1, 6, "UTF-8");
+                    $aPage = explode(".", $sPage);
+                    if (count($aPage) == 2) {
+                        $currPage = $aPage;
+                    } else {
+                        echo "错误的页码: {$data[5]} \n ";
+                    }
+                }
+                $para = $data[3];
+                if ($currPara != $data[3]) {
+                    $currPara = (int) $data[3];
+                    $book = mb_substr($data[2], 1, null, "UTF-8");
+                    $para = $currPara;
+                    $page1 = $currPage[0];
+                    $page2 = $currPage[1];
+                    $stmt->execute(array($book, $para, $page1, $page2));
+                }
+            }
+
+        }
+
+        // 提交更改
+        $PDO->commit();
+        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+            $error = PDO_ErrorInfo();
+            echo "error - $error[2] <br>";
+            $log .= "$from, $FileName, error, $error[2] \r\n";
+        } else {
+            echo "updata  recorders.<br />";
+            $log .= "updata  recorders.\r\n";
+        }
+        fclose($fp);
+        echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>\n";
+    } else {
+        echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
+    }
 }
-	echo "齐活!功德无量!all done!";	
+echo "齐活!功德无量!all done!";
 ?>
 
 

+ 88 - 95
app/install/db_insert_palitext.php

@@ -11,8 +11,8 @@ require_once "install_head.php";
 <?php
 require_once "./_pdo.php";
 require_once "../path.php";
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_insert_palitext.php" method="get">
 From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
@@ -22,129 +22,122 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
-
-$dirLog=_DIR_LOG_."/";
 
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirPaliTextBase=_DIR_PALI_HTML_."/";
-$dirXml=$outputFileNameHead."/";
+$dirLog = _DIR_LOG_ . "/";
 
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirPaliTextBase = _DIR_PALI_HTML_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
 
-$arrInserString=array();
-$db_file =_FILE_DB_PALITEXT_;
-PDO_Connect("sqlite:$db_file");
+$arrInserString = array();
+$db_file = _FILE_DB_PALITEXT_;
+PDO_Connect("$db_file");
 
 // 打开vri html文件并读取数据
-$pali_text_array=array();
-if(($fpPaliText=fopen($dirPaliTextBase.$xmlfile, "r"))!==FALSE){
-	while(($data=fgets($fpPaliText))!==FALSE){
-		if(  substr($data,0,2) === "<p" ){
-			array_push($pali_text_array,$data);
-		}
-		
-	}
-	fclose($fpPaliText);
-	echo "pali text load:".$dirPaliTextBase.$xmlfile."<br>";
-}
-else{
-	echo "can not pali text file. filename=".$dirPaliTextBase.$xmlfile;
+$pali_text_array = array();
+if (($fpPaliText = fopen($dirPaliTextBase . $xmlfile, "r")) !== false) {
+    while (($data = fgets($fpPaliText)) !== false) {
+        if (substr($data, 0, 2) === "<p") {
+            array_push($pali_text_array, $data);
+        }
+
+    }
+    fclose($fpPaliText);
+    echo "pali text load:" . $dirPaliTextBase . $xmlfile . "<br>";
+} else {
+    echo "can not pali text file. filename=" . $dirPaliTextBase . $xmlfile;
 }
 
-$inputRow=0;
-if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead."_pali.csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp , 0 , ',' )) !== FALSE ){
-		if($inputRow>0){
-			if(($inputRow-1)<count($pali_text_array)){
-				$data[5]=$pali_text_array[$inputRow-1];
-			}
-			$arrInserString[]=$data;
-		}
-		$inputRow++;
-	}
-	fclose($fp);
-	echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
-}
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+$inputRow = 0;
+if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . "_pali.csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        if ($inputRow > 0) {
+            if (($inputRow - 1) < count($pali_text_array)) {
+                $data[5] = $pali_text_array[$inputRow - 1];
+            }
+            $arrInserString[] = $data;
+        }
+        $inputRow++;
+    }
+    fclose($fp);
+    echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
-if(($inputRow-1)!=count($pali_text_array)){
-$log=$log."$from, $FileName,error,文件行数不匹配 inputRow=$inputRow pali_text_array=".count($pali_text_array)." \r\n";
+if (($inputRow - 1) != count($pali_text_array)) {
+    $log = $log . "$from, $FileName,error,文件行数不匹配 inputRow=$inputRow pali_text_array=" . count($pali_text_array) . " \r\n";
 }
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
 
-$query="INSERT INTO pali_text ('id', 'book','paragraph','level','class','toc','text','html','lenght') VALUES (NULL, ? , ? , ? , ? , ? , ? , ?,? )";
+$query = "INSERT INTO pali_text ('id', 'book','paragraph','level','class','toc','text','html','lenght') VALUES (NULL, ? , ? , ? , ? , ? , ? , ?,? )";
 $stmt = $PDO->prepare($query);
-foreach($arrInserString as $oneParam){
-	if($oneParam[3]<100){
-		$toc = $oneParam[6];
-	}
-	else{
-		$toc = "";
-	}
-	$newData=array($from+1, $oneParam[2], $oneParam[3], $oneParam[4], $toc , $oneParam[6], $oneParam[5], mb_strlen($oneParam[6],"UTF-8"));
-	$stmt->execute($newData);
+foreach ($arrInserString as $oneParam) {
+    if ($oneParam[3] < 100) {
+        $toc = $oneParam[6];
+    } else {
+        $toc = "";
+    }
+    $newData = array($from + 1, $oneParam[2], $oneParam[3], $oneParam[4], $toc, $oneParam[6], $oneParam[5], mb_strlen($oneParam[6], "UTF-8"));
+    $stmt->execute($newData);
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	$count=count($arrInserString);
-	echo "updata $count recorders.";
-}
-
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
 
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    $count = count($arrInserString);
+    echo "updata $count recorders.";
+}
 
-	$myLogFile = fopen($dirLog."db_insert_palitext.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen($dirLog . "db_insert_palitext.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_palitext.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_palitext.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 298 - 317
app/install/db_insert_sentence.php

@@ -13,10 +13,10 @@ require_once "install_head.php";
 include "./_pdo.php";
 require_once '../path.php';
 
-$db_file =_FILE_DB_PALI_SENTENCE_;
-$thisfile = '.'.mb_substr(__FILE__,mb_strlen(__DIR__));
-if(isset($_GET["from"])==false){
-?>
+$db_file = _FILE_DB_PALI_SENTENCE_;
+$thisfile = '.' . mb_substr(__FILE__, mb_strlen(__DIR__));
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="<?php echo $thisfile; ?>" method="get">
 From: <input type="text" value="0" name="from"><br>
 To: <input type="text" value="216" name="to"><br>
@@ -24,357 +24,338 @@ To: <input type="text" value="216" name="to"><br>
 </form>
 <?php
 
-return;
+    return;
 }
-function wordStyle($word,$style){
-	switch ($style) {
-		case 'bld':
-			# bold form
-			# 不包含字符{ }
-			if(mb_strpos($word,'{',0,"UTF-8")===FALSE){
-				return "<b>".$word."</b> ";
-			}
-			else{
-				$word = str_replace("{","<b>",$word);
-				$word = str_replace("}","</b>",$word);
-				return $word;
-			}
-			break;
-
-		case 'note':
-				# vir note...
-				return "<note>".$word."</note>";
-			break;
-		case 'paranum':
-				# vir note...
-				return "<paranum>".$word."</paranum>";
-			break;
-
-		default:
-			# code...
-			return $word;
-			break;
-	}
+function wordStyle($word, $style)
+{
+    switch ($style) {
+        case 'bld':
+            # bold form
+            # 不包含字符{ }
+            if (mb_strpos($word, '{', 0, "UTF-8") === false) {
+                return "<b>" . $word . "</b> ";
+            } else {
+                $word = str_replace("{", "<b>", $word);
+                $word = str_replace("}", "</b>", $word);
+                return $word;
+            }
+            break;
+
+        case 'note':
+            # vir note...
+            return "<note>" . $word . "</note>";
+            break;
+        case 'paranum':
+            # vir note...
+            return "<paranum>" . $word . "</paranum>";
+            break;
+
+        default:
+            # code...
+            return $word;
+            break;
+    }
 }
 
-
-$from=$_GET["from"];
-$to=$_GET["to"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from-$to</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to>=$fileNums) $to=$fileNums-1;
 
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirLog=_DIR_LOG_."/";
+$dirLog = _DIR_LOG_ . "/";
 
-$dirDb="db/";
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$dirDb = "db/";
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirXml=$outputFileNameHead."/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
-$currChapter="";
-$currParNum="";
-$arrAllWords[0]=array("id","wid","book","paragraph","word","real","type","gramma","mean","note","part","partmean","bmc","bmt","un","style","vri","sya","si","ka","pi","pa","kam");
-$g_wordCounter=0;
+$currChapter = "";
+$currParNum = "";
+$arrAllWords[0] = array("id", "wid", "book", "paragraph", "word", "real", "type", "gramma", "mean", "note", "part", "partmean", "bmc", "bmt", "un", "style", "vri", "sya", "si", "ka", "pi", "pa", "kam");
+$g_wordCounter = 0;
 
-$arrUnWords[0]=array("id","word","type","gramma","parent","mean","note","part","partmean","cf","state","delete","tag","len");
-$g_unWordCounter=0;
+$arrUnWords[0] = array("id", "word", "type", "gramma", "parent", "mean", "note", "part", "partmean", "cf", "state", "delete", "tag", "len");
+$g_unWordCounter = 0;
 
-$arrUnPart[0]="word";
-$g_unPartCounter=-1;
+$arrUnPart[0] = "word";
+$g_unPartCounter = -1;
 
 /*去掉标点符号的统计*/
-$arrAllPaliWordsCount=array();
-$g_paliWordCounter=0;
-$g_wordCounterInSutta=0;
-$g_paliWordCountCounter=0;
-
+$arrAllPaliWordsCount = array();
+$g_paliWordCounter = 0;
+$g_wordCounterInSutta = 0;
+$g_paliWordCountCounter = 0;
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
 
-$arrInserString=array();
+$arrInserString = array();
 
-function getWordEn($strIn){
-	$search  = array('ā', 'ī', 'ū', 'ṅ', 'ñ' , 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
-	$replace = array('a', 'i', 'u', 'n', 'n' , 't', 'd', 'n', 'l', 'm');
-	return(str_replace($search,$replace,$strIn));
+function getWordEn($strIn)
+{
+    $search = array('ā', 'ī', 'ū', 'ṅ', 'ñ', 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
+    $replace = array('a', 'i', 'u', 'n', 'n', 't', 'd', 'n', 'l', 'm');
+    return (str_replace($search, $replace, $strIn));
 }
 
-
-
 // 打开文件并读取数据
-$iWord=0;
-$pre=null;
-$curr=null;
-$next=null;
-$wordlist=array();
-$arrSent=array();
-$book=0;
-$sent_html="";
-
-if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp))!==FALSE){
-		//id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
-		//$data = mb_split(",",$data);
-		
-		$wordlist[]=$data;
-		if($book==0){
-			$book=substr($data[2],1);
-		}
-
-	}
-	fclose($fp);
-	
-	$iWord=0;
-	$iCurrPara=0;
-	$Note_Mark=0;
-	if($wordlist[1][6] != ".ctl."){
-		$sent=$wordlist[1][4]." ";
-		$sent_html=wordStyle($wordlist[1][4],$wordlist[1][15])." ";
-		$sent_real=$wordlist[1][5];
-		$wordcount=1;
-	}
-	else{
-		$sent="";
-		$sent_html="";
-		$sent_real="";
-		$wordcount=0;
-	}
-	$begin=1;
-	$end=1;
-	$iSent=0;
-	$Note_Mark1=0;
-	$Note_Mark2=0;
-	$Note_Mark = 0;
-	$wordcount=0;
-	for($i=1;$i<count($wordlist);$i++){
-		if($wordlist[$i][3]>$iCurrPara){
-			//echo  "new paragraph<br>";
-			$iWord=0;
-			if($i>1){
-				//echo "上一段结束<br>";
-				if(strlen(trim($sent))>0){
-					$end = $wordlist[$i-1][16];
-					$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen(trim($sent_real),"UTF-8"),$wordcount,$sent,$sent_html,trim($sent_real),getWordEn($sent_real));
-					//echo "end={$end}<br>";
-					//echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
-				}
-				$iCurrPara=$wordlist[$i][3];
-
-				$Note_Mark1=0;
-				$Note_Mark2=0;
-				$Note_Mark = 0;
-	
-				$pre=$wordlist[$i-1];
-				$curr=$wordlist[$i];
-				if($i<count($wordlist)-1){
-					$next=$wordlist[$i+1];
-				}
-				else{
-					$next="";
-				}
-	
-				if($next[4]=="(" || $curr[4]=="("){
-					$Note_Mark1=1;
-				}
-				else if($pre[4]==")" && $Note_Mark1==1){
-					$Note_Mark1=0;
-				}
-		
-				if($next[4]=="[" || $curr[4]=="["){
-					$Note_Mark2=1;
-				}
-				else if($pre[4]=="]" && $Note_Mark2==1){
-					$Note_Mark2=0;
-				}
-				$Note_Mark = $Note_Mark1+$Note_Mark2;
-				//下一段开始
-				if($wordlist[$i][6] != ".ctl."){
-					$sent=$wordlist[$i][4]." ";
-					$sent_html=wordStyle($wordlist[$i][4],$wordlist[$i][15])." ";
-					if($wordlist[$i][5]=='"'){
-						$sent_real="";
-					}
-					else{
-						$sent_real=$wordlist[$i][5];
-					}
-					$wordcount=1;
-				}
-				else{
-					$sent="";
-					$sent_html="";
-					$sent_real="";
-					$wordcount=0;
-				}
-				$begin = $wordlist[$i][16];
-				
-				$iSent++;
-				
-				
-				continue;
-			}
-			$iCurrPara=$wordlist[$i][3];
-		}
-		$isEndOfSen=false;
-		if($i<count($wordlist)-1){
-			$pre=$wordlist[$i-1];
-			$curr=$wordlist[$i];
-			if($i<count($wordlist)-1){
-				$next=$wordlist[$i+1];
-			}
-			else{
-				$next="";
-			}
-
-			if($next[4]=="("){
-				$Note_Mark1=1;
-			}
-			else if($pre[4]==")" && $Note_Mark1==1){
-				$Note_Mark1=0;
-			}
-	
-			if($next[4]=="["){
-				$Note_Mark2=1;
-			}
-			else if($pre[4]=="]" && $Note_Mark2==1){
-				$Note_Mark2=0;
-			}
-			$Note_Mark = $Note_Mark1+$Note_Mark2;
-
-			if($curr[15] != "note" || mb_substr($curr[1],0,5,"UTF-8") != "gatha"){
-				if($curr[4] == "."  && !is_numeric($pre[4]) && $next[3]==$iCurrPara && $Note_Mark===0){
-					//以.結尾且非註釋
-					if($next[4] != "("){
-						$isEndOfSen=true;
-					}
-				}
-				else if($curr[4]=="–"  && $next[4]=="‘"  && $Note_Mark===0){
-					$isEndOfSen=true;
-				}
-				else if($Note_Mark == 0){
-					//以!或?或;結尾
-					if($curr[4]=="!"){
-						if($next[4]!="!"){
-							if($next[4]!="("){
-								$isEndOfSen=true;
-							}
-						}
-					}
-					else if($curr[4]==";" || $curr[4]=="?"){
-						if($next[4] != "("){
-							$isEndOfSen=true;
-						}
-					}
-				}
-			}
-		}
-
-			if($curr[6] != ".ctl."){
-				if($next[5] != ""){
-					# 下一个是标点符号
-					$sent .= $curr[4]." ";
-					$sent_html .= wordStyle($curr[4],$curr[15])." ";
-				}
-				else{
-					$sent .= $curr[4];
-					$sent_html .= wordStyle($curr[4],$curr[15]);
-				}
-				if($wordlist[$i][5] != '' && ($Note_Mark==0 || ($Note_Mark==1 && ($next[4]=="[" || $next[4]=="(")))){
-
-					$wordcount++;
-					if($wordlist[$i][5]=="iti"){
-						$sent_real .=" ".$curr[4];
-					}
-					else{
-						$sent_real .=" ".$curr[5];
-					}
-				}
-				
-			}
-			if($isEndOfSen==true && strlen(trim($sent))>0){
-				$end = $wordlist[$i][16];
-				$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen(trim($sent_real),"UTF-8"),$wordcount,$sent,$sent_html,trim($sent_real),getWordEn($sent_real));			
-				//echo "end={$end}<br>";
-				//echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
-				
-				$sent="";
-				$sent_html="";
-				$sent_real="";
-				$iSent++;
-				$begin = $wordlist[$i][16]+1;
-				$wordcount=0;
-			}
-			
-			$iWord++;
-	}
-				if(strlen(trim($sent))>0){
-					$end = $wordlist[count($wordlist)-1][16];
-					$arrSent[]=array($book,$iCurrPara,$begin,$end,mb_strlen(trim($sent_real),"UTF-8"),$wordcount,$sent,$sent_html,trim($sent_real),getWordEn($sent_real));
-					//echo "end={$end}<br>";
-					//echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
-				}
-}
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+$iWord = 0;
+$pre = null;
+$curr = null;
+$next = null;
+$wordlist = array();
+$arrSent = array();
+$book = 0;
+$sent_html = "";
+
+if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+    while (($data = fgetcsv($fp)) !== false) {
+        //id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
+        //$data = mb_split(",",$data);
+
+        $wordlist[] = $data;
+        if ($book == 0) {
+            $book = substr($data[2], 1);
+        }
+
+    }
+    fclose($fp);
+
+    $iWord = 0;
+    $iCurrPara = 0;
+    $Note_Mark = 0;
+    if ($wordlist[1][6] != ".ctl.") {
+        $sent = $wordlist[1][4] . " ";
+        $sent_html = wordStyle($wordlist[1][4], $wordlist[1][15]) . " ";
+        $sent_real = $wordlist[1][5];
+        $wordcount = 1;
+    } else {
+        $sent = "";
+        $sent_html = "";
+        $sent_real = "";
+        $wordcount = 0;
+    }
+    $begin = 1;
+    $end = 1;
+    $iSent = 0;
+    $Note_Mark1 = 0;
+    $Note_Mark2 = 0;
+    $Note_Mark = 0;
+    $wordcount = 0;
+    for ($i = 1; $i < count($wordlist); $i++) {
+        if ($wordlist[$i][3] > $iCurrPara) {
+            //echo  "new paragraph<br>";
+            $iWord = 0;
+            if ($i > 1) {
+                //echo "上一段结束<br>";
+                if (strlen(trim($sent)) > 0) {
+                    $end = $wordlist[$i - 1][16];
+                    $arrSent[] = array($book, $iCurrPara, $begin, $end, mb_strlen(trim($sent_real), "UTF-8"), $wordcount, $sent, $sent_html, trim($sent_real), getWordEn($sent_real));
+                    //echo "end={$end}<br>";
+                    //echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
+                }
+                $iCurrPara = $wordlist[$i][3];
+
+                $Note_Mark1 = 0;
+                $Note_Mark2 = 0;
+                $Note_Mark = 0;
+
+                $pre = $wordlist[$i - 1];
+                $curr = $wordlist[$i];
+                if ($i < count($wordlist) - 1) {
+                    $next = $wordlist[$i + 1];
+                } else {
+                    $next = "";
+                }
+
+                if ($next[4] == "(" || $curr[4] == "(") {
+                    $Note_Mark1 = 1;
+                } else if ($pre[4] == ")" && $Note_Mark1 == 1) {
+                    $Note_Mark1 = 0;
+                }
+
+                if ($next[4] == "[" || $curr[4] == "[") {
+                    $Note_Mark2 = 1;
+                } else if ($pre[4] == "]" && $Note_Mark2 == 1) {
+                    $Note_Mark2 = 0;
+                }
+                $Note_Mark = $Note_Mark1 + $Note_Mark2;
+                //下一段开始
+                if ($wordlist[$i][6] != ".ctl.") {
+                    $sent = $wordlist[$i][4] . " ";
+                    $sent_html = wordStyle($wordlist[$i][4], $wordlist[$i][15]) . " ";
+                    if ($wordlist[$i][5] == '"') {
+                        $sent_real = "";
+                    } else {
+                        $sent_real = $wordlist[$i][5];
+                    }
+                    $wordcount = 1;
+                } else {
+                    $sent = "";
+                    $sent_html = "";
+                    $sent_real = "";
+                    $wordcount = 0;
+                }
+                $begin = $wordlist[$i][16];
+
+                $iSent++;
+
+                continue;
+            }
+            $iCurrPara = $wordlist[$i][3];
+        }
+        $isEndOfSen = false;
+        if ($i < count($wordlist) - 1) {
+            $pre = $wordlist[$i - 1];
+            $curr = $wordlist[$i];
+            if ($i < count($wordlist) - 1) {
+                $next = $wordlist[$i + 1];
+            } else {
+                $next = "";
+            }
+
+            if ($next[4] == "(") {
+                $Note_Mark1 = 1;
+            } else if ($pre[4] == ")" && $Note_Mark1 == 1) {
+                $Note_Mark1 = 0;
+            }
+
+            if ($next[4] == "[") {
+                $Note_Mark2 = 1;
+            } else if ($pre[4] == "]" && $Note_Mark2 == 1) {
+                $Note_Mark2 = 0;
+            }
+            $Note_Mark = $Note_Mark1 + $Note_Mark2;
+
+            if ($curr[15] != "note" || mb_substr($curr[1], 0, 5, "UTF-8") != "gatha") {
+                if ($curr[4] == "." && !is_numeric($pre[4]) && $next[3] == $iCurrPara && $Note_Mark === 0) {
+                    //以.結尾且非註釋
+                    if ($next[4] != "(") {
+                        $isEndOfSen = true;
+                    }
+                } else if ($curr[4] == "–" && $next[4] == "‘" && $Note_Mark === 0) {
+                    $isEndOfSen = true;
+                } else if ($Note_Mark == 0) {
+                    //以!或?或;結尾
+                    if ($curr[4] == "!") {
+                        if ($next[4] != "!") {
+                            if ($next[4] != "(") {
+                                $isEndOfSen = true;
+                            }
+                        }
+                    } else if ($curr[4] == ";" || $curr[4] == "?") {
+                        if ($next[4] != "(") {
+                            $isEndOfSen = true;
+                        }
+                    }
+                }
+            }
+        }
+
+        if ($curr[6] != ".ctl.") {
+            if ($next[5] != "") {
+                # 下一个是标点符号
+                $sent .= $curr[4] . " ";
+                $sent_html .= wordStyle($curr[4], $curr[15]) . " ";
+            } else {
+                $sent .= $curr[4];
+                $sent_html .= wordStyle($curr[4], $curr[15]);
+            }
+            if ($wordlist[$i][5] != '' && ($Note_Mark == 0 || ($Note_Mark == 1 && ($next[4] == "[" || $next[4] == "(")))) {
+
+                $wordcount++;
+                if ($wordlist[$i][5] == "iti") {
+                    $sent_real .= " " . $curr[4];
+                } else {
+                    $sent_real .= " " . $curr[5];
+                }
+            }
+
+        }
+        if ($isEndOfSen == true && strlen(trim($sent)) > 0) {
+            $end = $wordlist[$i][16];
+            $arrSent[] = array($book, $iCurrPara, $begin, $end, mb_strlen(trim($sent_real), "UTF-8"), $wordcount, $sent, $sent_html, trim($sent_real), getWordEn($sent_real));
+            //echo "end={$end}<br>";
+            //echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
+
+            $sent = "";
+            $sent_html = "";
+            $sent_real = "";
+            $iSent++;
+            $begin = $wordlist[$i][16] + 1;
+            $wordcount = 0;
+        }
+
+        $iWord++;
+    }
+    if (strlen(trim($sent)) > 0) {
+        $end = $wordlist[count($wordlist) - 1][16];
+        $arrSent[] = array($book, $iCurrPara, $begin, $end, mb_strlen(trim($sent_real), "UTF-8"), $wordcount, $sent, $sent_html, trim($sent_real), getWordEn($sent_real));
+        //echo "end={$end}<br>";
+        //echo "<div>[{$iCurrPara}-{$begin}-{$end}]({$wordcount})<br>{$sent}<br>{$sent_real}<br>".getWordEn($sent_real)."</div>";
+    }
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
 // 开始一个事务,关闭自动提交
 
-PDO_Connect("sqlite:$db_file");
+PDO_Connect("$db_file");
 $PDO->beginTransaction();
-$query="INSERT INTO pali_sent ('id','book','paragraph','begin','end','length','count','text','html','real','real_en') VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+$query = "INSERT INTO pali_sent ('id','book','paragraph','begin','end','length','count','text','html','real','real_en') VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 $stmt = $PDO->prepare($query);
-foreach($arrSent as $oneParam){
-	$stmt->execute($oneParam);
+foreach ($arrSent as $oneParam) {
+    $stmt->execute($oneParam);
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	$count=count($arrSent);
-	echo "updata $count recorders.";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    $count = count($arrSent);
+    echo "updata $count recorders.";
 }
 
-	$myLogFile = fopen(_DIR_LOG_."insert_sent.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen(_DIR_LOG_ . "insert_sent.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 
 ?>
 
 
-<?php 
+<?php
 
-if($from>=$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_sentence.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+if ($from >= $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_sentence.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 25 - 29
app/install/db_insert_sim.php

@@ -1,51 +1,47 @@
-<?php 
+<?php
 /*
 用相似句导入数据库
-*/
+ */
 
 ?>
 <?php
 require_once '../public/_pdo.php';
 require_once '../path.php';
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "start\n";
 
-$db_file = _DIR_PALICANON_."/pali_sim.db3";
-PDO_Connect("sqlite:$db_file");
+$db_file = _DIR_PALICANON_ . "/pali_sim.db3";
+PDO_Connect("$db_file");
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query="INSERT INTO sent_sim ('sent1','sent2','sim') VALUES (? , ? , ?)";
+$query = "INSERT INTO sent_sim ('sent1','sent2','sim') VALUES (? , ? , ?)";
 $stmt = $PDO->prepare($query);
 
 // 打开文件并读取数据
 $count = 0;
-if(($fp=fopen(_DIR_TMP_."/pali_simsent/sim.csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		$stmt->execute($data);
-		$count++;
-		if($count%1000000==0){
-			echo $count."\n";
-		}
-	}
-	fclose($fp);
-}
-else{
-	echo "can not open csv file. ";
+if (($fp = fopen(_DIR_TMP_ . "/pali_simsent/sim.csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        $stmt->execute($data);
+        $count++;
+        if ($count % 1000000 == 0) {
+            echo $count . "\n";
+        }
+    }
+    fclose($fp);
+} else {
+    echo "can not open csv file. ";
 }
 
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	
-	echo " error, $error[2] \r\n";
-}
-else{
-	echo "updata $count recorders.";
-}
+    $error = PDO_ErrorInfo();
 
-?>
+    echo " error, $error[2] \r\n";
+} else {
+    echo "updata $count recorders.";
+}

+ 111 - 113
app/install/db_insert_templet.php

@@ -1,7 +1,7 @@
-<?php 
+<?php
 /*
 用拆分好的三藏数据 生成模板库
-*/
+ */
 require_once "install_head.php";
 ?>
 <!DOCTYPE html>
@@ -14,8 +14,8 @@ require_once "install_head.php";
 <?php
 require_once '../public/_pdo.php';
 require_once '../path.php';
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_insert_templet.php" method="get">
 From: <input type="text" value="0" name="from"><br>
 To: <input type="text" value="216" name="to"><br>
@@ -25,148 +25,146 @@ To: <input type="text" value="216" name="to"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
 
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirLog=_DIR_LOG_;
+$dirLog = _DIR_LOG_;
 
-$dirDb=_DIR_PALICANON_TEMPLET_;
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirXml=$outputFileNameHead."/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
-$currChapter="";
-$currParNum="";
-$arrAllWords[0]=array("id","wid","book","paragraph","word","real","type","gramma","mean","note","part","partmean","bmc","bmt","un","style","vri","sya","si","ka","pi","pa","kam");
-$g_wordCounter=0;
+$currChapter = "";
+$currParNum = "";
+$arrAllWords[0] = array("id", "wid", "book", "paragraph", "word", "real", "type", "gramma", "mean", "note", "part", "partmean", "bmc", "bmt", "un", "style", "vri", "sya", "si", "ka", "pi", "pa", "kam");
+$g_wordCounter = 0;
 
-$arrUnWords[0]=array("id","word","type","gramma","parent","mean","note","part","partmean","cf","state","delete","tag","len");
-$g_unWordCounter=0;
+$arrUnWords[0] = array("id", "word", "type", "gramma", "parent", "mean", "note", "part", "partmean", "cf", "state", "delete", "tag", "len");
+$g_unWordCounter = 0;
 
-$arrUnPart[0]="word";
-$g_unPartCounter=-1;
+$arrUnPart[0] = "word";
+$g_unPartCounter = -1;
 
 /*去掉标点符号的统计*/
-$arrAllPaliWordsCount=array();
-$g_paliWordCounter=0;
-$g_wordCounterInSutta=0;
-$g_paliWordCountCounter=0;
-
+$arrAllPaliWordsCount = array();
+$g_paliWordCounter = 0;
+$g_wordCounterInSutta = 0;
+$g_paliWordCountCounter = 0;
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
+
+$arrInserString = array();
 
-$arrInserString=array();
-$db_file = $dirDb."/".$bookId.'_tpl.db3';
-PDO_Connect("sqlite:$db_file");
+$db_file = _DIR_PALICANON_TEMPLET_ . "/" . $bookId . '_tpl.db3';
+PDO_Connect("$db_file");
 
 PDO_Execute("DROP TABLE IF EXISTS main;");
-$query="CREATE TABLE 'main' ( 'id' TEXT PRIMARY KEY NOT NULL, 
-							'book' INTEGER, 
-							'paragraph' INTEGER, 
-							'wid' INTEGER, 
-							'word' TEXT, 
-							'real' TEXT, 
-							'type' TEXT, 
-							'gramma' TEXT, 
-							'part' TEXT, 
+$query = "CREATE TABLE 'main' ( 'id' TEXT PRIMARY KEY NOT NULL,
+							'book' INTEGER,
+							'paragraph' INTEGER,
+							'wid' INTEGER,
+							'word' TEXT,
+							'real' TEXT,
+							'type' TEXT,
+							'gramma' TEXT,
+							'part' TEXT,
 							'style' TEXT)";
-    $stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-
-	}
-	PDO_Execute("DROP INDEX IF EXISTS search;");
-	
-$query="CREATE INDEX 'search' ON \"main\" (\"book\", \"paragraph\", \"wid\" ASC)";
-    $stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-        $log=$log."$from, $FileName, error, $error[2] \r\n";
-    }
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
 
-// 打开文件并读取数据
-if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		//id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
-		
-		$params=array($data[0],
-					 mb_substr($data[2],1),
-					 $data[3],
-					 $data[16],
-					 $data[4],
-					 $data[5],
-					 $data[6],
-					 $data[7],
-					 $data[10],
-					 $data[15]);
-		$arrInserString[]=$params;
-	}
-	fclose($fp);
-	echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
 }
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+PDO_Execute("DROP INDEX IF EXISTS search;");
+
+$query = "CREATE INDEX 'search' ON \"main\" (\"book\", \"paragraph\", \"wid\" ASC)";
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+}
+
+// 打开文件并读取数据
+if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        //id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
+
+        $params = array($data[0],
+            mb_substr($data[2], 1),
+            $data[3],
+            $data[16],
+            $data[4],
+            $data[5],
+            $data[6],
+            $data[7],
+            $data[10],
+            $data[15]);
+        $arrInserString[] = $params;
+    }
+    fclose($fp);
+    echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query="INSERT INTO main ('id','book','paragraph','wid','word','real','type','gramma','part','style') VALUES (?,?,?,?,?,?,?,?,?,?)";
+$query = "INSERT INTO main ('id','book','paragraph','wid','word','real','type','gramma','part','style') VALUES (?,?,?,?,?,?,?,?,?,?)";
 $stmt = $PDO->prepare($query);
-foreach($arrInserString as $oneParam){
-	$stmt->execute($oneParam);
+foreach ($arrInserString as $oneParam) {
+    $stmt->execute($oneParam);
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	$count=count($arrInserString);
-	echo "updata $count recorders.";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    $count = count($arrInserString);
+    echo "updata $count recorders.";
 }
 
-	$myLogFile = fopen($dirLog."insert_db.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen($dirLog . "insert_db.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_templet.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_templet.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 49 - 51
app/install/db_insert_word_from_csv.php

@@ -11,8 +11,8 @@ require_once "install_head.php";
 <?php
 include "./_pdo.php";
 
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_insert_word_from_csv.php" method="get">
 From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
@@ -22,67 +22,65 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
+$from = $_GET["from"];
+$to = $_GET["to"];
 
-$dirLog=_DIR_LOG_."/";
-$dirXmlBase=_DIR_PALI_CSV_."/";
+$dirLog = _DIR_LOG_ . "/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>doing : No.{$from} book </h2>";
 
 global $dbh_word_index;
-$dns = "sqlite:"._FILE_DB_PALI_INDEX_;
-$dbh_word_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_PALI_INDEX_;
+$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 (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-	if(($fpoutput=fopen(_DIR_CSV_PALI_CANON_WORD_."/{$from}_words.csv", "r"))!==FALSE){
-		// 开始一个事务,关闭自动提交
-		$dbh_word_index->beginTransaction();
-		$query="INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
-		$stmt = $dbh_word_index->prepare($query);
 
-		$count=0;
-		while(($data=fgetcsv($fpoutput,0,','))!==FALSE){
-			$stmt->execute($data);
-			$count++;
-		}
-		// 提交更改 
-		$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";
-		}		
-	}
+if (($fpoutput = fopen(_DIR_CSV_PALI_CANON_WORD_ . "/{$from}_words.csv", "r")) !== false) {
+    // 开始一个事务,关闭自动提交
+    $dbh_word_index->beginTransaction();
+    $query = "INSERT INTO word ('id','book','paragraph','wordindex','bold') VALUES (?,?,?,?,?)";
+    $stmt = $dbh_word_index->prepare($query);
 
+    $count = 0;
+    while (($data = fgetcsv($fpoutput, 0, ',')) !== false) {
+        $stmt->execute($data);
+        $count++;
+    }
+    // 提交更改
+    $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);
-	
+$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_word_from_csv.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+if ($from >= $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_word_from_csv.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 36 - 43
app/install/db_insert_wordindex_from_csv.php

@@ -10,63 +10,56 @@ include "./_pdo.php";
 <h2>Insert to Index</h2>
 <?php
 
-if(isset($_GET["from"])==false){
-    $from=0;
+if (isset($_GET["from"]) == false) {
+    $from = 0;
+} else {
+    $from = $_GET["from"];
 }
-else{
-    $from=$_GET["from"];
-}
-
 
-$dirLog=_DIR_LOG_."/";
+$dirLog = _DIR_LOG_ . "/";
 
-$filelist=array();
-$fileNums=0;
-$log="";
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>doing : No.{$from}  </h2>";
 
 global $dbh_word_index;
-$dns = "sqlite:"._FILE_DB_WORD_INDEX_;
-$dbh_word_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_WORD_INDEX_;
+$dbh_word_index = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_word_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
+if (($fpoutput = fopen(_DIR_CSV_PALI_CANON_WORD_INDEX_ . "/{$from}.csv", "r")) !== false) {
 
-	if(($fpoutput=fopen(_DIR_CSV_PALI_CANON_WORD_INDEX_."/{$from}.csv", "r"))!==FALSE){
-
-		// 开始一个事务,关闭自动提交
-		$dbh_word_index->beginTransaction();
-        $query="INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES (?,?,?,?,?,?,?,?)";
+    // 开始一个事务,关闭自动提交
+    $dbh_word_index->beginTransaction();
+    $query = "INSERT INTO wordindex ('id','word','word_en','count','normal','bold','is_base','len') VALUES (?,?,?,?,?,?,?,?)";
 
-		$stmt = $dbh_word_index->prepare($query);
+    $stmt = $dbh_word_index->prepare($query);
 
-		$count=0;
-		while(($data=fgetcsv($fpoutput,0,','))!==FALSE){
-			$stmt->execute($data);
-			$count++;
-		}
-		// 提交更改 
-		$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";
-		}		
+    $count = 0;
+    while (($data = fgetcsv($fpoutput, 0, ',')) !== false) {
+        $stmt->execute($data);
+        $count++;
     }
-    else{
-        echo "<h2>齐活!功德无量!all done!</h2>"; 
-        exit;
+    // 提交更改
+    $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";
     }
-	
-
+} else {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+    exit;
+}
 
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_wordindex_from_csv.php?from=".($from+1)."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+echo "<script>";
+echo "window.location.assign(\"db_insert_wordindex_from_csv.php?from=" . ($from + 1) . "\")";
+echo "</script>";
+echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 
 ?>
 </body>

+ 28 - 27
app/install/db_pali_text_export.php

@@ -10,10 +10,10 @@ require_once "../public/_pdo.php";
 <h2>Export Pali Text DB to CSV</h2>
 <?php
 
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_pali_text_export.php" method="get">
-From: <input type="text" name="from" value="0"><br> 
+From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
 <input type="submit">
 </form>
@@ -21,42 +21,43 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
+$from = $_GET["from"];
+$to = $_GET["to"];
 
-$log="";
+$log = "";
 echo "<h2>$from</h2>";
 
-if($to==0 || $to>=217) $to=216;
-    $book = $from +1;
-if(($fp=fopen(_DIR_PALI_TITLE_."/".$book."_title.csv", "w"))!==FALSE){
-    fputcsv($fp,array('id','book','par_num','level','class','title','text'));
-    PDO_Connect("sqlite:"._FILE_DB_PALITEXT_);
-    $query="select id, book, paragraph, level, class, toc, text from pali_text where book = '$book' ";
+if ($to == 0 || $to >= 217) {
+    $to = 216;
+}
+
+$book = $from + 1;
+if (($fp = fopen(_DIR_PALI_TITLE_ . "/" . $book . "_title.csv", "w")) !== false) {
+    fputcsv($fp, array('id', 'book', 'par_num', 'level', 'class', 'title', 'text'));
+    PDO_Connect("" . _FILE_DB_PALITEXT_);
+    $query = "select id, book, paragraph, level, class, toc, text from pali_text where book = '$book' ";
     $title_data = PDO_FetchAll($query);
-    foreach( $title_data as $value){
+    foreach ($title_data as $value) {
         $value["id"] = "NULL";
-        $value["book"] = "p".$value["book"];
-        if($value["level"]=="100"){
+        $value["book"] = "p" . $value["book"];
+        if ($value["level"] == "100") {
             $value["toc"] = "";
         }
-        fputcsv($fp,$value);
+        fputcsv($fp, $value);
     }
     fclose($fp);
     echo "ok";
-}
-else{
-    echo "error:can not open file "._DIR_PALI_TITLE_."/".$book."_title.csv";
+} else {
+    echo "error:can not open file " . _DIR_PALI_TITLE_ . "/" . $book . "_title.csv";
 }
 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_pali_text_export.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_pali_text_export.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 

+ 155 - 162
app/install/db_update_palitext.php

@@ -11,10 +11,10 @@ require_once "../public/_pdo.php";
 <p><a href="index.php">Home</a></p>
 <?php
 
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_update_palitext.php" method="get">
-From: <input type="text" name="from" value="0"><br> 
+From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
 <input type="submit">
 </form>
@@ -22,209 +22,202 @@ To: <input type="text" name="to" value="216"><br>
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
-
-$dirLog=_DIR_LOG_."/";
 
-$dirDb="/";
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirPaliTextBase=_DIR_PALI_HTML_."/";
-$dirXml=$outputFileNameHead."/";
+$dirLog = _DIR_LOG_ . "/";
 
+$dirDb = "/";
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirPaliTextBase = _DIR_PALI_HTML_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-
-$log=$log.date("Y-m-d h:i:sa").",$from,$FileName,open\r\n";
-
-$arrInserString=array();
+echo "doing:" . $xmlfile . "<br>";
 
+$log = $log . date("Y-m-d h:i:sa") . ",$from,$FileName,open\r\n";
 
+$arrInserString = array();
 
 // 打开vri html文件并读取数据
-$pali_text_array=array();//vri text
-if(($fpPaliText=fopen($dirPaliTextBase.$xmlfile, "r"))!==FALSE){
-	while(($data=fgets($fpPaliText))!==FALSE){
-		array_push($pali_text_array,$data);
-	}
-	fclose($fpPaliText);
-	echo "pali text load:".$dirPaliTextBase.$xmlfile."<br>";
-}
-else{
-	echo "can not pali text file. filename=".$dirPaliTextBase.$xmlfile;
+$pali_text_array = array(); //vri text
+if (($fpPaliText = fopen($dirPaliTextBase . $xmlfile, "r")) !== false) {
+    while (($data = fgets($fpPaliText)) !== false) {
+        array_push($pali_text_array, $data);
+    }
+    fclose($fpPaliText);
+    echo "pali text load:" . $dirPaliTextBase . $xmlfile . "<br>";
+} else {
+    echo "can not pali text file. filename=" . $dirPaliTextBase . $xmlfile;
 }
 
 // 打开csv文件并读取数据
-$inputRow=0;
-if(($fp=fopen(_DIR_PALI_TITLE_."/".($from+1)."_title.csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		if($inputRow>0){
-			$params=$data;
-			array_push($arrInserString,$params);
-		}
-		$inputRow++;
-	}
-	fclose($fp);
-	echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
-}
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+$inputRow = 0;
+if (($fp = fopen(_DIR_PALI_TITLE_ . "/" . ($from + 1) . "_title.csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        if ($inputRow > 0) {
+            $params = $data;
+            array_push($arrInserString, $params);
+        }
+        $inputRow++;
+    }
+    fclose($fp);
+    echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
-if((count($arrInserString))  != count($pali_text_array)-2){
-	$log=$log."$from, $FileName,error,文件行数不匹配 csv = ".(count($arrInserString)-1) ." pali_text_array=".(count($pali_text_array)-2)." \r\n";
+if ((count($arrInserString)) != count($pali_text_array) - 2) {
+    $log = $log . "$from, $FileName,error,文件行数不匹配 csv = " . (count($arrInserString) - 1) . " pali_text_array=" . (count($pali_text_array) - 2) . " \r\n";
 }
 
-$book=$from+1;
+$book = $from + 1;
 
 //计算段落信息,如上一段
-PDO_Connect("sqlite:"._FILE_DB_PALITEXT_);
-$query="select * from pali_text where book = '$book' ";
+PDO_Connect("" . _FILE_DB_PALITEXT_);
+$query = "select * from pali_text where book = '$book' ";
 $title_data = PDO_FetchAll($query);
-echo  "Paragraph Count:".count($title_data)."<br>";
+echo "Paragraph Count:" . count($title_data) . "<br>";
 
 $paragraph_count = count($title_data);
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query ="UPDATE pali_text SET level = ? , toc = ? , chapter_len = ? , next_chapter = ?, prev_chapter=? , parent= ?  ,  chapter_strlen = ?  WHERE book=? and paragraph=?";
+$query = "UPDATE pali_text SET level = ? , toc = ? , chapter_len = ? , next_chapter = ?, prev_chapter=? , parent= ?  ,  chapter_strlen = ?  WHERE book=? and paragraph=?";
 $stmt = $PDO->prepare($query);
 
 $paragraph_info = array();
-array_push($paragraph_info,array($from,-1,$paragraph_count,-1,-1,-1));
-for($iPar=0;$iPar < count($title_data); $iPar++){
-	$title_data[$iPar]["level"] = $arrInserString[$iPar][3];
+array_push($paragraph_info, array($from, -1, $paragraph_count, -1, -1, -1));
+for ($iPar = 0; $iPar < count($title_data); $iPar++) {
+    $title_data[$iPar]["level"] = $arrInserString[$iPar][3];
 }
 
-for($iPar=0;$iPar < count($title_data); $iPar++){
-	$book=$from+1;
-	$paragraph=$title_data[$iPar]["paragraph"];
-	
-	if((int)$title_data[$iPar]["level"]==8){
-		$title_data[$iPar]["level"]=100;
-	}
-	
-	$curr_level=(int)$title_data[$iPar]["level"];
-	# j计算这个chapter的段落数量
-	$length=-1;
-	for($iPar1=$iPar+1;$iPar1<count($title_data); $iPar1++){
-		$thislevel = (int)$title_data[$iPar1]["level"];
-		if( $thislevel <= $curr_level){
-			$length=(int)$title_data[$iPar1]["paragraph"]-$paragraph;
-			break;
-		}
-	}
-	if($length==-1){
-		$length=$paragraph_count-$paragraph+1;
-	}
-	
-	$prev=-1;
-	if($iPar>0){
-		for($iPar1=$iPar-1;$iPar1>=0; $iPar1--){
-			if($title_data[$iPar1]["level"]==$curr_level){
-				$prev=$title_data[$iPar1]["paragraph"];
-				break;
-			}
-		}
-	}
-	
-	$next=-1;
-	if($iPar<count($title_data)-1){
-		for($iPar1=$iPar+1;$iPar1<count($title_data); $iPar1++){
-			if($title_data[$iPar1]["level"]==$curr_level){
-				$next=$title_data[$iPar1]["paragraph"];
-				break;
-			}
-		}
-	}		
-	
-	$parent=-1;
-	if($iPar>0){
-		for($iPar1=$iPar-1;$iPar1>=0; $iPar1--){
-			if($title_data[$iPar1]["level"]<$curr_level){
-				$parent=$title_data[$iPar1]["paragraph"];
-				break;
-			}
-		}
-	}				
-	//计算章节包含总字符数
-	$iChapter_strlen = 0;
-	for($i = $iPar ; $i < $iPar+$length; $i++ ){
-		$iChapter_strlen += $title_data[$i]["lenght"];
-	}
-	$newData=array(
-		$arrInserString[$iPar][3],
-		$arrInserString[$iPar][5],
-		$length,
-	   $next,
-	   $prev,
-	   $parent,
-	   $iChapter_strlen,
-	   $book,
-	   $paragraph
-	);
-	$stmt->execute($newData);
-	
-	if($curr_level>0 && $curr_level<8){
-		array_push($paragraph_info,array($book,$paragraph,$length,$prev,$next,$parent));
-	}
+for ($iPar = 0; $iPar < count($title_data); $iPar++) {
+    $book = $from + 1;
+    $paragraph = $title_data[$iPar]["paragraph"];
+
+    if ((int) $title_data[$iPar]["level"] == 8) {
+        $title_data[$iPar]["level"] = 100;
+    }
+
+    $curr_level = (int) $title_data[$iPar]["level"];
+    # j计算这个chapter的段落数量
+    $length = -1;
+    for ($iPar1 = $iPar + 1; $iPar1 < count($title_data); $iPar1++) {
+        $thislevel = (int) $title_data[$iPar1]["level"];
+        if ($thislevel <= $curr_level) {
+            $length = (int) $title_data[$iPar1]["paragraph"] - $paragraph;
+            break;
+        }
+    }
+    if ($length == -1) {
+        $length = $paragraph_count - $paragraph + 1;
+    }
+
+    $prev = -1;
+    if ($iPar > 0) {
+        for ($iPar1 = $iPar - 1; $iPar1 >= 0; $iPar1--) {
+            if ($title_data[$iPar1]["level"] == $curr_level) {
+                $prev = $title_data[$iPar1]["paragraph"];
+                break;
+            }
+        }
+    }
+
+    $next = -1;
+    if ($iPar < count($title_data) - 1) {
+        for ($iPar1 = $iPar + 1; $iPar1 < count($title_data); $iPar1++) {
+            if ($title_data[$iPar1]["level"] == $curr_level) {
+                $next = $title_data[$iPar1]["paragraph"];
+                break;
+            }
+        }
+    }
+
+    $parent = -1;
+    if ($iPar > 0) {
+        for ($iPar1 = $iPar - 1; $iPar1 >= 0; $iPar1--) {
+            if ($title_data[$iPar1]["level"] < $curr_level) {
+                $parent = $title_data[$iPar1]["paragraph"];
+                break;
+            }
+        }
+    }
+    //计算章节包含总字符数
+    $iChapter_strlen = 0;
+    for ($i = $iPar; $i < $iPar + $length; $i++) {
+        $iChapter_strlen += $title_data[$i]["lenght"];
+    }
+    $newData = array(
+        $arrInserString[$iPar][3],
+        $arrInserString[$iPar][5],
+        $length,
+        $next,
+        $prev,
+        $parent,
+        $iChapter_strlen,
+        $book,
+        $paragraph,
+    );
+    $stmt->execute($newData);
+
+    if ($curr_level > 0 && $curr_level < 8) {
+        array_push($paragraph_info, array($book, $paragraph, $length, $prev, $next, $parent));
+    }
 }
 
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	$count=count($title_data);
-	echo "updata $count paragraph info recorders.<br>";
-	echo count($paragraph_info)." Heading<br>";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    $count = count($title_data);
+    echo "updata $count paragraph info recorders.<br>";
+    echo count($paragraph_info) . " Heading<br>";
 }
 //段落信息结束
 
+$myLogFile = fopen(_DIR_LOG_ . "/db_update_palitext.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 
-	$myLogFile = fopen(_DIR_LOG_."/db_update_palitext.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
-	
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_update_palitext.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_update_palitext.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 99 - 106
app/install/db_update_toc.php

@@ -5,11 +5,12 @@ require_once '../path.php';
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-function getWordEn($strIn){
+function getWordEn($strIn)
+{
     $strIn = strtolower($strIn);
-	$search  = array('ā', 'ī', 'ū', 'ṅ', 'ñ' , 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
-	$replace = array('a', 'i', 'u', 'n', 'n' , 't', 'd', 'n', 'l', 'm');
-	return(str_replace($search,$replace,$strIn));
+    $search = array('ā', 'ī', 'ū', 'ṅ', 'ñ', 'ṭ', 'ḍ', 'ṇ', 'ḷ', 'ṃ');
+    $replace = array('a', 'i', 'u', 'n', 'n', 't', 'd', 'n', 'l', 'm');
+    return (str_replace($search, $replace, $strIn));
 }
 ?>
 <!DOCTYPE html>
@@ -20,10 +21,10 @@ function getWordEn($strIn){
 <h2>Update Table of Contence</h2>
 <?php
 
-if(isset($_GET["from"])==false){
-?>
+if (isset($_GET["from"]) == false) {
+    ?>
 <form action="db_update_toc.php" method="get">
-From: <input type="text" name="from" value="0"><br> 
+From: <input type="text" name="from" value="0"><br>
 To: <input type="text" name="to" value="216"><br>
 File: <input type="text" name="file" value="title"><br>
 Author: <input type="text" name="author" value=""><br>
@@ -41,151 +42,143 @@ Language:
 return;
 }
 
-$from=$_GET["from"];
-$to=$_GET["to"];
-$_file=$_GET["file"];
-$_author=$_GET["author"];
-$_lang=$_GET["lang"];
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = $_GET["from"];
+$to = $_GET["to"];
+$_file = $_GET["file"];
+$_author = $_GET["author"];
+$_lang = $_GET["lang"];
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
-
-$dirLog=_DIR_LOG_."/";
 
-$dirDb="/";
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirPaliTextBase=_DIR_PALI_HTML_."/";
-$dirXml=$outputFileNameHead."/";
+$dirLog = _DIR_LOG_ . "/";
 
+$dirDb = "/";
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirPaliTextBase = _DIR_PALI_HTML_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
 $xmlfile = $inputFileName;
 
-$log=$log.date("Y-m-d h:i:sa").",$from,$FileName,open\r\n";
-
-$arrInserString=array();
+$log = $log . date("Y-m-d h:i:sa") . ",$from,$FileName,open\r\n";
 
+$arrInserString = array();
 
 // 打开csv文件并读取数据
-$inputRow=0;
-if(($fp=fopen(_DIR_PALI_TITLE_."/".($from+1)."_{$_file}.csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		if($inputRow>0 && $data[3] != 100  && !empty($data[6])){
-			array_push($arrInserString,$data);
-		}
-		$inputRow++;
-	}
-	fclose($fp);
-	echo "res load:"._DIR_PALI_TITLE_."/".($from+1)."_title.csv<br>";
-}
-else{
+$inputRow = 0;
+if (($fp = fopen(_DIR_PALI_TITLE_ . "/" . ($from + 1) . "_{$_file}.csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        if ($inputRow > 0 && $data[3] != 100 && !empty($data[6])) {
+            array_push($arrInserString, $data);
+        }
+        $inputRow++;
+    }
+    fclose($fp);
+    echo "res load:" . _DIR_PALI_TITLE_ . "/" . ($from + 1) . "_title.csv<br>";
+} else {
     echo "can not open csv ";
-    
-    if($from==$to){
+
+    if ($from == $to) {
         echo "<h2>齐活!功德无量!all done!</h2>";
-    }
-    else{
+    } else {
         echo "<script>";
-        $next = $from+1;
+        $next = $from + 1;
         echo "window.location.assign(\"db_update_toc.php?from={$next}&to={$to}&file={$_file}&author={$_author}&lang={$_lang}\")";
         echo "</script>";
-        echo "正在载入:".($from+1);
+        echo "正在载入:" . ($from + 1);
         echo "</body></html>";
         exit;
     }
 }
 
-$book=$from+1;
+$book = $from + 1;
 
 //删除已有标题
-PDO_Connect("sqlite:"._FILE_DB_RESRES_INDEX_);
-$query =" DELETE FROM 'index' WHERE book ='{$book}'  AND  language = '{$_lang}'  ";
+PDO_Connect("" . _FILE_DB_RESRES_INDEX_);
+$query = " DELETE FROM 'index' WHERE book ='{$book}'  AND  language = '{$_lang}'  ";
 
 $PDO->query($query);
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query="INSERT INTO 'index' ('id','book','paragraph','title','title_en' ,'level','type','language','author','share','create_time','update_time' ) VALUES ( NULL , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
+$query = "INSERT INTO 'index' ('id','book','paragraph','title','title_en' ,'level','type','language','author','share','create_time','update_time' ) VALUES ( NULL , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
 $stmt = $PDO->prepare($query);
-if($_lang=="pali"){
-    $type=1;
-}
-else{
-    $type=2;
+if ($_lang == "pali") {
+    $type = 1;
+} else {
+    $type = 2;
 }
-foreach($arrInserString as $title){
-	if(isset($title[7])){
-		$author = $title[7];
-	}
-	else if(isset($_author)){
-		$author = $_author;
-	}
-	else{
-		$author = "";
-	}
-	$newData=array(
+foreach ($arrInserString as $title) {
+    if (isset($title[7])) {
+        $author = $title[7];
+    } else if (isset($_author)) {
+        $author = $_author;
+    } else {
+        $author = "";
+    }
+    $newData = array(
         $book,
         $title[2],
         $title[6],
         getWordEn($title[6]),
         $title[3],
-		$type,
-	    $_lang,
+        $type,
+        $_lang,
         $author,
-	   1,
-	   mTime(),
-       mTime()
-	);
-	$stmt->execute($newData);
+        1,
+        mTime(),
+        mTime(),
+    );
+    $stmt->execute($newData);
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	$log=$log."$from, error, $error[2] \r\n";
-}
-else{
-	$count=count($arrInserString);
-	echo "updata $count title recorders.<br>";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+    $log = $log . "$from, error, $error[2] \r\n";
+} else {
+    $count = count($arrInserString);
+    echo "updata $count title recorders.<br>";
 }
 //段落信息结束
-	$myLogFile = fopen(_DIR_LOG_."/db_update_toc.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
-	
+$myLogFile = fopen(_DIR_LOG_ . "/db_update_toc.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
+
 ?>
 
 
-<?php 
-    if($from==$to){
-        echo "<h2>齐活!功德无量!all done!</h2>";
-    }
-    else{
-        echo "<script>";
-        $next = $from+1;
-        echo "window.location.assign(\"db_update_toc.php?from={$next}&to={$to}&file={$_file}&author={$_author}&lang={$_lang}\")";
-        echo "</script>";
-        echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
-    }
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    $next = $from + 1;
+    echo "window.location.assign(\"db_update_toc.php?from={$next}&to={$to}&file={$_file}&author={$_author}&lang={$_lang}\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
+}
 ?>
 </body>
 </html>

+ 24 - 27
app/install/install_head.php

@@ -1,38 +1,35 @@
 <?php
-    require_once "../path.php";
+require_once "../path.php";
 //error handler function
 function customError($errno, $errstr)
- { 
- echo "<b>Error:</b> [$errno] $errstr";
- }
+{
+    echo "<b>Error:</b> [$errno] $errstr";
+}
 
 //set error handler
 set_error_handler("customError");
 
-    function user_db_is_exist(){
-        $PDO = new PDO("sqlite:"._FILE_DB_USERINFO_, "", "");
-        $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-        $stmt = $PDO->query("SELECT count(*) as co FROM sqlite_master WHERE type=\"table\" AND name = \"user\"");
-        
-        $row = $stmt->fetch(PDO::FETCH_NUM);
-        if ($row) {
-            if($row[0]>0){
-                return true;
-            }
-            else{
-                return false;
-            }
-        } 
-        else 
-        {
+function user_db_is_exist()
+{
+    $PDO = new PDO("" . _FILE_DB_USERINFO_, "", "");
+    $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+    $stmt = $PDO->query("SELECT count(*) as co FROM sqlite_master WHERE type=\"table\" AND name = \"user\"");
+
+    $row = $stmt->fetch(PDO::FETCH_NUM);
+    if ($row) {
+        if ($row[0] > 0) {
+            return true;
+        } else {
             return false;
-        }        
+        }
+    } else {
+        return false;
     }
+}
 
-    if(user_db_is_exist()){
-        if(!isset($_COOKIE["userid"])){
-            echo "请登陆后执行此操作";
-            exit;
-        }
+if (user_db_is_exist()) {
+    if (!isset($_COOKIE["userid"])) {
+        echo "请登陆后执行此操作";
+        exit;
     }
-?>
+}

+ 111 - 113
app/install/page_index.php

@@ -1,7 +1,7 @@
-<?php 
+<?php
 /*
 用拆分好的三藏数据 导出cs6段落编号
-*/
+ */
 
 ?>
 <!DOCTYPE html>
@@ -14,8 +14,8 @@
 <?php
 require_once '../public/_pdo.php';
 require_once '../path.php';
-if(isset($_GET["run"])==false){
-?>
+if (isset($_GET["run"]) == false) {
+    ?>
 <form action="db_insert_templet.php" method="get">
 From: <input type="text" value="0" name="from"><br>
 To: <input type="text" value="216" name="to"><br>
@@ -25,148 +25,146 @@ To: <input type="text" value="216" name="to"><br>
 return;
 }
 
-$from=0;
-$to=216;
-$filelist=array();
-$fileNums=0;
-$log="";
+$from = 0;
+$to = 216;
+$filelist = array();
+$fileNums = 0;
+$log = "";
 echo "<h2>$from</h2>";
 
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
+if (($handle = fopen("filelist.csv", 'r')) !== false) {
+    while (($filelist[$fileNums] = fgetcsv($handle, 0, ',')) !== false) {
+        $fileNums++;
+    }
+}
+if ($to == 0 || $to >= $fileNums) {
+    $to = $fileNums - 1;
 }
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
 
-$FileName=$filelist[$from][1].".htm";
-$fileId=$filelist[$from][0];
-$fileId=$filelist[$from][0];
+$FileName = $filelist[$from][1] . ".htm";
+$fileId = $filelist[$from][0];
+$fileId = $filelist[$from][0];
 
-$dirLog=_DIR_LOG_;
+$dirLog = _DIR_LOG_;
 
-$dirDb=_DIR_PALICANON_TEMPLET_;
-$inputFileName=$FileName;
-$outputFileNameHead=$filelist[$from][1];
-$bookId=$filelist[$from][2];
-$vriParNum=0;
-$wordOrder=1;
+$dirDb = _DIR_PALICANON_TEMPLET_;
+$inputFileName = $FileName;
+$outputFileNameHead = $filelist[$from][1];
+$bookId = $filelist[$from][2];
+$vriParNum = 0;
+$wordOrder = 1;
 
-$dirXmlBase=_DIR_PALI_CSV_."/";
-$dirXml=$outputFileNameHead."/";
+$dirXmlBase = _DIR_PALI_CSV_ . "/";
+$dirXml = $outputFileNameHead . "/";
 
-$currChapter="";
-$currParNum="";
-$arrAllWords[0]=array("id","wid","book","paragraph","word","real","type","gramma","mean","note","part","partmean","bmc","bmt","un","style","vri","sya","si","ka","pi","pa","kam");
-$g_wordCounter=0;
+$currChapter = "";
+$currParNum = "";
+$arrAllWords[0] = array("id", "wid", "book", "paragraph", "word", "real", "type", "gramma", "mean", "note", "part", "partmean", "bmc", "bmt", "un", "style", "vri", "sya", "si", "ka", "pi", "pa", "kam");
+$g_wordCounter = 0;
 
-$arrUnWords[0]=array("id","word","type","gramma","parent","mean","note","part","partmean","cf","state","delete","tag","len");
-$g_unWordCounter=0;
+$arrUnWords[0] = array("id", "word", "type", "gramma", "parent", "mean", "note", "part", "partmean", "cf", "state", "delete", "tag", "len");
+$g_unWordCounter = 0;
 
-$arrUnPart[0]="word";
-$g_unPartCounter=-1;
+$arrUnPart[0] = "word";
+$g_unPartCounter = -1;
 
 /*去掉标点符号的统计*/
-$arrAllPaliWordsCount=array();
-$g_paliWordCounter=0;
-$g_wordCounterInSutta=0;
-$g_paliWordCountCounter=0;
-
+$arrAllPaliWordsCount = array();
+$g_paliWordCounter = 0;
+$g_wordCounterInSutta = 0;
+$g_paliWordCountCounter = 0;
 
 $xmlfile = $inputFileName;
-echo "doing:".$xmlfile."<br>";
-$log=$log."$from,$FileName,open\r\n";
+echo "doing:" . $xmlfile . "<br>";
+$log = $log . "$from,$FileName,open\r\n";
 
-$arrInserString=array();
-$db_file = $dirDb."/".$bookId.'_tpl.db3';
-PDO_Connect("sqlite:$db_file");
+$arrInserString = array();
+$db_file = $dirDb . "/" . $bookId . '_tpl.db3';
+PDO_Connect("$db_file");
 
 PDO_Execute("DROP TABLE IF EXISTS main;");
-$query="CREATE TABLE 'main' ( 'id' TEXT PRIMARY KEY NOT NULL, 
-							'book' INTEGER, 
-							'paragraph' INTEGER, 
-							'wid' INTEGER, 
-							'word' TEXT, 
-							'real' TEXT, 
-							'type' TEXT, 
-							'gramma' TEXT, 
-							'part' TEXT, 
+$query = "CREATE TABLE 'main' ( 'id' TEXT PRIMARY KEY NOT NULL,
+							'book' INTEGER,
+							'paragraph' INTEGER,
+							'wid' INTEGER,
+							'word' TEXT,
+							'real' TEXT,
+							'type' TEXT,
+							'gramma' TEXT,
+							'part' TEXT,
 							'style' TEXT)";
-    $stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-
-	}
-	PDO_Execute("DROP INDEX IF EXISTS search;");
-	
-$query="CREATE INDEX 'search' ON \"main\" (\"book\", \"paragraph\", \"wid\" ASC)";
-    $stmt = @PDO_Execute($query);
-    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-        $error = PDO_ErrorInfo();
-        print_r($error[2]);
-        $log=$log."$from, $FileName, error, $error[2] \r\n";
-    }
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
 
-// 打开文件并读取数据
-if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
-	while(($data=fgetcsv($fp,0,','))!==FALSE){
-		//id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
-		
-		$params=array($data[0],
-					 mb_substr($data[2],1),
-					 $data[3],
-					 $data[16],
-					 $data[4],
-					 $data[5],
-					 $data[6],
-					 $data[7],
-					 $data[10],
-					 $data[15]);
-		$arrInserString[]=$params;
-	}
-	fclose($fp);
-	echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv<br>";
 }
-else{
-	echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
+PDO_Execute("DROP INDEX IF EXISTS search;");
+
+$query = "CREATE INDEX 'search' ON \"main\" (\"book\", \"paragraph\", \"wid\" ASC)";
+$stmt = @PDO_Execute($query);
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+    $error = PDO_ErrorInfo();
+    print_r($error[2]);
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+}
+
+// 打开文件并读取数据
+if (($fp = fopen($dirXmlBase . $dirXml . $outputFileNameHead . ".csv", "r")) !== false) {
+    while (($data = fgetcsv($fp, 0, ',')) !== false) {
+        //id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
+
+        $params = array($data[0],
+            mb_substr($data[2], 1),
+            $data[3],
+            $data[16],
+            $data[4],
+            $data[5],
+            $data[6],
+            $data[7],
+            $data[10],
+            $data[15]);
+        $arrInserString[] = $params;
+    }
+    fclose($fp);
+    echo "单词表load:" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv<br>";
+} else {
+    echo "can not open csv file. filename=" . $dirXmlBase . $dirXml . $outputFileNameHead . ".csv";
 }
 
 // 开始一个事务,关闭自动提交
 $PDO->beginTransaction();
-$query="INSERT INTO main ('id','book','paragraph','wid','word','real','type','gramma','part','style') VALUES (?,?,?,?,?,?,?,?,?,?)";
+$query = "INSERT INTO main ('id','book','paragraph','wid','word','real','type','gramma','part','style') VALUES (?,?,?,?,?,?,?,?,?,?)";
 $stmt = $PDO->prepare($query);
-foreach($arrInserString as $oneParam){
-	$stmt->execute($oneParam);
+foreach ($arrInserString as $oneParam) {
+    $stmt->execute($oneParam);
 }
-// 提交更改 
+// 提交更改
 $PDO->commit();
 if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-	$error = PDO_ErrorInfo();
-	echo "error - $error[2] <br>";
-	
-	$log=$log."$from, $FileName, error, $error[2] \r\n";
-}
-else{
-	$count=count($arrInserString);
-	echo "updata $count recorders.";
+    $error = PDO_ErrorInfo();
+    echo "error - $error[2] <br>";
+
+    $log = $log . "$from, $FileName, error, $error[2] \r\n";
+} else {
+    $count = count($arrInserString);
+    echo "updata $count recorders.";
 }
 
-	$myLogFile = fopen($dirLog."insert_db.log", "a");
-	fwrite($myLogFile, $log);
-	fclose($myLogFile);
+$myLogFile = fopen($dirLog . "insert_db.log", "a");
+fwrite($myLogFile, $log);
+fclose($myLogFile);
 ?>
 
 
-<?php 
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"db_insert_templet.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$filelist[$from+1][0];
+<?php
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"db_insert_templet.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $filelist[$from + 1][0];
 }
 ?>
 </body>

+ 40 - 42
app/install/step2.php

@@ -15,54 +15,52 @@ require_once 'nav_bar.php';
 ?>
 <h3>Step 2 Create User Database</h3>
 <?php
-$dbfile[]=array(_FILE_DB_USER_WBW_,"user_wbw.sql");
-$dbfile[]=array(_FILE_DB_COMMENTS_,"comments.sql");
-$dbfile[]=array(_FILE_DB_SENTENCE_,"sentence.sql");
-$dbfile[]=array(_FILE_DB_TERM_,"dhammaterm.sql");
-$dbfile[]=array(_FILE_DB_GROUP_,"group.sql");
-$dbfile[]=array(_FILE_DB_USERINFO_,"userinfo.sql");
-$dbfile[]=array(_FILE_DB_FILEINDEX_,"fileindex.sql");
-$dbfile[]=array(_FILE_DB_WBW_,"wbw.sql");
-$dbfile[]=array(_FILE_DB_COURSE_,"course.sql");
-$dbfile[]=array(_FILE_DB_MEDIA_,"media.sql");
-$dbfile[]=array(_FILE_DB_MESSAGE_,"message.sql");
-$dbfile[]=array(_FILE_DB_USER_STATISTICS_,"statistics.sql");
-$dir="./userdb/";
+$dbfile[] = array(_FILE_DB_USER_WBW_, "user_wbw.sql");
+$dbfile[] = array(_FILE_DB_COMMENTS_, "comments.sql");
+$dbfile[] = array(_FILE_DB_SENTENCE_, "sentence.sql");
+$dbfile[] = array(_FILE_DB_TERM_, "dhammaterm.sql");
+$dbfile[] = array(_FILE_DB_GROUP_, "group.sql");
+$dbfile[] = array(_FILE_DB_USERINFO_, "userinfo.sql");
+$dbfile[] = array(_FILE_DB_FILEINDEX_, "fileindex.sql");
+$dbfile[] = array(_FILE_DB_WBW_, "wbw.sql");
+$dbfile[] = array(_FILE_DB_COURSE_, "course.sql");
+$dbfile[] = array(_FILE_DB_MEDIA_, "media.sql");
+$dbfile[] = array(_FILE_DB_MESSAGE_, "message.sql");
+$dbfile[] = array(_FILE_DB_USER_STATISTICS_, "statistics.sql");
+$dir = "./userdb/";
 
-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>"; 
+if (isset($_GET["index"])) {
+    echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';
+    $index = $_GET["index"];
+    $dns = "" . $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>";
 }
 
-
-for($i=0; $i<count($dbfile); $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])){
+for ($i = 0; $i < count($dbfile); $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="step2.php?index='.$i.'">建立</a></div>';    
-	}
-	else{
+        echo "</div>";
+        echo '<div style="flex:2;"><a href="step2.php?index=' . $i . '">建立</a></div>';
+    } else {
         echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step2.php?index='.$i.'">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+        echo "</div>";
+        echo '<div style="flex:2;"><a href="step2.php?index=' . $i . '">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
     }
-	echo "</div>";  
+    echo "</div>";
 }
 ?>
 <div>

+ 51 - 62
app/install/step3.php

@@ -19,44 +19,42 @@ require_once 'nav_bar.php';
 </div>
 <div>
 <?php
-$dbfile[]=array(_FILE_DB_REF_,"ref.sql");
-$dbfile[]=array(_FILE_DB_REF_INDEX_,"ref_index.sql");
-$dir="./refdict_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>"; 
+$dbfile[] = array(_FILE_DB_REF_, "ref.sql");
+$dbfile[] = array(_FILE_DB_REF_INDEX_, "ref_index.sql");
+$dir = "./refdict_db/";
+
+if (isset($_GET["index"])) {
+    echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';
+    $index = $_GET["index"];
+    $dns = "" . $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>";
 }
 
-
-for($i=0; $i<count($dbfile); $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])){
+for ($i = 0; $i < count($dbfile); $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="step3.php?index='.$i.'">建立</a></div>';    
-	}
-	else{
+        echo "</div>";
+        echo '<div style="flex:2;"><a href="step3.php?index=' . $i . '">建立</a></div>';
+    } else {
         echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step3.php?index='.$i.'">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+        echo "</div>";
+        echo '<div style="flex:2;"><a href="step3.php?index=' . $i . '">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
     }
-	echo "</div>";  
+    echo "</div>";
 }
 ?>
 </div>
@@ -65,53 +63,44 @@ for($i=0; $i<count($dbfile); $i++){
 <?php
 echo "var rich_file_list = new Array();\n";
 $filelist = array();
-if(($handle=fopen(_DIR_DICT_TEXT_.'/rich/list.txt','r'))!==FALSE){
-	while(($data=fgetcsv($handle,0,','))!==FALSE){
-        $filelist[] = $data;     
+if (($handle = fopen(_DIR_DICT_TEXT_ . '/rich/list.txt', 'r')) !== false) {
+    while (($data = fgetcsv($handle, 0, ',')) !== false) {
+        $filelist[] = $data;
     }
-    foreach($filelist as $value){
+    foreach ($filelist as $value) {
         echo "rich_file_list.push(['{$value[0]}','{$value[1]}']);\n";
-    }    
-}
-else{
-   // exit("无法打开rich文件列表");
+    }
+} else {
+    // exit("无法打开rich文件列表");
 }
 
-
-
 echo "var sys_file_list = new Array();\n";
 $filelist = array();
-if(($handle=fopen(_DIR_DICT_TEXT_.'/system/list.txt','r'))!==FALSE){
-	while(($data=fgetcsv($handle,0,','))!==FALSE){
-        $filelist[] = $data; 
+if (($handle = fopen(_DIR_DICT_TEXT_ . '/system/list.txt', 'r')) !== false) {
+    while (($data = fgetcsv($handle, 0, ',')) !== false) {
+        $filelist[] = $data;
     }
-    foreach($filelist as $value){
+    foreach ($filelist as $value) {
         echo "sys_file_list.push(['{$value[0]}','{$value[1]}']);\n";
 
-    }    
-}
-else{
-   // exit("无法打开system文件列表");
+    }
+} else {
+    // exit("无法打开system文件列表");
 }
 
-
-
 echo "var thin_file_list = new Array();\n";
 $filelist = array();
-if(($handle=fopen(_DIR_DICT_TEXT_.'/thin/list.csv','r'))!==FALSE){
-	while( ($data=fgetcsv($handle,0 , ',' ) )!==FALSE){
-        $filelist[] = $data; 
+if (($handle = fopen(_DIR_DICT_TEXT_ . '/thin/list.csv', 'r')) !== false) {
+    while (($data = fgetcsv($handle, 0, ',')) !== false) {
+        $filelist[] = $data;
     }
-    foreach($filelist as $value){
+    foreach ($filelist as $value) {
         echo "thin_file_list.push(['{$value[0]}','{$value[1]}','{$value[2]}']);\n";
-    }    
-}
-else{
+    }
+} else {
     //exit("无法打开thin文件列表");
 }
 
-
-
 ?>
 var iCurrRichDictIndex = 0;
 var iCurrSysDictIndex = 0;

+ 59 - 71
app/install/step3_run.php

@@ -5,123 +5,114 @@ require_once '../path.php';
 $filename = $_GET["filename"];
 $dbname = $_GET["dbname"];
 $table = $_GET["table"];
-switch($_GET["dbtype"]){
+switch ($_GET["dbtype"]) {
     case "rich":
     case "system":
-        if($_GET["dbtype"]=="rich"){
-            $sDescDbFile = _DIR_DICT_3RD_."/".$dbname;
-            $csvfile = _DIR_DICT_TEXT_."/rich/{$filename}";
-        }
-        else if($_GET["dbtype"]=="system"){
-            $sDescDbFile = _DIR_DICT_SYSTEM_."/".$dbname;      
-            $csvfile = _DIR_DICT_TEXT_."/system/{$filename}";      
-        }
-        $dns = "sqlite:".$sDescDbFile;
-        $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        if ($_GET["dbtype"] == "rich") {
+            $sDescDbFile = _DIR_DICT_3RD_ . "/" . $dbname;
+            $csvfile = _DIR_DICT_TEXT_ . "/rich/{$filename}";
+        } else if ($_GET["dbtype"] == "system") {
+            $sDescDbFile = _DIR_DICT_SYSTEM_ . "/" . $dbname;
+            $csvfile = _DIR_DICT_TEXT_ . "/system/{$filename}";
+        }
+        $dns = "" . $sDescDbFile;
+        $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-        if(strstr($filename,".",true)===strstr($dbname,".",true)){
+        if (strstr($filename, ".", true) === strstr($dbname, ".", true)) {
             //建立数据库
             $_sql = file_get_contents('rich_dict.sql');
             $_arr = explode(';', $_sql);
             //执行sql语句
             foreach ($_arr as $_value) {
-                $dbh->query($_value.';');
+                $dbh->query($_value . ';');
             }
-            echo $dns."建立数据库成功<br>";
+            echo $dns . "建立数据库成功<br>";
         }
 
         // 开始一个事务,关闭自动提交
         $dbh->beginTransaction();
-        
-        $query="INSERT INTO dict ('id','pali', 'type', 'gramma', 'parent', 'mean', 'note', 'parts', 'partmean', 'status', 'confidence', 'len', 'dict_name', 'lang') VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+        $query = "INSERT INTO dict ('id','pali', 'type', 'gramma', 'parent', 'mean', 'note', 'parts', 'partmean', 'status', 'confidence', 'len', 'dict_name', 'lang') VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
         $stmt = $dbh->prepare($query);
-        $count=0;
+        $count = 0;
         // 打开文件并读取数据
-        if(($fp=fopen($csvfile, "r"))!==FALSE){
-            while(($data=fgetcsv($fp,0,','))!==FALSE){
+        if (($fp = fopen($csvfile, "r")) !== false) {
+            while (($data = fgetcsv($fp, 0, ',')) !== false) {
                 //id,wid,book,paragraph,word,real,type,gramma,mean,note,part,partmean,bmc,bmt,un,style,vri,sya,si,ka,pi,pa,kam
                 $stmt->execute($data);
                 $count++;
             }
             fclose($fp);
             echo "单词表load<br>";
-        }
-        else{
+        } else {
             echo "can not open csv file. ";
-        }   
+        }
 
-        // 提交更改 
+        // 提交更改
         $dbh->commit();
         if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
             $error = $dbh->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             echo "updata $count recorders.";
         }
 
         $dbh = null;
 
-    break;
+        break;
     case "thin":
         echo "doing filename: $filename dbname: $dbname table:$table<br>";
-        $sDescDbFile = _DIR_DICT_SYSTEM_."/".$dbname; 
-        $csvfile = _DIR_DICT_TEXT_."/thin/{$filename}";    
-        $dns = "sqlite:".$sDescDbFile;
-        $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $sDescDbFile = _DIR_DICT_SYSTEM_ . "/" . $dbname;
+        $csvfile = _DIR_DICT_TEXT_ . "/thin/{$filename}";
+        $dns = "" . $sDescDbFile;
+        $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
         // 开始一个事务,关闭自动提交
         $dbh->beginTransaction();
-        if($dbname==="ref.db"){
-            if($table==="dict"){
-                $query="INSERT INTO dict ('id','language', 'dict_id', 'eword', 'word', 'paliword', 'mean', 'length', 'status') VALUES ( ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ?  )";
-            }
-            else if($table==="info"){
-                $query="INSERT INTO info ('language' , 'id' ,  'shortname' , 'name') VALUES (  ? ,  ? ,  ? ,  ? )";
-            }
-            else{
+        if ($dbname === "ref.db") {
+            if ($table === "dict") {
+                $query = "INSERT INTO dict ('id','language', 'dict_id', 'eword', 'word', 'paliword', 'mean', 'length', 'status') VALUES ( ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ?  )";
+            } else if ($table === "info") {
+                $query = "INSERT INTO info ('language' , 'id' ,  'shortname' , 'name') VALUES (  ? ,  ? ,  ? ,  ? )";
+            } else {
                 echo "table name $table unkow.";
             }
-        }
-        else if($dbname==="ref1.db"){
-            $query="INSERT INTO dict ('id','eword', 'word', 'length', 'count') VALUES (  ? ,  ? ,  ? ,  ? ,  ? )";
-        }
-        else{
+        } else if ($dbname === "ref1.db") {
+            $query = "INSERT INTO dict ('id','eword', 'word', 'length', 'count') VALUES (  ? ,  ? ,  ? ,  ? ,  ? )";
+        } else {
             echo "db name $dbname unkow.";
         }
-       
+
         $stmt = $dbh->prepare($query);
-        $count=0;
+        $count = 0;
         // 打开文件并读取数据
-        if(($fp=fopen($csvfile, "r"))!==FALSE){
-            while(($data=fgetcsv($fp,0,','))!==FALSE){
+        if (($fp = fopen($csvfile, "r")) !== false) {
+            while (($data = fgetcsv($fp, 0, ',')) !== false) {
                 $stmt->execute($data);
                 $count++;
             }
             fclose($fp);
             echo "单词表load<br>";
-        }
-        else{
+        } else {
             echo "can not open csv file. ";
-        }   
+        }
 
-        // 提交更改 
+        // 提交更改
         $dbh->commit();
         if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
             $error = $dbh->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             echo "updata $count recorders.";
         }
 
         $dbh = null;
 
-    break;
+        break;
     case "part":
-        $dns = "sqlite:"._FILE_DB_PART_;
-        $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $dns = "" . _FILE_DB_PART_;
+        $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
         {
@@ -130,42 +121,39 @@ switch($_GET["dbtype"]){
             $_arr = explode(';', $_sql);
             //执行sql语句
             foreach ($_arr as $_value) {
-                $dbh->query($_value.';');
+                $dbh->query($_value . ';');
             }
-            echo $dns."建立数据库成功<br>";
+            echo $dns . "建立数据库成功<br>";
         }
 
         // 开始一个事务,关闭自动提交
         $dbh->beginTransaction();
-        
-        $query="INSERT INTO part ('word','weight') VALUES ( ?, ? )";
+
+        $query = "INSERT INTO part ('word','weight') VALUES ( ?, ? )";
         $stmt = $dbh->prepare($query);
-        $count=0;
+        $count = 0;
         // 打开文件并读取数据
-        if(($fp=fopen(_DIR_DICT_TEXT_."/system/part.csv", "r"))!==FALSE){
-            while(($data=fgetcsv($fp,0,','))!==FALSE){
+        if (($fp = fopen(_DIR_DICT_TEXT_ . "/system/part.csv", "r")) !== false) {
+            while (($data = fgetcsv($fp, 0, ',')) !== false) {
                 $stmt->execute($data);
                 $count++;
             }
             fclose($fp);
             echo "part load ";
-        }
-        else{
+        } else {
             echo "can not open csv file. ";
-        }   
+        }
 
-        // 提交更改 
+        // 提交更改
         $dbh->commit();
         if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
             $error = $dbh->errorInfo();
             echo "error - $error[2] <br>";
-        }
-        else{
+        } else {
             echo "updata $count recorders.";
         }
 
         $dbh = null;
 
-    break;
+        break;
 }
-?>

+ 35 - 37
app/install/step4.php

@@ -20,49 +20,47 @@ require_once 'nav_bar.php';
 <div>
 <h4>生成数据库文件</h4>
 <?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/";
+$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>"; 
+if (isset($_GET["index"])) {
+    echo '<div style="padding:10px;margin:5px;border-bottom: 1px solid gray;background-color:yellow;">';
+    $index = $_GET["index"];
+    $dns = "" . $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>";
 }
 
-
-for($i=0; $i<count($dbfile); $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])){
+for ($i = 0; $i < count($dbfile); $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 "</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>";
+        echo '<div style="flex:2;"><a href="step4.php?index=' . $i . '">重建</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
     }
-	echo "</div>";  
+    echo "</div>";
 }
 ?>
 

+ 139 - 149
app/install/step5.php

@@ -26,35 +26,35 @@ require_once 'nav_bar.php';
      └3rd
 	 └system
    └palicanon
- └user 
+ └user
  </pre>
 </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");
-$dbfile[]=array(_FILE_DB_RESRES_INDEX_,"res.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>"; 
+$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");
+$dbfile[] = array(_FILE_DB_RESRES_INDEX_, "res.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 = "" . $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>";
 }
 ?>
 
@@ -67,24 +67,22 @@ echo "</div>";
 <div class="card">
 <h4>逐词解析模板数据库</h4>
 <?php
-if(file_exists(_DIR_PALICANON_TEMPLET_)){
-	$iCount=0;
-	for($i=1;$i<=217;$i++){
-		if(file_exists(_DIR_PALICANON_TEMPLET_."/p{$i}_tpl.db3")){
-			$iCount++;
-		}
-	}
-	if($iCount==217){
-		echo "文件已经存在。<br>";
-		echo '<a href="db_insert_templet.php">重新生成数据库</a>';
-	}
-	else{
-		echo "缺少".(217-$iCount)."个文件<br>";
-		echo '<a href="db_insert_templet.php">生成数据库</a>';
-	}
-}
-else{
-	echo "模板数据库目录不存在<br>";
+if (file_exists(_DIR_PALICANON_TEMPLET_)) {
+    $iCount = 0;
+    for ($i = 1; $i <= 217; $i++) {
+        if (file_exists(_DIR_PALICANON_TEMPLET_ . "/p{$i}_tpl.db3")) {
+            $iCount++;
+        }
+    }
+    if ($iCount == 217) {
+        echo "文件已经存在。<br>";
+        echo '<a href="db_insert_templet.php">重新生成数据库</a>';
+    } else {
+        echo "缺少" . (217 - $iCount) . "个文件<br>";
+        echo '<a href="db_insert_templet.php">生成数据库</a>';
+    }
+} else {
+    echo "模板数据库目录不存在<br>";
 }
 ?>
 </div>
@@ -92,31 +90,30 @@ else{
 <div class="card">
 	<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="step5.php?index='.$i.'">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
-		}
-		echo "</div>";  
-	}
-	?>
+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="step5.php?index=' . $i . '">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+    }
+    echo "</div>";
+}
+?>
 	?>
 	<div class="contence">
 	<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_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_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>
 
@@ -126,22 +123,21 @@ else{
 <div class="card">
 	<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="step5.php?index=0">建立</a></div>';    
-	}
-	else{
-        echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step5.php?index=0">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
-    }
-	echo "</div>";  
-	?>
+$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="step5.php?index=0">建立</a></div>';
+} else {
+    echo "<span style='color:green;'>已存在</span>";
+    echo "</div>";
+    echo '<div style="flex:2;"><a href="step5.php?index=0">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+}
+echo "</div>";
+?>
 	<div class="contence">
 	<a href="db_insert_bold.php" target="_blank">生成</a>
 	</div>
@@ -150,29 +146,27 @@ else{
 <div class="card">
 <h4>Pali句子库</h4>
 <?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="step5.php?index=5">建立</a></div>';    
-	}
-	else{
-        echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step5.php?index=5">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
-    }
-	echo "</div>";  
-
-if(file_exists(_FILE_DB_PALI_SENTENCE_)){
-	echo "Pali句子数据库已经存在<br>";
-	echo '<a href="db_insert_sentence.php">重新生成</a>';
+$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="step5.php?index=5">建立</a></div>';
+} else {
+    echo "<span style='color:green;'>已存在</span>";
+    echo "</div>";
+    echo '<div style="flex:2;"><a href="step5.php?index=5">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
 }
-else{
-	echo "Pali句子数据库不存在<br>";
-	echo '<a href="db_insert_sentence.php">生成</a>';
+echo "</div>";
+
+if (file_exists(_FILE_DB_PALI_SENTENCE_)) {
+    echo "Pali句子数据库已经存在<br>";
+    echo '<a href="db_insert_sentence.php">重新生成</a>';
+} else {
+    echo "Pali句子数据库不存在<br>";
+    echo '<a href="db_insert_sentence.php">生成</a>';
 }
 ?>
 </div>
@@ -181,31 +175,29 @@ else{
 <h4>Pali原文库</h4>
 <div>
 <?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="step5.php?index=6">建立</a></div>';    
-	}
-	else{
-        echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step5.php?index=6">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
-    }
-	echo "</div>";  
-
-if(file_exists(_FILE_DB_PALITEXT_)){
-	echo "Pali原文数据库已经存在<br>";
-	echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
-	echo '<a href="db_update_palitext.php" target="_blank">更新</a><br>';
+$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="step5.php?index=6">建立</a></div>';
+} else {
+    echo "<span style='color:green;'>已存在</span>";
+    echo "</div>";
+    echo '<div style="flex:2;"><a href="step5.php?index=6">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
 }
-else{
-	echo '<a href="db_insert_palitext.php">生成</a><br>';
+echo "</div>";
+
+if (file_exists(_FILE_DB_PALITEXT_)) {
+    echo "Pali原文数据库已经存在<br>";
+    echo '<a href="db_insert_palitext.php" target="_blank">重新生成</a><br>';
+    echo '<a href="db_update_palitext.php" target="_blank">更新</a><br>';
+} else {
+    echo '<a href="db_insert_palitext.php">生成</a><br>';
 }
-echo "<a href = '"._DIR_LOG_."/db_update_palitext.log"."' target='_blank'>view Log</a>"
+echo "<a href = '" . _DIR_LOG_ . "/db_update_palitext.log" . "' target='_blank'>view Log</a>"
 ?>
 </div>
 </div>
@@ -215,31 +207,29 @@ echo "<a href = '"._DIR_LOG_."/db_update_palitext.log"."' target='_blank'>view L
 <h4>标题索引</h4>
 <div>
 <?php
-	$db = $dbfile[7];
-	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="step5.php?index=7">建立</a></div>'; 
-	}
-	else{
-        echo "<span style='color:green;'>已存在</span>";
-    	echo "</div>"; 
-        echo '<div style="flex:2;"><a href="step5.php?index=7">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
-    }
-	echo "</div>";  
-
-	if(file_exists(_FILE_DB_PALITEXT_)){
-		echo "标题索引数据库已经存在<br>";
-		echo '<a href="db_update_toc.php" target="_blank">更新</a><br>';
-	}
-	else{
-		echo "标题索引数据库不存在<br>";
-		echo '<div style="flex:2;"><a href="step5.php?index='.$i.'">建立</a></div>'; 
-	}
-echo "<a href = '"._DIR_LOG_."/db_update_title.log"."' target='_blank'>view Log</a>"
+$db = $dbfile[7];
+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="step5.php?index=7">建立</a></div>';
+} else {
+    echo "<span style='color:green;'>已存在</span>";
+    echo "</div>";
+    echo '<div style="flex:2;"><a href="step5.php?index=7">清空</a><span style="color:red;">注意!此操作将删除原数据库中所有数据!</span></div>';
+}
+echo "</div>";
+
+if (file_exists(_FILE_DB_PALITEXT_)) {
+    echo "标题索引数据库已经存在<br>";
+    echo '<a href="db_update_toc.php" target="_blank">更新</a><br>';
+} else {
+    echo "标题索引数据库不存在<br>";
+    echo '<div style="flex:2;"><a href="step5.php?index=' . $i . '">建立</a></div>';
+}
+echo "<a href = '" . _DIR_LOG_ . "/db_update_title.log" . "' target='_blank'>view Log</a>"
 ?>
 </div>
 </div>

+ 29 - 31
app/lib/fullcalendar/php/get-date.php

@@ -4,36 +4,34 @@
 require_once "../../../path.php";
 require_once "../../../public/_pdo.php";
 
-function get_teacher_course($teacher_id){
-
-		$teacher = "  ";
-
-	global $PDO;
-	PDO_Connect("sqlite:"._FILE_DB_COURSE_);
-	
-	$query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
-
-	$Fetch = PDO_FetchAll($query,array($teacher_id));
-	
-	$output = array();
-	foreach ($Fetch as $key => $couse) {
-		# code...
-		$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
-		$fAllLesson = PDO_FetchAll($query);
-		foreach ($fAllLesson as  $lesson) {
-			$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
-			$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
-			$output[]=array("id"=>$lesson["id"],
-										"title"=>$couse["title"],
-										"url"=>"../../course/lesson.php?id=".$lesson["id"],
-										"start"=> $start,
-										"end"=>$end
-									);
-		}
-	}
-	return($output);
-	
-}
+function get_teacher_course($teacher_id)
+{
+
+    $teacher = "  ";
+
+    global $PDO;
+    PDO_Connect("" . _FILE_DB_COURSE_);
 
+    $query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
 
-?>
+    $Fetch = PDO_FetchAll($query, array($teacher_id));
+
+    $output = array();
+    foreach ($Fetch as $key => $couse) {
+        # code...
+        $query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
+        $fAllLesson = PDO_FetchAll($query);
+        foreach ($fAllLesson as $lesson) {
+            $start = date("Y-m-d\TH:i:s+00:00", $lesson["date"] / 1000);
+            $end = date("Y-m-d\TH:i:s+00:00", $lesson["date"] / 1000 + $lesson["duration"]);
+            $output[] = array("id" => $lesson["id"],
+                "title" => $couse["title"],
+                "url" => "../../course/lesson.php?id=" . $lesson["id"],
+                "start" => $start,
+                "end" => $end,
+            );
+        }
+    }
+    return ($output);
+
+}

+ 7 - 8
app/media/function.php

@@ -1,10 +1,11 @@
 <?php
 require_once '../path.php';
-function media_get($idlist){
+function media_get($idlist)
+{
     //打开数据库
-    $dns = "sqlite:"._FILE_DB_MEDIA_;
-    $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+    $dns = "" . _FILE_DB_MEDIA_;
+    $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     /*  使用一个数组的值执行一条含有 IN 子句的预处理语句 */
     /*  创建一个填充了和params相同数量占位符的字符串 */
@@ -14,9 +15,7 @@ function media_get($idlist){
     $stmt = $dbh->prepare($query);
     $stmt->execute($idlist);
     $fMedia = $stmt->fetchAll(PDO::FETCH_ASSOC);
-    $dbh=null;
-    return($fMedia);
+    $dbh = null;
+    return ($fMedia);
 
 }
-
-?>

+ 35 - 44
app/media/get.php

@@ -1,50 +1,41 @@
 <?php
-    require_once '../path.php';
-    //打开数据库
-    $dns = "sqlite:"._FILE_DB_MEDIA_;
-    $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+require_once '../path.php';
+//打开数据库
+$dns = "" . _FILE_DB_MEDIA_;
+$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-    if(isset($_GET["id"])){
-        $query = "SELECT * FROM media WHERE id = ? limit 0 , 1";
-        $stmt = $dbh->prepare($query);
-        $stmt->execute(array($_GET["id"]));
-        $fMedia = $stmt->fetchAll(PDO::FETCH_ASSOC);
-        $dbh=null;
-        if(count($fMedia)>0){
-            $imgLink = $fMedia[0]["link"];
-            if(substr($imgLink,0,6)=="media:"){
-                echo _DIR_USER_IMG_.'/'.substr($imgLink,6);
-            }
-            else{
-                echo $imgLink;
-            }
+if (isset($_GET["id"])) {
+    $query = "SELECT * FROM media WHERE id = ? limit 0 , 1";
+    $stmt = $dbh->prepare($query);
+    $stmt->execute(array($_GET["id"]));
+    $fMedia = $stmt->fetchAll(PDO::FETCH_ASSOC);
+    $dbh = null;
+    if (count($fMedia) > 0) {
+        $imgLink = $fMedia[0]["link"];
+        if (substr($imgLink, 0, 6) == "media:") {
+            echo _DIR_USER_IMG_ . '/' . substr($imgLink, 6);
+        } else {
+            echo $imgLink;
         }
-        else{
-            echo "";
-        }        
+    } else {
+        echo "";
     }
-    else{
-        $query = "SELECT id , link  FROM media WHERE type = '3' order by create_time DESC limit 0 , 10 ";
-        $stmt = $dbh->prepare($query);
-        $stmt->execute(array());
-        $fMedia = $stmt->fetchAll(PDO::FETCH_ASSOC);
-        $dbh=null;
-        if(count($fMedia)>0){
-            
-            $imgLink = $fMedia[0]["link"];
-            if(substr($imgLink,0,6)=="media:"){
-                echo _DIR_USER_IMG_.'/'.substr($imgLink,6);
-            }
-            else{
-                echo $imgLink;
-            }
+} else {
+    $query = "SELECT id , link  FROM media WHERE type = '3' order by create_time DESC limit 0 , 10 ";
+    $stmt = $dbh->prepare($query);
+    $stmt->execute(array());
+    $fMedia = $stmt->fetchAll(PDO::FETCH_ASSOC);
+    $dbh = null;
+    if (count($fMedia) > 0) {
+
+        $imgLink = $fMedia[0]["link"];
+        if (substr($imgLink, 0, 6) == "media:") {
+            echo _DIR_USER_IMG_ . '/' . substr($imgLink, 6);
+        } else {
+            echo $imgLink;
         }
-        else{
-            echo "";
-        }         
+    } else {
+        echo "";
     }
-
-    
-
-?>
+}

+ 40 - 47
app/nissaya/get.php

@@ -3,58 +3,51 @@ require_once "../public/_pdo.php";
 require_once "../path.php";
 require_once "../ucenter/active.php";
 
-$result["error"]="";
-$result["data"]=array();
+$result["error"] = "";
+$result["data"] = array();
 
-if(isset($_GET["book"])){
-	$book = $_GET["book"];
-}
-else{
-	$result["error"]="no param";
-	echo json_encode($result,JSON_UNESCAPED_UNICODE);
-	exit;
-}
-if(isset($_GET["para"])){
-	$para = $_GET["para"];
-}
-else{
-	$result["error"]="no param";
-	echo json_encode($result,JSON_UNESCAPED_UNICODE);
-	exit;
+if (isset($_GET["book"])) {
+    $book = $_GET["book"];
+} else {
+    $result["error"] = "no param";
+    echo json_encode($result, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+if (isset($_GET["para"])) {
+    $para = $_GET["para"];
+} else {
+    $result["error"] = "no param";
+    echo json_encode($result, JSON_UNESCAPED_UNICODE);
+    exit;
 }
 
-if(isset($_GET["begin"])){
-	$begin = $_GET["begin"];
-}
-else{
-	$begin = 0;
+if (isset($_GET["begin"])) {
+    $begin = $_GET["begin"];
+} else {
+    $begin = 0;
 }
-if(isset($_GET["end"])){
-	$end = $_GET["end"];
+if (isset($_GET["end"])) {
+    $end = $_GET["end"];
+} else {
+    $end = 0;
 }
-else{
-	$end = 0;
-}
-add_edit_event(_NISSAYA_FIND_,"{$book}-{$para}-{$begin}-{$end}");
+add_edit_event(_NISSAYA_FIND_, "{$book}-{$para}-{$begin}-{$end}");
 
-PDO_Connect("sqlite:"._FILE_DB_PAGE_INDEX_);
+PDO_Connect("" . _FILE_DB_PAGE_INDEX_);
 $query = "SELECT * from m where book=? and para=?";
-$Fetch = PDO_FetchAll($query,array($book,$para));
-
-foreach ($Fetch as $key => $value){
-	$query = "SELECT * from book_match where book_vri=? and vol=?";
-	$Fetch_nsy_book = PDO_FetchRow($query,array($value["book"],$value["page1"]));
-	if($Fetch_nsy_book){
-		$prefix = $Fetch_nsy_book["table"];
-		$query = "SELECT * from {$prefix}_pagematch where bookid=? and bookpagenumber=?";
-		$Fetch_nsy_index = PDO_FetchRow($query,array($Fetch_nsy_book["bookid"],$value["page2"]));
-		$Fetch_nsy_index["dir"]=$prefix;
-		$result["data"][] = $Fetch_nsy_index;
-	}
-	else{
-		$result["error"]= "error: in table book_match";
-	}
-}
-echo json_encode($result,JSON_UNESCAPED_UNICODE);
+$Fetch = PDO_FetchAll($query, array($book, $para));
 
-?>
+foreach ($Fetch as $key => $value) {
+    $query = "SELECT * from book_match where book_vri=? and vol=?";
+    $Fetch_nsy_book = PDO_FetchRow($query, array($value["book"], $value["page1"]));
+    if ($Fetch_nsy_book) {
+        $prefix = $Fetch_nsy_book["table"];
+        $query = "SELECT * from {$prefix}_pagematch where bookid=? and bookpagenumber=?";
+        $Fetch_nsy_index = PDO_FetchRow($query, array($Fetch_nsy_book["bookid"], $value["page2"]));
+        $Fetch_nsy_index["dir"] = $prefix;
+        $result["data"][] = $Fetch_nsy_index;
+    } else {
+        $result["error"] = "error: in table book_match";
+    }
+}
+echo json_encode($result, JSON_UNESCAPED_UNICODE);

+ 23 - 26
app/pali_sent/get_sim.php

@@ -1,48 +1,45 @@
 <?php
 /*
 get user sentence from db
-*/
+ */
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
 //获取相似句子列表
 
-if(isset($_POST["sent_id"])){
-	$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_SIM_;
-	$dbh_sim = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-	$dbh_sim->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 
-	$query="SELECT sent2 FROM sent_sim WHERE  sent1 = ? limit 0 , 10";
-	$stmt = $dbh_sim->prepare($query);
-	$stmt->execute(array($_POST["sent_id"]));
-	$simList = $stmt->fetchAll(PDO::FETCH_ASSOC);
-}
-else{
-	$sim = $_POST["sim"];
-	$simList = json_decode($sim);
+if (isset($_POST["sent_id"])) {
+    $dns = "" . _FILE_DB_PALI_SENTENCE_SIM_;
+    $dbh_sim = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dbh_sim->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+    $query = "SELECT sent2 FROM sent_sim WHERE  sent1 = ? limit 0 , 10";
+    $stmt = $dbh_sim->prepare($query);
+    $stmt->execute(array($_POST["sent_id"]));
+    $simList = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} else {
+    $sim = $_POST["sim"];
+    $simList = json_decode($sim);
 
 }
 $output = array();
 
-$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
-$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+$dns = "" . _FILE_DB_PALI_SENTENCE_;
+$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$query="SELECT * FROM pali_sent WHERE  id = ? ";
+$query = "SELECT * FROM pali_sent WHERE  id = ? ";
 $stmt = $dbh->prepare($query);
 $count = 0;
-foreach ($simList as  $value) {
+foreach ($simList as $value) {
     # code...
     $stmt->execute(array($value["sent2"]));
-	$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
-	if($Fetch){
-		$sent = $Fetch;
-		$sent["path"]=_get_para_path($Fetch["book"],$Fetch["paragraph"]);
-		$output[] = $sent;  
-	}
+    $Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+    if ($Fetch) {
+        $sent = $Fetch;
+        $sent["path"] = _get_para_path($Fetch["book"], $Fetch["paragraph"]);
+        $output[] = $sent;
+    }
 
 }
 
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-
-?>

+ 251 - 239
app/pali_sent/pali_sent.php

@@ -4,285 +4,297 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 
 //is login
-if(isset($_COOKIE["username"]) && !empty($_COOKIE["username"])){
-	$username = $_COOKIE["username"];
-}
-else{
-	$username = "";
+if (isset($_COOKIE["username"]) && !empty($_COOKIE["username"])) {
+    $username = $_COOKIE["username"];
+} else {
+    $username = "";
 }
 
-if(isset($_GET["op"])){
-	$_op=$_GET["op"];
-}
-else if(isset($_POST["op"])){
-	$_op=$_POST["op"];
+if (isset($_GET["op"])) {
+    $_op = $_GET["op"];
+} else if (isset($_POST["op"])) {
+    $_op = $_POST["op"];
 }
-if(isset($_GET["word"])){
-	$_word=mb_strtolower($_GET["word"],'UTF-8');
+if (isset($_GET["word"])) {
+    $_word = mb_strtolower($_GET["word"], 'UTF-8');
 
 }
 
-if(isset($_GET["id"])){
-	$_id=$_GET["id"];
+if (isset($_GET["id"])) {
+    $_id = $_GET["id"];
 }
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_PALI_SENTENCE_);
+PDO_Connect("" . _FILE_DB_PALI_SENTENCE_);
 
-if(isset($_GET["sent"])){
-	$_sent=mb_strtolower($_GET["sent"],'UTF-8');
+if (isset($_GET["sent"])) {
+    $_sent = mb_strtolower($_GET["sent"], 'UTF-8');
 }
 
 // 输入一个句子,输出整个句子的单词 array
-function words_of_sentence(string $sent) {
-	$words = preg_split("/[ \.\[\]\{\}\-,';‘’–0123456789]+/", $sent); // 去除标点、数字
-	$words = array_filter($words);  // 去除空词
-	$words = array_filter($words, function($item) { 
-		if ($item != 'ca' && $item != 'vā' && $item != 'na') return $item; }); // 去除 ca, vā 和 na
-	return $words;
+function words_of_sentence(string $sent)
+{
+    $words = preg_split("/[ \.\[\]\{\}\-,';‘’–0123456789]+/", $sent); // 去除标点、数字
+    $words = array_filter($words); // 去除空词
+    $words = array_filter($words, function ($item) {
+        if ($item != 'ca' && $item != 'vā' && $item != 'na') {
+            return $item;
+        }
+    }); // 去除 ca, vā 和 na
+    return $words;
 }
 
 // 采用 jaccard 相似度,考虑到圣典中的相似句单词、句式都是非常接近的
-function jaccard_similarity($words_of_sent1, $words_of_sent2) {
-	$intersect = count(array_intersect($words_of_sent1, $words_of_sent2));
-	$union = count($words_of_sent1)+count($words_of_sent2)-$intersect;
-	if ($union) {
-		return $intersect / $union;
-	} else {
-		return 0;
-	}
+function jaccard_similarity($words_of_sent1, $words_of_sent2)
+{
+    $intersect = count(array_intersect($words_of_sent1, $words_of_sent2));
+    $union = count($words_of_sent1) + count($words_of_sent2) - $intersect;
+    if ($union) {
+        return $intersect / $union;
+    } else {
+        return 0;
+    }
 }
 
 // 带顺序的 jaccard 算法,当前效果一般,TODO: 切片相同时加入得分
-function ordered_jaccard_similarity($words_of_sent1, $words_of_sent2) {
-	$score = 0;
-	$k = min(count($words_of_sent1), count($words_of_sent2));
-	for ($i=1; $i<$k; $i++) {
-		$score += jaccard_similarity(
-			array_slice($words_of_sent1, 0, $i),
-			array_slice($words_of_sent2, 0, $i));
-	}
-	return $score / $k;
+function ordered_jaccard_similarity($words_of_sent1, $words_of_sent2)
+{
+    $score = 0;
+    $k = min(count($words_of_sent1), count($words_of_sent2));
+    for ($i = 1; $i < $k; $i++) {
+        $score += jaccard_similarity(
+            array_slice($words_of_sent1, 0, $i),
+            array_slice($words_of_sent2, 0, $i));
+    }
+    return $score / $k;
 }
 
 // 定义一个链表节点,方便 sim_sent_id 按照相似度插入
-class sim_sent_node {
-	public $id;
-	public $jaccard_score;
-	public $next;
-
-	public function __construct($id = null, $jaccard_score = null, $next = null) {
-		$this->id = $id;
-		$this->jaccard_score = $jaccard_score;
-		$this->next = $next;
-	}
+class sim_sent_node
+{
+    public $id;
+    public $jaccard_score;
+    public $next;
+
+    public function __construct($id = null, $jaccard_score = null, $next = null)
+    {
+        $this->id = $id;
+        $this->jaccard_score = $jaccard_score;
+        $this->next = $next;
+    }
 }
 
 // 定义链表
-class sim_sent_list {
-	public $head;    // 头节点,默认一个虚头节点
-	public $size;
-
-	public function __construct() {
-		$this->head = new sim_sent_node();
-		$this->size = 0;
-	}
-
-	// 按照 jaccard_score 相似度插入
-	public function jaccard_add($id, $jaccard_score) {
-		$prev = $this->head;
-		while ($prev->next != null && $prev->next->jaccard_score > $jaccard_score) {
-			$prev = $prev->next;
-		}
-		$prev->next = new sim_sent_node($id, $jaccard_score, $prev->next);
-		$this->size++;
-	}
-
-	public function get_text_list() {
-		$prev = $this->head;
-		if ($this->size == 0) {
-			return;
-		}
-
-		$ids = "";
-		while ($prev->next != null) {
-			$ids = $ids.",".$prev->next->id;
-			$prev = $prev->next;
-		}
-		$ids = substr($ids, 1); // 去掉第一个逗号
-		return $ids;
-	}
-
-	public function print_list() {
-		$prev = $this->head;
-		if ($this->size == 0) {
-			return;
-		}
-		while ($prev->next != null) {
-			print($prev->next->id."\t".$prev->next->jaccard_score."\n");
-			$prev = $prev->next;
-		}
-	}
+class sim_sent_list
+{
+    public $head; // 头节点,默认一个虚头节点
+    public $size;
+
+    public function __construct()
+    {
+        $this->head = new sim_sent_node();
+        $this->size = 0;
+    }
+
+    // 按照 jaccard_score 相似度插入
+    public function jaccard_add($id, $jaccard_score)
+    {
+        $prev = $this->head;
+        while ($prev->next != null && $prev->next->jaccard_score > $jaccard_score) {
+            $prev = $prev->next;
+        }
+        $prev->next = new sim_sent_node($id, $jaccard_score, $prev->next);
+        $this->size++;
+    }
+
+    public function get_text_list()
+    {
+        $prev = $this->head;
+        if ($this->size == 0) {
+            return;
+        }
+
+        $ids = "";
+        while ($prev->next != null) {
+            $ids = $ids . "," . $prev->next->id;
+            $prev = $prev->next;
+        }
+        $ids = substr($ids, 1); // 去掉第一个逗号
+        return $ids;
+    }
+
+    public function print_list()
+    {
+        $prev = $this->head;
+        if ($this->size == 0) {
+            return;
+        }
+        while ($prev->next != null) {
+            print($prev->next->id . "\t" . $prev->next->jaccard_score . "\n");
+            $prev = $prev->next;
+        }
+    }
 }
 
 // 将相似句列表存入数据库
-function insert_similar_sent_list_into_sqlite($current_id, $text_list) {
-	/* 使用这部分代码先为数据库添加一个 sim_sents 字段
-	$add_column = "ALTER TABLE pali_sent ADD COLUMN sim_sents TEXT";
-	$Action_add = PDO_Execute($add_column);
-	$query = "PRAGMA TABLE_INFO (pali_sent)";
-	$Fetch = PDO_FetchALL($query);
-	print_r($Fetch);
-	*/
-	global $PDO;
-	$Update = "UPDATE pali_sent SET sim_sents = ".$PDO->quote($text_list)." WHERE id = ".$current_id;
-	$Result = PDO_Execute($Update);
-	return;
+function insert_similar_sent_list_into_sqlite($current_id, $text_list)
+{
+    /* 使用这部分代码先为数据库添加一个 sim_sents 字段
+    $add_column = "ALTER TABLE pali_sent ADD COLUMN sim_sents TEXT";
+    $Action_add = PDO_Execute($add_column);
+    $query = "PRAGMA TABLE_INFO (pali_sent)";
+    $Fetch = PDO_FetchALL($query);
+    print_r($Fetch);
+     */
+    global $PDO;
+    $Update = "UPDATE pali_sent SET sim_sents = " . $PDO->quote($text_list) . " WHERE id = " . $current_id;
+    $Result = PDO_Execute($Update);
+    return;
 }
 
 // 预计算,存入数据库
-function similar_sent_matrix() {
-	// 按照 count = 18, 8, ..., 255 依次获得查询结果 (i-3,i+3)
-	//          count = 17,16,...,7                                       (i-2,i+2)
-	for ($current_count=17; $current_count > 7; $current_count--) { 
-		print("单词数:".$current_count."\n");
-		$current_query = "select id,text from pali_sent where count=".$current_count;
-		$Current = PDO_FetchAll($current_query);
-		if (count($Current)) {
-			foreach($Current as $current_row) {
-				$current_id = $current_row['id'];
-				$current_sent = $current_row['text'];
-				$current_words = words_of_sentence($current_sent);
-				
-				// 按照 count > $current_count-3 and count <$current_count+3 查询希望比较的语句
-				$compare_query = "select id,text from pali_sent where count>".($current_count-2)." and count<".($current_count+2);
-				$Compare = PDO_FetchALL($compare_query);
-
-				$current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
-				foreach($Compare as $compare_row) {
-					if ($current_row != $compare_row) {
-						$compare_id = $compare_row['id'];
-						$compare_sent = $compare_row['text'];
-						$compare_words = words_of_sentence($compare_sent);
-
-						$jaccard_score = jaccard_similarity($current_words, $compare_words);
-						if ($jaccard_score > 0.3) {
-							$current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
-						}
-					}
-				} // end of foreach $compare_row
-
-				if ($current_sim_sent_list->size != 0) {
-					print("update ".$current_id."\n");
-					$text_list = $current_sim_sent_list->get_text_list();
-					insert_similar_sent_list_into_sqlite($current_id, $text_list);
-				}
-			} // end of foreach $current_row
-		}
-	}
-	return;
+function similar_sent_matrix()
+{
+    // 按照 count = 18, 8, ..., 255 依次获得查询结果 (i-3,i+3)
+    //          count = 17,16,...,7                                       (i-2,i+2)
+    for ($current_count = 17; $current_count > 7; $current_count--) {
+        print("单词数:" . $current_count . "\n");
+        $current_query = "select id,text from pali_sent where count=" . $current_count;
+        $Current = PDO_FetchAll($current_query);
+        if (count($Current)) {
+            foreach ($Current as $current_row) {
+                $current_id = $current_row['id'];
+                $current_sent = $current_row['text'];
+                $current_words = words_of_sentence($current_sent);
+
+                // 按照 count > $current_count-3 and count <$current_count+3 查询希望比较的语句
+                $compare_query = "select id,text from pali_sent where count>" . ($current_count - 2) . " and count<" . ($current_count + 2);
+                $Compare = PDO_FetchALL($compare_query);
+
+                $current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
+                foreach ($Compare as $compare_row) {
+                    if ($current_row != $compare_row) {
+                        $compare_id = $compare_row['id'];
+                        $compare_sent = $compare_row['text'];
+                        $compare_words = words_of_sentence($compare_sent);
+
+                        $jaccard_score = jaccard_similarity($current_words, $compare_words);
+                        if ($jaccard_score > 0.3) {
+                            $current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
+                        }
+                    }
+                } // end of foreach $compare_row
+
+                if ($current_sim_sent_list->size != 0) {
+                    print("update " . $current_id . "\n");
+                    $text_list = $current_sim_sent_list->get_text_list();
+                    insert_similar_sent_list_into_sqlite($current_id, $text_list);
+                }
+            } // end of foreach $current_row
+        }
+    }
+    return;
 }
 
 // 实时计算相似句
-function sents_similar_to_id($id) {
-	$query = "SELECT count,text FROM pali_sent WHERE id=".$id;
-	$Current = PDO_FetchALL($query);
-	if (count($Current)) {
-		foreach($Current as $current_row) {
-			$current_count = $current_row['count'];
-			$current_sent = $current_row['text'];
-			$current_words = words_of_sentence($current_sent);
-			print("current text: \n".$current_sent."\n");
-
-			if ($current_count <= 5) {
-				print("[-] too short.\n");
-				return;
-			}
-
-			// 只和单词数大于 5 的比较
-			$compare_query = "SELECT id,text FROM pali_sent WHERE count>5";
-			$Compare = PDO_FetchALL($compare_query);
-
-			$current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
-			foreach($Compare as $compare_row) {
-				if ($current_row != $compare_row) {
-					$compare_id = $compare_row['id'];
-					$compare_sent = $compare_row['text'];
-					$compare_words = words_of_sentence($compare_sent);
-
-					$jaccard_score = jaccard_similarity($current_words, $compare_words);
-					if ($jaccard_score > 0.3) {
-						print("Jaccard similarity: ".$jaccard_score."\tSentence id:".$compare_id."\n");
-						print("Text: \n". $compare_sent."\n");
-						$current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
-					}
-				}
-			} // end of foreach $compare_row
-
-			if ($current_sim_sent_list->size != 0) {
-				// $current_sim_sent_list->print_list();
-			} else {
-				print("[-]not found.\n");
-			}
-
-		} // end of foreach($Current)
-	} // end of if (count($Current))
+function sents_similar_to_id($id)
+{
+    $query = "SELECT count,text FROM pali_sent WHERE id=" . $id;
+    $Current = PDO_FetchALL($query);
+    if (count($Current)) {
+        foreach ($Current as $current_row) {
+            $current_count = $current_row['count'];
+            $current_sent = $current_row['text'];
+            $current_words = words_of_sentence($current_sent);
+            print("current text: \n" . $current_sent . "\n");
+
+            if ($current_count <= 5) {
+                print("[-] too short.\n");
+                return;
+            }
+
+            // 只和单词数大于 5 的比较
+            $compare_query = "SELECT id,text FROM pali_sent WHERE count>5";
+            $Compare = PDO_FetchALL($compare_query);
+
+            $current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
+            foreach ($Compare as $compare_row) {
+                if ($current_row != $compare_row) {
+                    $compare_id = $compare_row['id'];
+                    $compare_sent = $compare_row['text'];
+                    $compare_words = words_of_sentence($compare_sent);
+
+                    $jaccard_score = jaccard_similarity($current_words, $compare_words);
+                    if ($jaccard_score > 0.3) {
+                        print("Jaccard similarity: " . $jaccard_score . "\tSentence id:" . $compare_id . "\n");
+                        print("Text: \n" . $compare_sent . "\n");
+                        $current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
+                    }
+                }
+            } // end of foreach $compare_row
+
+            if ($current_sim_sent_list->size != 0) {
+                // $current_sim_sent_list->print_list();
+            } else {
+                print("[-]not found.\n");
+            }
+
+        } // end of foreach($Current)
+    } // end of if (count($Current))
 }
 
 $id = $argv[1];
 //sents_similar_to_id($id);
 
 if (!isset($_op)) {
-	exit(0);
+    exit(0);
 }
 
-switch($_op){
-	case "get":
-	{
-		$Fetch=array();
-		if(isset($_word)){
-			$queryWord = str_replace(" ","",$_word);
-			$query = "select book,paragraph,text from pali_sent where \"real\" like ".$PDO->quote("%".$queryWord.'%')." limit 0,5";
-			$Fetch = PDO_FetchAll($query);
-			$newList = array();
-			//去掉重复的
-			foreach($Fetch as $onerow){
-				$found=false;
-				foreach($newList as $new){
-					if($onerow["text"]==$new["text"]){
-						$found=true;
-						break;
-					}
-				}
-				if($found==false){
-					array_push($newList,$onerow);
-				}
-			}
-			$Fetch = $newList;
-
-			if(count($Fetch)<5){
-				$query = "select text from pali_sent where \"real_en\" like ".$PDO->quote('%'.$queryWord.'%')." limit 0,5";
-				$Fetch2 = PDO_FetchAll($query);
-				//去掉重复的
-				foreach($Fetch2 as $onerow){
-					$found=false;
-					foreach($Fetch as $oldArray){
-						if($onerow["word"]==$oldArray["word"]){
-							$found=true;
-							break;
-						}
-					}
-					if($found==false){
-						array_push($Fetch,$onerow);
-					}
-				}
-			}
-			
-		}
-		else if(isset($_id)){
-		}
-		echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
-		break;
-	}
+switch ($_op) {
+    case "get":
+        {
+            $Fetch = array();
+            if (isset($_word)) {
+                $queryWord = str_replace(" ", "", $_word);
+                $query = "select book,paragraph,text from pali_sent where \"real\" like " . $PDO->quote("%" . $queryWord . '%') . " limit 0,5";
+                $Fetch = PDO_FetchAll($query);
+                $newList = array();
+                //去掉重复的
+                foreach ($Fetch as $onerow) {
+                    $found = false;
+                    foreach ($newList as $new) {
+                        if ($onerow["text"] == $new["text"]) {
+                            $found = true;
+                            break;
+                        }
+                    }
+                    if ($found == false) {
+                        array_push($newList, $onerow);
+                    }
+                }
+                $Fetch = $newList;
+
+                if (count($Fetch) < 5) {
+                    $query = "select text from pali_sent where \"real_en\" like " . $PDO->quote('%' . $queryWord . '%') . " limit 0,5";
+                    $Fetch2 = PDO_FetchAll($query);
+                    //去掉重复的
+                    foreach ($Fetch2 as $onerow) {
+                        $found = false;
+                        foreach ($Fetch as $oldArray) {
+                            if ($onerow["word"] == $oldArray["word"]) {
+                                $found = true;
+                                break;
+                            }
+                        }
+                        if ($found == false) {
+                            array_push($Fetch, $onerow);
+                        }
+                    }
+                }
+
+            } else if (isset($_id)) {
+            }
+            echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
+            break;
+        }
 }
-?>

+ 9 - 11
app/pali_sent/pali_sent_list.php

@@ -1,7 +1,7 @@
 <?php
 /*
 get user sentence from db
-*/
+ */
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
@@ -11,21 +11,19 @@ $para = $_POST["para"];
 $paraList = json_decode($para);
 $output = array();
 
-$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
-$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+$dns = "" . _FILE_DB_PALI_SENTENCE_;
+$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$query="SELECT begin,end ,text FROM pali_sent WHERE (book = ?  AND paragraph = ?  ) ";
+$query = "SELECT begin,end ,text FROM pali_sent WHERE (book = ?  AND paragraph = ?  ) ";
 $stmt = $dbh->prepare($query);
 foreach ($paraList as $key => $value) {
     # code...
-    $stmt->execute(array($value->book,$value->para));
+    $stmt->execute(array($value->book, $value->para));
     $Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
-    $sent["info"]=array("book"=>$value->book,"para"=>$value->para);
-    $sent["data"]=$Fetch;
-    $output[] = $sent;  
+    $sent["info"] = array("book" => $value->book, "para" => $value->para);
+    $sent["data"] = $Fetch;
+    $output[] = $sent;
 }
 
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-
-?>

+ 219 - 212
app/pali_sent/sim_sent.php

@@ -4,262 +4,269 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_PALI_SENTENCE_);
+PDO_Connect("" . _FILE_DB_PALI_SENTENCE_);
 PDO_Execute("PRAGMA synchronous = OFF");
 PDO_Execute("PRAGMA journal_mode = WAL");
 PDO_Execute("PRAGMA foreign_keys = ON");
 PDO_Execute("PRAGMA busy_timeout = 5000");
 
-
 // 输入一个句子,输出整个句子的单词 array
-function words_of_sentence(string $sent) {
-	$words = preg_split("/[ \.\[\]\{\}\-,';‘’–0123456789]+/", $sent); // 去除标点、数字
-	$words = array_filter($words);  // 去除空词
-	$words = array_filter($words, function($item) { 
-		if ($item != 'ca' && $item != 'vā' && $item != 'na') return $item; }); // 去除 ca, vā 和 na
-	return $words;
+function words_of_sentence(string $sent)
+{
+    $words = preg_split("/[ \.\[\]\{\}\-,';‘’–0123456789]+/", $sent); // 去除标点、数字
+    $words = array_filter($words); // 去除空词
+    $words = array_filter($words, function ($item) {
+        if ($item != 'ca' && $item != 'vā' && $item != 'na') {
+            return $item;
+        }
+    }); // 去除 ca, vā 和 na
+    return $words;
 }
 
 // 采用 jaccard 相似度,考虑到圣典中的相似句单词、句式都是非常接近的
-function jaccard_similarity($words_of_sent1, $words_of_sent2) {
-	$intersect = count(array_intersect($words_of_sent1, $words_of_sent2));
-	$union = count($words_of_sent1)+count($words_of_sent2)-$intersect;
-	if ($union) {
-		return $intersect / $union;
-	} else {
-		return 0;
-	}
+function jaccard_similarity($words_of_sent1, $words_of_sent2)
+{
+    $intersect = count(array_intersect($words_of_sent1, $words_of_sent2));
+    $union = count($words_of_sent1) + count($words_of_sent2) - $intersect;
+    if ($union) {
+        return $intersect / $union;
+    } else {
+        return 0;
+    }
 }
 
 // 带顺序的 jaccard 算法,当前效果一般,TODO: 切片相同时加入得分
-function ordered_jaccard_similarity($words_of_sent1, $words_of_sent2) {
-	$score = 0;
-	$k = min(count($words_of_sent1), count($words_of_sent2));
-	for ($i=1; $i<$k; $i++) {
-		$score += jaccard_similarity(
-			array_slice($words_of_sent1, 0, $i),
-			array_slice($words_of_sent2, 0, $i));
-	}
-	return $score / $k;
+function ordered_jaccard_similarity($words_of_sent1, $words_of_sent2)
+{
+    $score = 0;
+    $k = min(count($words_of_sent1), count($words_of_sent2));
+    for ($i = 1; $i < $k; $i++) {
+        $score += jaccard_similarity(
+            array_slice($words_of_sent1, 0, $i),
+            array_slice($words_of_sent2, 0, $i));
+    }
+    return $score / $k;
 }
 
 // 定义一个链表节点,方便 sim_sent_id 按照相似度插入
-class sim_sent_node {
-	public $id;
-	public $jaccard_score;
-	public $next;
+class sim_sent_node
+{
+    public $id;
+    public $jaccard_score;
+    public $next;
 
-	public function __construct($id = null, $jaccard_score = null, $next = null) {
-		$this->id = $id;
-		$this->jaccard_score = $jaccard_score;
-		$this->next = $next;
-	}
+    public function __construct($id = null, $jaccard_score = null, $next = null)
+    {
+        $this->id = $id;
+        $this->jaccard_score = $jaccard_score;
+        $this->next = $next;
+    }
 }
 
 // 定义链表
-class sim_sent_list {
-	public $head;    // 头节点,默认一个虚头节点
-	public $size;
+class sim_sent_list
+{
+    public $head; // 头节点,默认一个虚头节点
+    public $size;
 
-	public function __construct() {
-		$this->head = new sim_sent_node();
-		$this->size = 0;
-	}
+    public function __construct()
+    {
+        $this->head = new sim_sent_node();
+        $this->size = 0;
+    }
 
-	// 按照 jaccard_score 相似度插入
-	public function jaccard_add($id, $jaccard_score) {
-		$prev = $this->head;
-		while ($prev->next != null && $prev->next->jaccard_score > $jaccard_score) {
-			$prev = $prev->next;
-		}
-		$prev->next = new sim_sent_node($id, $jaccard_score, $prev->next);
-		$this->size++;
-	}
+    // 按照 jaccard_score 相似度插入
+    public function jaccard_add($id, $jaccard_score)
+    {
+        $prev = $this->head;
+        while ($prev->next != null && $prev->next->jaccard_score > $jaccard_score) {
+            $prev = $prev->next;
+        }
+        $prev->next = new sim_sent_node($id, $jaccard_score, $prev->next);
+        $this->size++;
+    }
 
-	public function get_text_list() {
-		$prev = $this->head;
-		if ($this->size == 0) {
-			return;
-		}
+    public function get_text_list()
+    {
+        $prev = $this->head;
+        if ($this->size == 0) {
+            return;
+        }
 
-		$ids = "";
-		while ($prev->next != null) {
-			$ids = $ids.",".$prev->next->id;
-			$prev = $prev->next;
-		}
-		$ids = substr($ids, 1); // 去掉第一个逗号
-		return $ids;
-	}
+        $ids = "";
+        while ($prev->next != null) {
+            $ids = $ids . "," . $prev->next->id;
+            $prev = $prev->next;
+        }
+        $ids = substr($ids, 1); // 去掉第一个逗号
+        return $ids;
+    }
 
-	public function print_list() {
-		$prev = $this->head;
-		if ($this->size == 0) {
-			return;
-		}
-		while ($prev->next != null) {
-			print($prev->next->id."\t".$prev->next->jaccard_score."\n");
-			$prev = $prev->next;
-		}
-	}
+    public function print_list()
+    {
+        $prev = $this->head;
+        if ($this->size == 0) {
+            return;
+        }
+        while ($prev->next != null) {
+            print($prev->next->id . "\t" . $prev->next->jaccard_score . "\n");
+            $prev = $prev->next;
+        }
+    }
 }
 
 // 将相似句列表存入数据库
-function insert_similar_sent_list_into_sqlite($current_id, $text_list) {
-	/* 使用这部分代码先为数据库添加一个 sim_sents 字段
-	$add_column = "ALTER TABLE pali_sent ADD COLUMN sim_sents TEXT";
-	$Action_add = PDO_Execute($add_column);
-	$query = "PRAGMA TABLE_INFO (pali_sent)";
-	$Fetch = PDO_FetchALL($query);
-	print_r($Fetch);
-	*/
-	global $PDO;
-	$Update = "UPDATE pali_sent SET sim_sents = ".$PDO->quote($text_list)." WHERE id = ".$current_id;
-	$Result = PDO_Execute($Update);
-	return;
+function insert_similar_sent_list_into_sqlite($current_id, $text_list)
+{
+    /* 使用这部分代码先为数据库添加一个 sim_sents 字段
+    $add_column = "ALTER TABLE pali_sent ADD COLUMN sim_sents TEXT";
+    $Action_add = PDO_Execute($add_column);
+    $query = "PRAGMA TABLE_INFO (pali_sent)";
+    $Fetch = PDO_FetchALL($query);
+    print_r($Fetch);
+     */
+    global $PDO;
+    $Update = "UPDATE pali_sent SET sim_sents = " . $PDO->quote($text_list) . " WHERE id = " . $current_id;
+    $Result = PDO_Execute($Update);
+    return;
 }
 
 // 预计算,存入数据库
-function similar_sent_matrix($begin,$end,$begin_id=0) {
-	// 按照 count = 18, 8, ..., 255 依次获得查询结果 (i-3,i+3)
-	//          count = 17,16,...,7                                       (i-2,i+2)
-	for ($current_count=$begin; $current_count <=$end ; $current_count++) { 
-		print("单词数:".$current_count."\n");
-		$current_query = "select id,text from pali_sent where count=".$current_count;
-		$Current = PDO_FetchAll($current_query);
-		if (count($Current)) {
-			foreach($Current as $current_row) {
-				$current_id = $current_row['id'];
-				if($begin_id>0 && $current_count==$begin){
-					if($current_id<$begin_id){
-						continue;
-					}
-				}
-				$current_sent = $current_row['text'];
-				$current_words = words_of_sentence($current_sent);
-				
-				// 按照 count > $current_count-3 and count <$current_count+3 查询希望比较的语句
-				if($current_count>17){
-					$section = 3;
-				}
-				else if($current_count>6){
-					$section = 2;
-				}
-				else if($current_count>3){
-					$section = 1;
-				}
-				else {
-					$section = 0;
-				}
-				$compare_query = "select id,text from pali_sent where count>".($current_count-$section)." and count<".($current_count+$section);
-				$Compare = PDO_FetchALL($compare_query);
+function similar_sent_matrix($begin, $end, $begin_id = 0)
+{
+    // 按照 count = 18, 8, ..., 255 依次获得查询结果 (i-3,i+3)
+    //          count = 17,16,...,7                                       (i-2,i+2)
+    for ($current_count = $begin; $current_count <= $end; $current_count++) {
+        print("单词数:" . $current_count . "\n");
+        $current_query = "select id,text from pali_sent where count=" . $current_count;
+        $Current = PDO_FetchAll($current_query);
+        if (count($Current)) {
+            foreach ($Current as $current_row) {
+                $current_id = $current_row['id'];
+                if ($begin_id > 0 && $current_count == $begin) {
+                    if ($current_id < $begin_id) {
+                        continue;
+                    }
+                }
+                $current_sent = $current_row['text'];
+                $current_words = words_of_sentence($current_sent);
+
+                // 按照 count > $current_count-3 and count <$current_count+3 查询希望比较的语句
+                if ($current_count > 17) {
+                    $section = 3;
+                } else if ($current_count > 6) {
+                    $section = 2;
+                } else if ($current_count > 3) {
+                    $section = 1;
+                } else {
+                    $section = 0;
+                }
+                $compare_query = "select id,text from pali_sent where count>" . ($current_count - $section) . " and count<" . ($current_count + $section);
+                $Compare = PDO_FetchALL($compare_query);
 
-				$current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
-				foreach($Compare as $compare_row) {
-					if ($current_row != $compare_row) {
-						$compare_id = $compare_row['id'];
-						$compare_sent = $compare_row['text'];
-						$compare_words = words_of_sentence($compare_sent);
+                $current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
+                foreach ($Compare as $compare_row) {
+                    if ($current_row != $compare_row) {
+                        $compare_id = $compare_row['id'];
+                        $compare_sent = $compare_row['text'];
+                        $compare_words = words_of_sentence($compare_sent);
 
-						if($current_count>3){
-							$jaccard_score = jaccard_similarity($current_words, $compare_words);
-						}
-						else if($current_count==3 ){
-							if($current_words==$compare_words){
-								$jaccard_score = 1;
-							}
-						}
-						else if($current_count==2){
-							if($current_words==$compare_words){
-								$jaccard_score = 1;
-							}
-						}
-						else{
-							$jaccard_score = 0;
-						}
-						if ($jaccard_score > 0.3) {
-							$current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
-						}
-					}
-				} // end of foreach $compare_row
+                        if ($current_count > 3) {
+                            $jaccard_score = jaccard_similarity($current_words, $compare_words);
+                        } else if ($current_count == 3) {
+                            if ($current_words == $compare_words) {
+                                $jaccard_score = 1;
+                            }
+                        } else if ($current_count == 2) {
+                            if ($current_words == $compare_words) {
+                                $jaccard_score = 1;
+                            }
+                        } else {
+                            $jaccard_score = 0;
+                        }
+                        if ($jaccard_score > 0.3) {
+                            $current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
+                        }
+                    }
+                } // end of foreach $compare_row
 
-				if ($current_sim_sent_list->size != 0) {
-					print("update $current_count - ".$current_id."\n");
-					$text_list = $current_sim_sent_list->get_text_list();
-					insert_similar_sent_list_into_sqlite($current_id, $text_list);
-				}
-			} // end of foreach $current_row
-		}
-	}
-	return;
+                if ($current_sim_sent_list->size != 0) {
+                    print("update $current_count - " . $current_id . "\n");
+                    $text_list = $current_sim_sent_list->get_text_list();
+                    insert_similar_sent_list_into_sqlite($current_id, $text_list);
+                }
+            } // end of foreach $current_row
+        }
+    }
+    return;
 }
 
 // 实时计算相似句
-function sents_similar_to_id($id) {
-	$query = "SELECT count,text FROM pali_sent WHERE id=".$id;
-	$Current = PDO_FetchALL($query);
-	if (count($Current)) {
-		foreach($Current as $current_row) {
-			$current_count = $current_row['count'];
-			$current_sent = $current_row['text'];
-			$current_words = words_of_sentence($current_sent);
-			print("current text: \n".$current_sent."\n");
+function sents_similar_to_id($id)
+{
+    $query = "SELECT count,text FROM pali_sent WHERE id=" . $id;
+    $Current = PDO_FetchALL($query);
+    if (count($Current)) {
+        foreach ($Current as $current_row) {
+            $current_count = $current_row['count'];
+            $current_sent = $current_row['text'];
+            $current_words = words_of_sentence($current_sent);
+            print("current text: \n" . $current_sent . "\n");
 
-			if ($current_count <= 5) {
-				print("[-] too short.\n");
-				return;
-			}
+            if ($current_count <= 5) {
+                print("[-] too short.\n");
+                return;
+            }
 
-			// 只和单词数大于 5 的比较
-			$compare_query = "SELECT id,text FROM pali_sent WHERE count>5";
-			$Compare = PDO_FetchALL($compare_query);
+            // 只和单词数大于 5 的比较
+            $compare_query = "SELECT id,text FROM pali_sent WHERE count>5";
+            $Compare = PDO_FetchALL($compare_query);
 
-			$current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
-			foreach($Compare as $compare_row) {
-				if ($current_row != $compare_row) {
-					$compare_id = $compare_row['id'];
-					$compare_sent = $compare_row['text'];
-					$compare_words = words_of_sentence($compare_sent);
+            $current_sim_sent_list = new sim_sent_list(); // 新建相似句链表
+            foreach ($Compare as $compare_row) {
+                if ($current_row != $compare_row) {
+                    $compare_id = $compare_row['id'];
+                    $compare_sent = $compare_row['text'];
+                    $compare_words = words_of_sentence($compare_sent);
 
-					$jaccard_score = jaccard_similarity($current_words, $compare_words);
-					if ($jaccard_score > 0.3) {
-						print("Jaccard similarity: ".$jaccard_score."\tSentence id:".$compare_id."\n");
-						print("Text: \n". $compare_sent."\n");
-						$current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
-					}
-				}
-			} // end of foreach $compare_row
+                    $jaccard_score = jaccard_similarity($current_words, $compare_words);
+                    if ($jaccard_score > 0.3) {
+                        print("Jaccard similarity: " . $jaccard_score . "\tSentence id:" . $compare_id . "\n");
+                        print("Text: \n" . $compare_sent . "\n");
+                        $current_sim_sent_list->jaccard_add($compare_id, $jaccard_score);
+                    }
+                }
+            } // end of foreach $compare_row
 
-			if ($current_sim_sent_list->size != 0) {
-				// $current_sim_sent_list->print_list();
-			} else {
-				print("[-]not found.\n");
-			}
+            if ($current_sim_sent_list->size != 0) {
+                // $current_sim_sent_list->print_list();
+            } else {
+                print("[-]not found.\n");
+            }
 
-		} // end of foreach($Current)
-	} // end of if (count($Current))
+        } // end of foreach($Current)
+    } // end of if (count($Current))
 }
 
 //$id = $argv[1];
 //sents_similar_to_id($id);
 
-	if ($argc < 3){
-		echo "无效的参数 ";
-		exit;
-	}
-	$from = (int)$argv[1];
-	$to =(int)$argv[2];
-	if ($argc > 3){
-		$from_id = (int)$argv[3];
-	}
-	else{
-		$from_id = 0;
-	}
-	if($from<2){
-		$from = 2;
-	}
-	if($to>255){
-		$to = 255;
-	}
-	similar_sent_matrix($from,$to,$from_id);
-	echo "\n all done";
-?>
+if ($argc < 3) {
+    echo "无效的参数 ";
+    exit;
+}
+$from = (int) $argv[1];
+$to = (int) $argv[2];
+if ($argc > 3) {
+    $from_id = (int) $argv[3];
+} else {
+    $from_id = 0;
+}
+if ($from < 2) {
+    $from = 2;
+}
+if ($to > 255) {
+    $to = 255;
+}
+similar_sent_matrix($from, $to, $from_id);
+echo "\n all done";

+ 58 - 64
app/palicanon/book_tag.php

@@ -2,93 +2,87 @@
 require_once '../path.php';
 
 try {
-	$redis = new redis();  
-	$r_conn = $redis->connect('127.0.0.1', 6379);
+    $redis = new redis();
+    $r_conn = $redis->connect('127.0.0.1', 6379);
 } catch (Exception $e) {
-	$r_conn = false;
+    $r_conn = false;
 }
 
-$tag =  str_getcsv($_GET["tag"],",");//
-$arrBookTag=json_decode(file_get_contents("../public/book_tag/en.json"),true);
+$tag = str_getcsv($_GET["tag"], ","); //
+$arrBookTag = json_decode(file_get_contents("../public/book_tag/en.json"), true);
 $countTag = count($tag);
 $output = array();
 foreach ($arrBookTag as $bookkey => $bookvalue) {
     $isfind = 0;
     foreach ($tag as $tagkey => $tagvalue) {
-        if(strpos($bookvalue["tag"],':'.$tagvalue.':') !== FALSE){
+        if (strpos($bookvalue["tag"], ':' . $tagvalue . ':') !== false) {
             $isfind++;
         }
     }
-    if($isfind==$countTag){
+    if ($isfind == $countTag) {
         $output[] = $bookvalue;
     }
 }
 
+$dns = "" . _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "sqlite:"._FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
-
-$dns = "sqlite:"._FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "sqlite:"._FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-
-
-
 foreach ($output as $key => $value) {
-	# code...
-	$book = (int)$value["book"];
-	$para = (int)$value["para"];
-	$level = (int)$value["level"];
-	if(count($output)<100 || (count($output)>100 && $level==1)){
-		$query = "SELECT * FROM pali_text WHERE book = ? and paragraph = ?";
-		$stmt = $dbh_pali_text->prepare($query);
-		$stmt->execute(array($book,$para));
-		$paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
+    # code...
+    $book = (int) $value["book"];
+    $para = (int) $value["para"];
+    $level = (int) $value["level"];
+    if (count($output) < 100 || (count($output) > 100 && $level == 1)) {
+        $query = "SELECT * FROM pali_text WHERE book = ? and paragraph = ?";
+        $stmt = $dbh_pali_text->prepare($query);
+        $stmt->execute(array($book, $para));
+        $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
 
-		if($paraInfo){	
-			# 查进度
-			$paraProgress = false;
-			if($r_conn){
-				$count = $redis->hLen("progress_chapter_{$book}_{$para}");
-				if($count>0){
-					$prog = $redis->hGetAll("progress_chapter_{$book}_{$para}");
-					foreach ($prog as $keylang => $valuetrans) {
-						# code...
-						$paraProgress = array("lang"=>$keylang,"all_trans"=>$valuetrans);
-						break;
-					}
-				}
-			}
-			else{
-				$query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
-				$stmt = $dbh_toc->prepare($query);
-				$sth_toc = $dbh_toc->prepare($query);
-				$sth_toc->execute(array($book,$para));
-				$paraProgress = $sth_toc->fetch(PDO::FETCH_ASSOC);				
-			}
+        if ($paraInfo) {
+            # 查进度
+            $paraProgress = false;
+            if ($r_conn) {
+                $count = $redis->hLen("progress_chapter_{$book}_{$para}");
+                if ($count > 0) {
+                    $prog = $redis->hGetAll("progress_chapter_{$book}_{$para}");
+                    foreach ($prog as $keylang => $valuetrans) {
+                        # code...
+                        $paraProgress = array("lang" => $keylang, "all_trans" => $valuetrans);
+                        break;
+                    }
+                }
+            } else {
+                $query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
+                $stmt = $dbh_toc->prepare($query);
+                $sth_toc = $dbh_toc->prepare($query);
+                $sth_toc->execute(array($book, $para));
+                $paraProgress = $sth_toc->fetch(PDO::FETCH_ASSOC);
+            }
 
-			$output[$key]["progress"]=$paraProgress;
-		
-			#查标题
-			if(isset($_GET["lang"])){
-				$query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
-				$stmt = $dbh_res->prepare($query);
-				$sth_title = $dbh_res->prepare($query);
-				$sth_title->execute(array($book,$para,$_GET["lang"]));
-				$trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
-				if($trans_title){
-					$output[$key]["trans_title"]=$trans_title['title'];
-				}
-			}
-		}
-	}
+            $output[$key]["progress"] = $paraProgress;
+
+            #查标题
+            if (isset($_GET["lang"])) {
+                $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+                $stmt = $dbh_res->prepare($query);
+                $sth_title = $dbh_res->prepare($query);
+                $sth_title->execute(array($book, $para, $_GET["lang"]));
+                $trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
+                if ($trans_title) {
+                    $output[$key]["trans_title"] = $trans_title['title'];
+                }
+            }
+        }
+    }
 }
 
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-?>

+ 65 - 73
app/palicanon/get_chapter_children.php

@@ -2,93 +2,85 @@
 require_once '../path.php';
 
 try {
-	$redis = new redis();  
-	$r_conn = $redis->connect('127.0.0.1', 6379);
+    $redis = new redis();
+    $r_conn = $redis->connect('127.0.0.1', 6379);
 } catch (Exception $e) {
-	$r_conn=false;
+    $r_conn = false;
 }
 
+$dns = "" . _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-
-$dns = "sqlite:"._FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
-
-$dns = "sqlite:"._FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "sqlite:"._FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-if(isset($_GET["book"])){
-	$book = (int)$_GET["book"];
+if (isset($_GET["book"])) {
+    $book = (int) $_GET["book"];
 }
-if(isset($_GET["para"])){
-	$para = (int)$_GET["para"];
+if (isset($_GET["para"])) {
+    $para = (int) $_GET["para"];
 }
 
 $query = "SELECT chapter_len FROM pali_text WHERE book = ? and paragraph = ?";
 $stmt = $dbh_pali_text->prepare($query);
-$stmt->execute(array($book,$para));
+$stmt->execute(array($book, $para));
 $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
-if($paraInfo){
-	$query = "SELECT level FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 0,1";
-	$stmt = $dbh_pali_text->prepare($query);
-	$stmt->execute(array($book,$para+1,$para+(int)$paraInfo["chapter_len"]-1));
-	$paraMax = $stmt->fetch(PDO::FETCH_ASSOC);
-	if($paraMax){
-		$query = "SELECT book, paragraph as para, level , toc as title FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 0,1000";
-		$stmt = $dbh_pali_text->prepare($query);
-		$stmt->execute(array($book,$para,$para+$paraInfo["chapter_len"],$paraMax["level"]));
-		$paraList = $stmt->fetchAll(PDO::FETCH_ASSOC);	
-		foreach ($paraList as $key => $value) {
-			# 查进度
-			$paraProgress = false;
-			if($r_conn){
-				$count = $redis->hLen("progress_chapter_{$value["book"]}_{$value["para"]}");
-				if($count>0){
-					$prog = $redis->hGetAll("progress_chapter_{$value["book"]}_{$value["para"]}");
-					foreach ($prog as $keylang => $valuetrans) {
-						# code...
-						$paraProgress = array("lang"=>$keylang,"all_trans"=>$valuetrans);
-						break;
-					}
-				}
-			}
-			else{
-				$query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
-				$stmt = $dbh_toc->prepare($query);
-				$sth_toc = $dbh_toc->prepare($query);
-				$sth_toc->execute(array($value["book"],$value["para"]));
-				$paraProgress = $sth_toc->fetch(PDO::FETCH_ASSOC);				
-			}
-
-			$paraList[$key]["progress"]=$paraProgress;
+if ($paraInfo) {
+    $query = "SELECT level FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 0,1";
+    $stmt = $dbh_pali_text->prepare($query);
+    $stmt->execute(array($book, $para + 1, $para + (int) $paraInfo["chapter_len"] - 1));
+    $paraMax = $stmt->fetch(PDO::FETCH_ASSOC);
+    if ($paraMax) {
+        $query = "SELECT book, paragraph as para, level , toc as title FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 0,1000";
+        $stmt = $dbh_pali_text->prepare($query);
+        $stmt->execute(array($book, $para, $para + $paraInfo["chapter_len"], $paraMax["level"]));
+        $paraList = $stmt->fetchAll(PDO::FETCH_ASSOC);
+        foreach ($paraList as $key => $value) {
+            # 查进度
+            $paraProgress = false;
+            if ($r_conn) {
+                $count = $redis->hLen("progress_chapter_{$value["book"]}_{$value["para"]}");
+                if ($count > 0) {
+                    $prog = $redis->hGetAll("progress_chapter_{$value["book"]}_{$value["para"]}");
+                    foreach ($prog as $keylang => $valuetrans) {
+                        # code...
+                        $paraProgress = array("lang" => $keylang, "all_trans" => $valuetrans);
+                        break;
+                    }
+                }
+            } else {
+                $query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
+                $stmt = $dbh_toc->prepare($query);
+                $sth_toc = $dbh_toc->prepare($query);
+                $sth_toc->execute(array($value["book"], $value["para"]));
+                $paraProgress = $sth_toc->fetch(PDO::FETCH_ASSOC);
+            }
 
-			#查标题
-			if(isset($_GET["lang"])){
-				$query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
-				$stmt = $dbh_res->prepare($query);
-				$sth_title = $dbh_res->prepare($query);
-				$sth_title->execute(array($value["book"],$value["para"],$_GET["lang"]));
-				$trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
-				if($trans_title){
-					$paraList[$key]["trans_title"]=$trans_title['title'];
-				}
-			}
-		}
-		echo json_encode($paraList, JSON_UNESCAPED_UNICODE);
-	}
-	else{
-		echo json_encode(array(), JSON_UNESCAPED_UNICODE);
-	}
-	
-}
-else{
-	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
-}
+            $paraList[$key]["progress"] = $paraProgress;
 
+            #查标题
+            if (isset($_GET["lang"])) {
+                $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+                $stmt = $dbh_res->prepare($query);
+                $sth_title = $dbh_res->prepare($query);
+                $sth_title->execute(array($value["book"], $value["para"], $_GET["lang"]));
+                $trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
+                if ($trans_title) {
+                    $paraList[$key]["trans_title"] = $trans_title['title'];
+                }
+            }
+        }
+        echo json_encode($paraList, JSON_UNESCAPED_UNICODE);
+    } else {
+        echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+    }
 
-?>
+} else {
+    echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+}

+ 49 - 54
app/palicanon/get_chapter_info.php

@@ -2,74 +2,69 @@
 require_once '../path.php';
 
 try {
-	$redis = new redis();  
-	$r_conn = $redis->connect('127.0.0.1', 6379);
+    $redis = new redis();
+    $r_conn = $redis->connect('127.0.0.1', 6379);
 } catch (Exception $e) {
-	$r_conn=false;
+    $r_conn = false;
 }
 
-$dns = "sqlite:"._FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
-$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+$dns = "" . _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "sqlite:"._FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "sqlite:"._FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dns = "" . _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-if(isset($_GET["book"])){
-	$book = (int)$_GET["book"];
+if (isset($_GET["book"])) {
+    $book = (int) $_GET["book"];
 }
-if(isset($_GET["para"])){
-	$para = (int)$_GET["para"];
+if (isset($_GET["para"])) {
+    $para = (int) $_GET["para"];
 }
 
 $query = "SELECT * FROM pali_text WHERE book = ? and paragraph = ?";
 $stmt = $dbh_pali_text->prepare($query);
-$stmt->execute(array($book,$para));
+$stmt->execute(array($book, $para));
 $paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
-if($paraInfo){	
-	# 查进度
-	$paraProgress = array();
-	if($r_conn){
-		$count = $redis->hLen("progress_chapter_{$book}_{$para}");
-		if($count>0){
-			$prog = $redis->hGetAll("progress_chapter_{$book}_{$para}");
-			foreach ($prog as $keylang => $valuetrans) {
-				# code...
-				$paraProgress[] = array("lang"=>$keylang,"all_trans"=>$valuetrans);
-			}
-		}
+if ($paraInfo) {
+    # 查进度
+    $paraProgress = array();
+    if ($r_conn) {
+        $count = $redis->hLen("progress_chapter_{$book}_{$para}");
+        if ($count > 0) {
+            $prog = $redis->hGetAll("progress_chapter_{$book}_{$para}");
+            foreach ($prog as $keylang => $valuetrans) {
+                # code...
+                $paraProgress[] = array("lang" => $keylang, "all_trans" => $valuetrans);
+            }
+        }
 
-	}
-	else{
-		$query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
-		$stmt = $dbh_toc->prepare($query);
-		$sth_toc = $dbh_toc->prepare($query);
-		$sth_toc->execute(array($book,$para));
-		$paraProgress = $sth_toc->fetchAll(PDO::FETCH_ASSOC);	
-	}
-	$paraInfo["progress"]=$paraProgress;
+    } else {
+        $query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
+        $stmt = $dbh_toc->prepare($query);
+        $sth_toc = $dbh_toc->prepare($query);
+        $sth_toc->execute(array($book, $para));
+        $paraProgress = $sth_toc->fetchAll(PDO::FETCH_ASSOC);
+    }
+    $paraInfo["progress"] = $paraProgress;
 
-	#查标题
-	if(isset($_GET["lang"])){
-		$query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
-		$stmt = $dbh_res->prepare($query);
-		$sth_title = $dbh_res->prepare($query);
-		$sth_title->execute(array($book,$para,$_GET["lang"]));
-		$trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
-		if($trans_title){
-			$paraInfo["trans_title"]=$trans_title['title'];
-		}
-	}
-	echo json_encode($paraInfo, JSON_UNESCAPED_UNICODE);
+    #查标题
+    if (isset($_GET["lang"])) {
+        $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+        $stmt = $dbh_res->prepare($query);
+        $sth_title = $dbh_res->prepare($query);
+        $sth_title->execute(array($book, $para, $_GET["lang"]));
+        $trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
+        if ($trans_title) {
+            $paraInfo["trans_title"] = $trans_title['title'];
+        }
+    }
+    echo json_encode($paraInfo, JSON_UNESCAPED_UNICODE);
+} else {
+    echo json_encode(array(), JSON_UNESCAPED_UNICODE);
 }
-else{
-	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
-}
-
-
-?>

+ 89 - 73
app/path.php

@@ -1,91 +1,107 @@
 <?php
+define("_DB_ENGIN_", "sqlite");
 
-define("_DIR_APPDATA_" , __DIR__."/../tmp/appdata");
+define("_DB_HOST_", "localhost");
+define("_DB_USERNAME_", "");
+define("_DB_PASSWORD_", "");
 
-define("_DIR_PALICANON_" , __DIR__."/../tmp/appdata/palicanon");
-define("_DIR_PALICANON_TEMPLET_" , __DIR__."/../tmp/appdata/palicanon/templet");
-define("_DIR_PALICANON_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text");
-define("_DIR_PALICANON_WBW_" , __DIR__."/../tmp/appdata/palicanon/wbw");
-define("_DIR_PALICANON_TRAN_" , __DIR__."/../tmp/appdata/palicanon/translate");
+define("_DB_NAME_PALICANON_", "palicanon");
+define("_DB_NAME_DICTIONARY_", "dictionary");
+define("_DB_NAME_USERDATA_", "userdata");
 
-define("_DIR_IMAGES_" , __DIR__."/../tmp/images");
-define("_DIR_IMAGES_ARTICLE_" , __DIR__."/../tmp/images/article");
-define("_DIR_IMAGES_COLLECTION_" , __DIR__."/../tmp/images/collection");
-define("_DIR_IMAGES_COURSE_" , __DIR__."/../tmp/images/course");
-define("_DIR_IMAGES_COURSE_A_" , "../../tmp/images/course");
-define("_DIR_IMAGES_LESSON_" , __DIR__."/../tmp/images/lesson");
+define("_DIR_APPDATA_", __DIR__ . "/../tmp/appdata");
+
+define("_DIR_PALICANON_", __DIR__ . "/../tmp/appdata/palicanon");
+define("_DIR_PALICANON_TEMPLET_", __DIR__ . "/../tmp/appdata/palicanon/templet");
+define("_DIR_PALICANON_PALITEXT_", __DIR__ . "/../tmp/appdata/palicanon/pali_text");
+define("_DIR_PALICANON_WBW_", __DIR__ . "/../tmp/appdata/palicanon/wbw");
+define("_DIR_PALICANON_TRAN_", __DIR__ . "/../tmp/appdata/palicanon/translate");
+
+define("_DIR_IMAGES_", __DIR__ . "/../tmp/images");
+define("_DIR_IMAGES_ARTICLE_", __DIR__ . "/../tmp/images/article");
+define("_DIR_IMAGES_COLLECTION_", __DIR__ . "/../tmp/images/collection");
+define("_DIR_IMAGES_COURSE_", __DIR__ . "/../tmp/images/course");
+define("_DIR_IMAGES_COURSE_A_", "../../tmp/images/course");
+define("_DIR_IMAGES_LESSON_", __DIR__ . "/../tmp/images/lesson");
 
 //pali canon db file 语料库
-define("_FILE_DB_RESRES_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/res.db3");
-define("_FILE_DB_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text.db3");
-define("_FILE_DB_STATISTICS_" , __DIR__."/../tmp/appdata/palicanon/word_statistics.db3");
-define("_FILE_DB_PALI_SENTENCE_" , __DIR__."/../tmp/appdata/palicanon/pali_sent1.db3");
-define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sim.db3");
-define("_FILE_DB_PALI_TOC_" , __DIR__."/../tmp/appdata/palicanon/pali_toc.db3");
-define("_FILE_DB_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/index.db3");
-define("_FILE_DB_WORD_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/wordindex.db3");
-define("_FILE_DB_PALI_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/paliindex.db3");
-define("_FILE_DB_PAGE_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/pagemap.db3");
-define("_FILE_DB_BOOK_WORD_"  , __DIR__."/../tmp/appdata/palicanon/bookword.db3");
-define("_FILE_DB_BOLD_"  , __DIR__."/../tmp/appdata/palicanon/bold.db3");
+define("_FILE_DB_PALICANON_TEMPLET_", __DIR__ . "/../tmp/appdata/palicanon/templet.db3");
+define("_FILE_DB_RESRES_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/res.db3");
+define("_FILE_DB_PALITEXT_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_text.db3");
+define("_FILE_DB_STATISTICS_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/word_statistics.db3");
+define("_FILE_DB_PALI_SENTENCE_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_sent1.db3");
+define("_FILE_DB_PALI_SENTENCE_SIM_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_sim.db3");
+define("_FILE_DB_PALI_TOC_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pali_toc.db3");
+define("_FILE_DB_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/index.db3");
+define("_FILE_DB_WORD_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/wordindex.db3");
+define("_FILE_DB_PALI_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/paliindex.db3");
+define("_FILE_DB_PAGE_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/pagemap.db3");
+define("_FILE_DB_BOOK_WORD_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/bookword.db3");
+define("_FILE_DB_BOLD_", "sqlite:" . __DIR__ . "/../tmp/appdata/palicanon/bold.db3");
 
 //语料库
 
-define("_DIR_CSV_PALI_CANON_WORD_" , __DIR__."/../paliword/book");
-define("_DIR_CSV_PALI_CANON_WORD_INDEX_" , __DIR__."/../paliword/index");
-
-define("_DIR_PALI_CSV_" , __DIR__."/../tmp/palicsv");
-define("_DIR_LOG_" , __DIR__."/../tmp/log");
-define("_DIR_TEMP_" , __DIR__."/../tmp/temp");
-define("_DIR_TMP_" , __DIR__."/../tmp");
+define("_DIR_CSV_PALI_CANON_WORD_", __DIR__ . "/../paliword/book");
+define("_DIR_CSV_PALI_CANON_WORD_INDEX_", __DIR__ . "/../paliword/index");
 
+define("_DIR_PALI_CSV_", __DIR__ . "/../tmp/palicsv");
+define("_DIR_LOG_", __DIR__ . "/../tmp/log");
+define("_DIR_TEMP_", __DIR__ . "/../tmp/temp");
+define("_DIR_TMP_", __DIR__ . "/../tmp");
 
 //dictionary
-define("_DIR_DICT_" , __DIR__."/../tmp/appdata/dict");
-define("_DIR_DICT_SYSTEM_" , __DIR__."/../tmp/appdata/dict/system");
-define("_DIR_DICT_3RD_" , __DIR__."/../tmp/appdata/dict/3rd");
-define("_DIR_DICT_REF_" , __DIR__."/../tmp/appdata/dict/ref");
+define("_DIR_DICT_", __DIR__ . "/../tmp/appdata/dict");
+define("_DIR_DICT_SYSTEM_", __DIR__ . "/../tmp/appdata/dict/system");
+define("_DIR_DICT_3RD_", __DIR__ . "/../tmp/appdata/dict/3rd");
+define("_DIR_DICT_REF_", __DIR__ . "/../tmp/appdata/dict/ref");
+
+define("_DIR_USERS_GUIDE_", __DIR__ . "/../documents/users_guide");
+
+#参考字典
+define("_FILE_DB_REF_", "sqlite:" . __DIR__ . "/../tmp/appdata/dict/system/ref.db");
+define("_TABLE_DICT_REF_", "dict");
+define("_TABLE_DICT_REF_NAME_LIST_", "info");
 
-define("_DIR_USERS_GUIDE_" , __DIR__."/../documents/users_guide");
+#参考字典索引
+define("_FILE_DB_REF_INDEX_", "sqlite:" . __DIR__ . "/../tmp/appdata/dict/system/ref1.db");
+define("_TABLE_REF_INDEX_", "dict");
 
-define("_FILE_DB_REF_"  , __DIR__."/../tmp/appdata/dict/system/ref.db");
-define("_FILE_DB_REF_INDEX_"  , __DIR__."/../tmp/appdata/dict/system/ref1.db");
-define("_FILE_DB_PART_"  , __DIR__."/../tmp/appdata/dict/system/part.db3");
+#为了切分复合词 使用的词头表
+define("_FILE_DB_PART_", "sqlite:" . __DIR__ . "/../tmp/appdata/dict/system/part.db3");
+define("_TABLE_PART_", "part");
 
-define("_DIR_FONT_" , __DIR__."/../font");
-define("_DIR_PALI_HTML_" , __DIR__."/../palihtml");
-define("_DIR_DICT_TEXT_" , __DIR__."/../dicttext");
+define("_DIR_FONT_", __DIR__ . "/../font");
+define("_DIR_PALI_HTML_", __DIR__ . "/../palihtml");
+define("_DIR_DICT_TEXT_", __DIR__ . "/../dicttext");
 
-define("_DIR_PALI_TITLE_" , __DIR__."/../pali_title");
-define("_DIR_APP_" , __DIR__."/../app");
-define("_DIR_LANGUAGE_" , __DIR__."/../app/public/lang");
-define("_DIR_BOOK_INDEX_" , __DIR__."/../app/public/book_index");
+define("_DIR_PALI_TITLE_", __DIR__ . "/../pali_title");
+define("_DIR_APP_", __DIR__ . "/../app");
+define("_DIR_LANGUAGE_", __DIR__ . "/../app/public/lang");
+define("_DIR_BOOK_INDEX_", __DIR__ . "/../app/public/book_index");
 
 /*user data*/
-define("_DIR_USER_BASE_" , __DIR__."/../tmp/user");
-define("_DIR_USER_DOC_" , __DIR__."/../tmp/user_doc");
-define("_DIR_USER_IMG_" , __DIR__."/../tmp/user/media/3");
-define("_DIR_USER_IMG_LINK_" , "../../tmp/user/media/3");
-define("_DIR_MYDOCUMENT_" , "/my_document");
-
-define("_FILE_DB_USER_WBW_" , __DIR__."/../tmp/user/user_wbw.db3");
-define("_FILE_DB_COMMENTS_" , __DIR__."/../tmp/user/comments.db3");
-define("_FILE_DB_SENTENCE_"  , __DIR__."/../tmp/user/sentence.db3");
-define("_FILE_DB_TERM_"  , __DIR__."/../tmp/user/dhammaterm.db");
-define("_FILE_DB_GROUP_"  , __DIR__."/../tmp/user/group.db3");
-define("_FILE_DB_USERINFO_"  , __DIR__."/../tmp/user/userinfo.db3");
-define("_FILE_DB_FILEINDEX_"  , __DIR__."/../tmp/user/fileindex.db");
-define("_FILE_DB_WBW_"  , __DIR__."/../tmp/user/wbw.db3");
-define("_FILE_DB_COURSE_"  , __DIR__."/../tmp/user/course.db3");
-define("_FILE_DB_MEDIA_"  , __DIR__."/../tmp/user/media.db3");
-define("_FILE_DB_MESSAGE_"  , __DIR__."/../tmp/user/message.db");
-define("_FILE_DB_USER_STATISTICS_"  , __DIR__."/../tmp/user/statistics.db3");
-define("_FILE_DB_CHANNAL_"  , __DIR__."/../tmp/user/channal.db3");
-define("_FILE_DB_USER_DICT_"  , __DIR__."/../tmp/user/udict.db3");
-define("_FILE_DB_USER_ARTICLE_"  , __DIR__."/../tmp/user/article.db3");
-define("_FILE_DB_HOSTSETTING_"  , __DIR__."/../tmp/user/hostsetting.db3");
-define("_FILE_DB_USER_SENTENCE_HISTORAY_"  , __DIR__."/../tmp/user/usent_historay.db3");
-define("_FILE_DB_USER_ACTIVE_"  , __DIR__."/../tmp/user/user_active.db3");
-define("_FILE_DB_USER_ACTIVE_LOG_"  , __DIR__."/../tmp/user/user_active_log.db3");
-
-?>
+define("_DIR_USER_BASE_", __DIR__ . "/../tmp/user");
+define("_DIR_USER_DOC_", __DIR__ . "/../tmp/user_doc");
+define("_DIR_USER_IMG_", __DIR__ . "/../tmp/user/media/3");
+define("_DIR_USER_IMG_LINK_", "../../tmp/user/media/3");
+define("_DIR_MYDOCUMENT_", "/my_document");
+
+define("_FILE_DB_USER_WBW_", "sqlite:" . __DIR__ . "/../tmp/user/user_wbw.db3");
+define("_FILE_DB_COMMENTS_", "sqlite:" . __DIR__ . "/../tmp/user/comments.db3");
+define("_FILE_DB_SENTENCE_", "sqlite:" . __DIR__ . "/../tmp/user/sentence.db3");
+define("_FILE_DB_TERM_", "sqlite:" . __DIR__ . "/../tmp/user/dhammaterm.db");
+define("_FILE_DB_GROUP_", "sqlite:" . __DIR__ . "/../tmp/user/group.db3");
+define("_FILE_DB_USERINFO_", "sqlite:" . __DIR__ . "/../tmp/user/userinfo.db3");
+define("_FILE_DB_FILEINDEX_", "sqlite:" . __DIR__ . "/../tmp/user/fileindex.db");
+define("_FILE_DB_WBW_", "sqlite:" . __DIR__ . "/../tmp/user/wbw.db3");
+define("_FILE_DB_COURSE_", "sqlite:" . __DIR__ . "/../tmp/user/course.db3");
+define("_FILE_DB_MEDIA_", "sqlite:" . __DIR__ . "/../tmp/user/media.db3");
+define("_FILE_DB_MESSAGE_", "sqlite:" . __DIR__ . "/../tmp/user/message.db");
+define("_FILE_DB_USER_STATISTICS_", "sqlite:" . __DIR__ . "/../tmp/user/statistics.db3");
+define("_FILE_DB_CHANNAL_", "sqlite:" . __DIR__ . "/../tmp/user/channal.db3");
+define("_FILE_DB_USER_DICT_", "sqlite:" . __DIR__ . "/../tmp/user/udict.db3");
+define("_FILE_DB_USER_ARTICLE_", "sqlite:" . __DIR__ . "/../tmp/user/article.db3");
+define("_FILE_DB_HOSTSETTING_", "sqlite:" . __DIR__ . "/../tmp/user/hostsetting.db3");
+define("_FILE_DB_USER_SENTENCE_HISTORAY_", "sqlite:" . __DIR__ . "/../tmp/user/usent_historay.db3");
+define("_FILE_DB_USER_ACTIVE_", "sqlite:" . __DIR__ . "/../tmp/user/user_active.db3");
+define("_FILE_DB_USER_ACTIVE_LOG_", "sqlite:" . __DIR__ . "/../tmp/user/user_active_log.db3");

+ 243 - 245
app/pcdl/change.php

@@ -8,235 +8,235 @@
 include "./_pdo.php";
 include "../app/public.inc";
 
-$from=$_GET["from"];
-$to=$_GET["to"];
+$from = $_GET["from"];
+$to = $_GET["to"];
 
-$book[0]="";
-$book[1]="Namakkārapāḷi";
-$book[2]="Mahāpaṇāmapāṭha(Buddhavandanā)";
-$book[3]="Lakkhaṇāto";
-$book[4]="Suttavandanā";
-$book[5]="Jinālaṅkāra";
-$book[6]="Kamalāñjali";
-$book[7]="Pajjamadhu";
-$book[8]="Buddhaguṇagāthāvalī";
-$book[9]="Abhidhānappadīpikāṭīkā";
-$book[10]="Subodhālaṅkāro";
-$book[11]="Subodhālaṅkāraṭīkā";
-$book[12]="Bālāvatāra";
-$book[13]="Moggallānasuttapāṭho";
-$book[14]="Kaccāyanabyākaraṇaṃ";
-$book[15]="Saddanītippakaraṇaṃ (padamālā)";
-$book[16]="Saddanītippakaraṇaṃ";
-$book[17]="Padarūpasiddhi";
-$book[18]="Moggallāna pañcikā ṭīkā";
-$book[19]="Payogasiddhipāḷi";
-$book[20]="Vuttodayaṃ";
-$book[21]="Abhidhānappadīpikā";
-$book[22]="Niruttidīpanīpāṭha";
-$book[23]="Paramatthadīpanī";
-$book[24]="Anudīpanīpāṭha";
-$book[25]="Paṭṭhānuddesa dīpanīpāṭha";
-$book[26]="Caturārakkhadīpanī";
-$book[27]="Kavidappaṇanīti";
-$book[28]="Nītimañjarī";
-$book[29]="Dhammanīti";
-$book[30]="Mahārahanīti";
-$book[31]="Lokanīti";
-$book[32]="Suttantanīti";
-$book[33]="Sūrassatīnīti";
-$book[34]="Cāṇakyanītipāḷi";
-$book[35]="Naradakkhadīpanī";
-$book[36]="Rasavāhinī";
-$book[37]="Sīmavisodhanī";
-$book[38]="Vessantarāgīti";
-$book[39]="Dīghanikāye";
-$book[40]="Majjhimanikāya";
-$book[41]="Saṃyuttanikāye";
-$book[42]="Aṅguttaranikāye";
-$book[43]="Vinayapiṭaka";
-$book[44]="Abhidhammapiṭaka";
-$book[45]="Aṭṭhakathā";
-$book[46]="Milidaṭīkā";
-$book[47]="Padamañjarī";
-$book[48]="Padasādhanaṃ";
-$book[49]="Saddabindu pakaraṇaṃ";
-$book[50]="Kaccāyana dhātu mañjūsā";
-$book[51]="Samantakūṭavaṇṇanā";
-$book[52]="Vuttisametā";
-$book[53]="Thupavaṃso";
-$book[54]="Dāṭhāvaṃso";
-$book[55]="Dhātupāṭha vilāsiniyā";
-$book[56]="Dhātuvaṃso";
-$book[57]="Hatthavanagallavihāra vaṃso";
-$book[58]="Jinacaritaya";
-$book[59]="Jinavaṃsadīpaṃ";
-$book[60]="Telakaṭāhagāthā";
-$book[61]="Cūḷaganthavaṃsapāḷi";
-$book[62]="Sāsanavaṃsappadīpikā";
-$book[63]="Mahāvaṃsapāḷi";
-$book[64]="Visuddhimaggo(Paṭhamo bhāgo)";
-$book[65]="Visuddhimaggo(Dutiyo bhāgo)";
-$book[66]="Visuddhimagga-mahāṭīkā(Paṭhamo bhāgo)";
-$book[67]="Visuddhimagga-mahāṭīkā(Dutiyo bhāgo)";
-$book[68]="Visuddhimagga nidānakathā";
-$book[69]="Paṭṭhānapāḷi(Dutiyo bhāgo)";
-$book[70]="Paṭṭhānapāḷi(Tatiyo bhāgo)";
-$book[71]="Paṭṭhānapāḷi(Catuttho bhāgo)";
-$book[72]="Paṭṭhānapāḷi(Pañcamo bhāgo)";
-$book[73]="Dhammasaṅgaṇīpāḷi";
-$book[74]="Vibhaṅgapāḷi";
-$book[75]="Dhātukathāpāḷi";
-$book[76]="Puggalapaññattipāḷi";
-$book[77]="Kathāvatthupāḷi";
-$book[78]="Yamakapāḷi (paṭhamo bhāgo)";
-$book[79]="Yamakapāḷi (dutiyo bhāgo)";
-$book[80]="Yamakapāḷi (tatiyo bhāgo)";
-$book[81]="Paṭṭhānapāḷi(Paṭhamo bhāgo)";
-$book[82]="Dasakanipātapāḷi";
-$book[83]="Ekādasakanipātapāḷi";
-$book[84]="Ekakanipātapāḷi";
-$book[85]="Dukanipātapāḷi";
-$book[86]="Tikanipātapāḷi";
-$book[87]="Catukkanipātapāḷi";
-$book[88]="Pañcakanipātapāḷi";
-$book[89]="Chakkanipātapāḷi";
-$book[90]="Sattakanipātapāḷi";
-$book[91]="Aṭṭhakanipātapāḷi";
-$book[92]="Navakanipātapāḷi";
-$book[93]="Sīlakkhandhavaggapāḷi";
-$book[94]="Mahāvaggapāḷi";
-$book[95]="Pāthikavaggapāḷi";
-$book[96]="Dhammasaṅgaṇī-aṭṭhakathā";
-$book[97]="Vibhaṅga-aṭṭhakathā";
-$book[98]="Pañcapakaraṇa-aṭṭhakathā";
-$book[99]="Ekakanipāta-aṭṭhakathā";
-$book[100]="Dukanipāta-aṭṭhakathā";
-$book[101]="Pañcakanipāta-aṭṭhakathā";
-$book[102]="Aṭṭhakanipāta-aṭṭhakathā";
-$book[103]="Sīlakkhandhavaggaṭṭhakathā";
-$book[104]="Mahāvaggaṭṭhakathā";
-$book[105]="Pāthikavaggaṭṭhakathā";
-$book[106]="Therīgāthā-aṭṭhakathā";
-$book[107]="Apadāna-aṭṭhakathā(Paṭhamo bhāgo)";
-$book[108]="Buddhavaṃsa-aṭṭhakathā";
-$book[109]="Cariyāpiṭaka-aṭṭhakathā";
-$book[110]="Jātaka-aṭṭhakathā(Paṭhamo bhāgo)";
-$book[111]="Jātaka-aṭṭhakathā(Dutiyo bhāgo)";
-$book[112]="Jātaka-aṭṭhakathā(Tatiyo bhāgo)";
-$book[113]="Jātaka-aṭṭhakathā(Catuttho bhāgo)";
-$book[114]="Jātaka-aṭṭhakathā(Pañcamo bhāgo)";
-$book[115]="Jātaka-aṭṭhakathā(Chaṭṭho bhāgo)";
-$book[116]="Khuddakapāṭha-aṭṭhakathā";
-$book[117]="Jātaka-aṭṭhakathā(Sattamo bhāgo)";
-$book[118]="Mahāniddesa-aṭṭhakathā";
-$book[119]="Cūḷaniddesa-aṭṭhakathā";
-$book[120]="Paṭisambhidāmagga-aṭṭhakathā(Paṭhamo bhāgo)";
-$book[121]="Nettippakaraṇa-aṭṭhakathā";
-$book[122]="Dhammapada-aṭṭhakathā";
-$book[123]="Udāna-aṭṭhakathā";
-$book[124]="Itivuttaka-aṭṭhakathā";
-$book[125]="Suttanipāta-aṭṭhakathā";
-$book[126]="Vimānavatthu-aṭṭhakathā";
-$book[127]="Petavatthu-aṭṭhakathā";
-$book[128]="Theragāthā-aṭṭhakathā(Paṭhamo bhāgo)";
-$book[129]="Theragāthā-aṭṭhakathā(Dutiyo bhāgo)";
-$book[130]="Mūlapaṇṇāsa-aṭṭhakathā";
-$book[131]="Majjhimapaṇṇāsa-aṭṭhakathā";
-$book[132]="Uparipaṇṇāsa-aṭṭhakathā";
-$book[133]="Sagāthāvagga-aṭṭhakathā";
-$book[134]="Nidānavagga-aṭṭhakathā";
-$book[135]="Khandhavagga-aṭṭhakathā";
-$book[136]="Saḷāyatanavagga-aṭṭhakathā";
-$book[137]="Mahāvagga-aṭṭhakathā";
-$book[138]="Pārājikakaṇḍa-aṭṭhakathā (paṭhamo bhāgo)";
-$book[139]="Pācittiya-aṭṭhakathā";
-$book[140]="Mahāvagga-aṭṭhakathā";
-$book[141]="Cūḷavagga-aṭṭhakathā";
-$book[142]="Parivāra-aṭṭhakathā";
-$book[143]="Therāpadānapāḷi(Paṭhamo bhāgo)";
-$book[144]="Therāpadānapāḷi(Dutiyo bhāgo)";
-$book[145]="Buddhavaṃsapāḷi";
-$book[146]="Cariyāpiṭakapāḷi";
-$book[147]="Jātakapāḷi(Dutiyo bhāgo)";
-$book[148]="Jātakapāḷi(Paṭhamo bhāgo)";
-$book[149]="Mahāniddesapāḷi";
-$book[150]="Cūḷaniddesapāḷi";
-$book[151]="Paṭisambhidāmaggapāḷi";
-$book[152]="Milindapañhapāḷi";
-$book[153]="Nettippakaraṇapāḷi";
-$book[154]="Khuddakapāṭhapāḷi";
-$book[155]="Peṭakopadesapāḷi";
-$book[156]="Dhammapadapāḷi";
-$book[157]="Udānapāḷi";
-$book[158]="Itivuttakapāḷi";
-$book[159]="Suttanipātapāḷi";
-$book[160]="Vimānavatthupāḷi";
-$book[161]="Petavatthupāḷi";
-$book[162]="Theragāthāpāḷi";
-$book[163]="Therīgāthāpāḷi";
-$book[164]="Mūlapaṇṇāsapāḷi";
-$book[165]="Majjhimapaṇṇāsapāḷi";
-$book[166]="Uparipaṇṇāsapāḷi";
-$book[167]="Sagāthāvaggo";
-$book[168]="Nidānavaggo";
-$book[169]="Khandhavaggo";
-$book[170]="Saḷāyatanavaggo";
-$book[171]="Mahāvaggo";
-$book[172]="Dhammasaṅgaṇī-mūlaṭīkā";
-$book[173]="Vibhaṅga-mūlaṭīkā";
-$book[174]="Pañcapakaraṇa-mūlaṭīkā";
-$book[175]="Dhammasaṅgaṇī-anuṭīkā";
-$book[176]="Pañcapakaraṇa-anuṭīkā";
-$book[177]="Ganthārambhakathā";
-$book[178]="Abhidhammatthasaṅgaho";
-$book[179]="Paṭhamo paricchedo";
-$book[180]="Abhidhammamātikāpāḷi";
-$book[181]="Ekakanipāta-ṭīkā";
-$book[182]="Dukanipāta-ṭīkā";
-$book[183]="Pañcakanipāta-ṭīkā";
-$book[184]="Aṭṭhakanipāta-ṭīkā";
-$book[185]="Sīlakkhandhavaggaṭīkā";
-$book[186]="Mahāvaggaṭīkā";
-$book[187]="Pāthikavaggaṭīkā";
-$book[188]="Sīlakkhandhavaggaabhinavaṭīkā";
-$book[189]="Sīlakkhandhavaggaabhinavaṭīkā";
-$book[190]="Nettippakaraṇa-ṭīkā";
-$book[191]="Nettivibhāvinī";
-$book[192]="Mūlapaṇṇāsa-ṭīkā";
-$book[193]="Majjhimapaṇṇāsaṭīkā";
-$book[194]="Uparipaṇṇāsa-ṭīkā";
-$book[195]="Sagāthāvaggaṭīkā";
-$book[196]="Nidānavaggaṭīkā";
-$book[197]="Khandhavaggaṭīkā";
-$book[198]="Saḷāyatanavaggaṭīkā";
-$book[199]="Mahāvaggaṭīkā";
-$book[200]="Vinayavinicchayo";
-$book[201]="Vinayavinicchayaṭīkā(Paṭhamo bhāgo)";
-$book[202]="Pācityādiyojanā";
-$book[203]="Khuddasikkhā-mūlasikkhā";
-$book[204]="Sāratthadīpanī-ṭīkā (paṭhamo bhāgo)";
-$book[205]="Sāratthadīpanī-ṭīkā (dutiyo bhāgo)";
-$book[206]="Sāratthadīpanī-ṭīkā (tatiyo bhāgo)";
-$book[207]="Bhikkhupātimokkhapāḷi";
-$book[208]="Vinayasaṅgaha-aṭṭhakathā";
-$book[209]="Vajirabuddhi-ṭīkā";
-$book[210]="Vimativinodanī-ṭīkā (paṭhamo bhāgo)";
-$book[211]="Vinayālaṅkāra-ṭīkā (paṭhamo bhāgo)";
-$book[212]="Kaṅkhāvitaraṇīpurāṇa-ṭīkā";
-$book[213]="Pārājikapāḷi";
-$book[214]="Pācittiyapāḷi";
-$book[215]="Mahāvaggapāḷi";
-$book[216]="Cūḷavaggapāḷi";
-$book[217]="Parivārapāḷi";
+$book[0] = "";
+$book[1] = "Namakkārapāḷi";
+$book[2] = "Mahāpaṇāmapāṭha(Buddhavandanā)";
+$book[3] = "Lakkhaṇāto";
+$book[4] = "Suttavandanā";
+$book[5] = "Jinālaṅkāra";
+$book[6] = "Kamalāñjali";
+$book[7] = "Pajjamadhu";
+$book[8] = "Buddhaguṇagāthāvalī";
+$book[9] = "Abhidhānappadīpikāṭīkā";
+$book[10] = "Subodhālaṅkāro";
+$book[11] = "Subodhālaṅkāraṭīkā";
+$book[12] = "Bālāvatāra";
+$book[13] = "Moggallānasuttapāṭho";
+$book[14] = "Kaccāyanabyākaraṇaṃ";
+$book[15] = "Saddanītippakaraṇaṃ (padamālā)";
+$book[16] = "Saddanītippakaraṇaṃ";
+$book[17] = "Padarūpasiddhi";
+$book[18] = "Moggallāna pañcikā ṭīkā";
+$book[19] = "Payogasiddhipāḷi";
+$book[20] = "Vuttodayaṃ";
+$book[21] = "Abhidhānappadīpikā";
+$book[22] = "Niruttidīpanīpāṭha";
+$book[23] = "Paramatthadīpanī";
+$book[24] = "Anudīpanīpāṭha";
+$book[25] = "Paṭṭhānuddesa dīpanīpāṭha";
+$book[26] = "Caturārakkhadīpanī";
+$book[27] = "Kavidappaṇanīti";
+$book[28] = "Nītimañjarī";
+$book[29] = "Dhammanīti";
+$book[30] = "Mahārahanīti";
+$book[31] = "Lokanīti";
+$book[32] = "Suttantanīti";
+$book[33] = "Sūrassatīnīti";
+$book[34] = "Cāṇakyanītipāḷi";
+$book[35] = "Naradakkhadīpanī";
+$book[36] = "Rasavāhinī";
+$book[37] = "Sīmavisodhanī";
+$book[38] = "Vessantarāgīti";
+$book[39] = "Dīghanikāye";
+$book[40] = "Majjhimanikāya";
+$book[41] = "Saṃyuttanikāye";
+$book[42] = "Aṅguttaranikāye";
+$book[43] = "Vinayapiṭaka";
+$book[44] = "Abhidhammapiṭaka";
+$book[45] = "Aṭṭhakathā";
+$book[46] = "Milidaṭīkā";
+$book[47] = "Padamañjarī";
+$book[48] = "Padasādhanaṃ";
+$book[49] = "Saddabindu pakaraṇaṃ";
+$book[50] = "Kaccāyana dhātu mañjūsā";
+$book[51] = "Samantakūṭavaṇṇanā";
+$book[52] = "Vuttisametā";
+$book[53] = "Thupavaṃso";
+$book[54] = "Dāṭhāvaṃso";
+$book[55] = "Dhātupāṭha vilāsiniyā";
+$book[56] = "Dhātuvaṃso";
+$book[57] = "Hatthavanagallavihāra vaṃso";
+$book[58] = "Jinacaritaya";
+$book[59] = "Jinavaṃsadīpaṃ";
+$book[60] = "Telakaṭāhagāthā";
+$book[61] = "Cūḷaganthavaṃsapāḷi";
+$book[62] = "Sāsanavaṃsappadīpikā";
+$book[63] = "Mahāvaṃsapāḷi";
+$book[64] = "Visuddhimaggo(Paṭhamo bhāgo)";
+$book[65] = "Visuddhimaggo(Dutiyo bhāgo)";
+$book[66] = "Visuddhimagga-mahāṭīkā(Paṭhamo bhāgo)";
+$book[67] = "Visuddhimagga-mahāṭīkā(Dutiyo bhāgo)";
+$book[68] = "Visuddhimagga nidānakathā";
+$book[69] = "Paṭṭhānapāḷi(Dutiyo bhāgo)";
+$book[70] = "Paṭṭhānapāḷi(Tatiyo bhāgo)";
+$book[71] = "Paṭṭhānapāḷi(Catuttho bhāgo)";
+$book[72] = "Paṭṭhānapāḷi(Pañcamo bhāgo)";
+$book[73] = "Dhammasaṅgaṇīpāḷi";
+$book[74] = "Vibhaṅgapāḷi";
+$book[75] = "Dhātukathāpāḷi";
+$book[76] = "Puggalapaññattipāḷi";
+$book[77] = "Kathāvatthupāḷi";
+$book[78] = "Yamakapāḷi (paṭhamo bhāgo)";
+$book[79] = "Yamakapāḷi (dutiyo bhāgo)";
+$book[80] = "Yamakapāḷi (tatiyo bhāgo)";
+$book[81] = "Paṭṭhānapāḷi(Paṭhamo bhāgo)";
+$book[82] = "Dasakanipātapāḷi";
+$book[83] = "Ekādasakanipātapāḷi";
+$book[84] = "Ekakanipātapāḷi";
+$book[85] = "Dukanipātapāḷi";
+$book[86] = "Tikanipātapāḷi";
+$book[87] = "Catukkanipātapāḷi";
+$book[88] = "Pañcakanipātapāḷi";
+$book[89] = "Chakkanipātapāḷi";
+$book[90] = "Sattakanipātapāḷi";
+$book[91] = "Aṭṭhakanipātapāḷi";
+$book[92] = "Navakanipātapāḷi";
+$book[93] = "Sīlakkhandhavaggapāḷi";
+$book[94] = "Mahāvaggapāḷi";
+$book[95] = "Pāthikavaggapāḷi";
+$book[96] = "Dhammasaṅgaṇī-aṭṭhakathā";
+$book[97] = "Vibhaṅga-aṭṭhakathā";
+$book[98] = "Pañcapakaraṇa-aṭṭhakathā";
+$book[99] = "Ekakanipāta-aṭṭhakathā";
+$book[100] = "Dukanipāta-aṭṭhakathā";
+$book[101] = "Pañcakanipāta-aṭṭhakathā";
+$book[102] = "Aṭṭhakanipāta-aṭṭhakathā";
+$book[103] = "Sīlakkhandhavaggaṭṭhakathā";
+$book[104] = "Mahāvaggaṭṭhakathā";
+$book[105] = "Pāthikavaggaṭṭhakathā";
+$book[106] = "Therīgāthā-aṭṭhakathā";
+$book[107] = "Apadāna-aṭṭhakathā(Paṭhamo bhāgo)";
+$book[108] = "Buddhavaṃsa-aṭṭhakathā";
+$book[109] = "Cariyāpiṭaka-aṭṭhakathā";
+$book[110] = "Jātaka-aṭṭhakathā(Paṭhamo bhāgo)";
+$book[111] = "Jātaka-aṭṭhakathā(Dutiyo bhāgo)";
+$book[112] = "Jātaka-aṭṭhakathā(Tatiyo bhāgo)";
+$book[113] = "Jātaka-aṭṭhakathā(Catuttho bhāgo)";
+$book[114] = "Jātaka-aṭṭhakathā(Pañcamo bhāgo)";
+$book[115] = "Jātaka-aṭṭhakathā(Chaṭṭho bhāgo)";
+$book[116] = "Khuddakapāṭha-aṭṭhakathā";
+$book[117] = "Jātaka-aṭṭhakathā(Sattamo bhāgo)";
+$book[118] = "Mahāniddesa-aṭṭhakathā";
+$book[119] = "Cūḷaniddesa-aṭṭhakathā";
+$book[120] = "Paṭisambhidāmagga-aṭṭhakathā(Paṭhamo bhāgo)";
+$book[121] = "Nettippakaraṇa-aṭṭhakathā";
+$book[122] = "Dhammapada-aṭṭhakathā";
+$book[123] = "Udāna-aṭṭhakathā";
+$book[124] = "Itivuttaka-aṭṭhakathā";
+$book[125] = "Suttanipāta-aṭṭhakathā";
+$book[126] = "Vimānavatthu-aṭṭhakathā";
+$book[127] = "Petavatthu-aṭṭhakathā";
+$book[128] = "Theragāthā-aṭṭhakathā(Paṭhamo bhāgo)";
+$book[129] = "Theragāthā-aṭṭhakathā(Dutiyo bhāgo)";
+$book[130] = "Mūlapaṇṇāsa-aṭṭhakathā";
+$book[131] = "Majjhimapaṇṇāsa-aṭṭhakathā";
+$book[132] = "Uparipaṇṇāsa-aṭṭhakathā";
+$book[133] = "Sagāthāvagga-aṭṭhakathā";
+$book[134] = "Nidānavagga-aṭṭhakathā";
+$book[135] = "Khandhavagga-aṭṭhakathā";
+$book[136] = "Saḷāyatanavagga-aṭṭhakathā";
+$book[137] = "Mahāvagga-aṭṭhakathā";
+$book[138] = "Pārājikakaṇḍa-aṭṭhakathā (paṭhamo bhāgo)";
+$book[139] = "Pācittiya-aṭṭhakathā";
+$book[140] = "Mahāvagga-aṭṭhakathā";
+$book[141] = "Cūḷavagga-aṭṭhakathā";
+$book[142] = "Parivāra-aṭṭhakathā";
+$book[143] = "Therāpadānapāḷi(Paṭhamo bhāgo)";
+$book[144] = "Therāpadānapāḷi(Dutiyo bhāgo)";
+$book[145] = "Buddhavaṃsapāḷi";
+$book[146] = "Cariyāpiṭakapāḷi";
+$book[147] = "Jātakapāḷi(Dutiyo bhāgo)";
+$book[148] = "Jātakapāḷi(Paṭhamo bhāgo)";
+$book[149] = "Mahāniddesapāḷi";
+$book[150] = "Cūḷaniddesapāḷi";
+$book[151] = "Paṭisambhidāmaggapāḷi";
+$book[152] = "Milindapañhapāḷi";
+$book[153] = "Nettippakaraṇapāḷi";
+$book[154] = "Khuddakapāṭhapāḷi";
+$book[155] = "Peṭakopadesapāḷi";
+$book[156] = "Dhammapadapāḷi";
+$book[157] = "Udānapāḷi";
+$book[158] = "Itivuttakapāḷi";
+$book[159] = "Suttanipātapāḷi";
+$book[160] = "Vimānavatthupāḷi";
+$book[161] = "Petavatthupāḷi";
+$book[162] = "Theragāthāpāḷi";
+$book[163] = "Therīgāthāpāḷi";
+$book[164] = "Mūlapaṇṇāsapāḷi";
+$book[165] = "Majjhimapaṇṇāsapāḷi";
+$book[166] = "Uparipaṇṇāsapāḷi";
+$book[167] = "Sagāthāvaggo";
+$book[168] = "Nidānavaggo";
+$book[169] = "Khandhavaggo";
+$book[170] = "Saḷāyatanavaggo";
+$book[171] = "Mahāvaggo";
+$book[172] = "Dhammasaṅgaṇī-mūlaṭīkā";
+$book[173] = "Vibhaṅga-mūlaṭīkā";
+$book[174] = "Pañcapakaraṇa-mūlaṭīkā";
+$book[175] = "Dhammasaṅgaṇī-anuṭīkā";
+$book[176] = "Pañcapakaraṇa-anuṭīkā";
+$book[177] = "Ganthārambhakathā";
+$book[178] = "Abhidhammatthasaṅgaho";
+$book[179] = "Paṭhamo paricchedo";
+$book[180] = "Abhidhammamātikāpāḷi";
+$book[181] = "Ekakanipāta-ṭīkā";
+$book[182] = "Dukanipāta-ṭīkā";
+$book[183] = "Pañcakanipāta-ṭīkā";
+$book[184] = "Aṭṭhakanipāta-ṭīkā";
+$book[185] = "Sīlakkhandhavaggaṭīkā";
+$book[186] = "Mahāvaggaṭīkā";
+$book[187] = "Pāthikavaggaṭīkā";
+$book[188] = "Sīlakkhandhavaggaabhinavaṭīkā";
+$book[189] = "Sīlakkhandhavaggaabhinavaṭīkā";
+$book[190] = "Nettippakaraṇa-ṭīkā";
+$book[191] = "Nettivibhāvinī";
+$book[192] = "Mūlapaṇṇāsa-ṭīkā";
+$book[193] = "Majjhimapaṇṇāsaṭīkā";
+$book[194] = "Uparipaṇṇāsa-ṭīkā";
+$book[195] = "Sagāthāvaggaṭīkā";
+$book[196] = "Nidānavaggaṭīkā";
+$book[197] = "Khandhavaggaṭīkā";
+$book[198] = "Saḷāyatanavaggaṭīkā";
+$book[199] = "Mahāvaggaṭīkā";
+$book[200] = "Vinayavinicchayo";
+$book[201] = "Vinayavinicchayaṭīkā(Paṭhamo bhāgo)";
+$book[202] = "Pācityādiyojanā";
+$book[203] = "Khuddasikkhā-mūlasikkhā";
+$book[204] = "Sāratthadīpanī-ṭīkā (paṭhamo bhāgo)";
+$book[205] = "Sāratthadīpanī-ṭīkā (dutiyo bhāgo)";
+$book[206] = "Sāratthadīpanī-ṭīkā (tatiyo bhāgo)";
+$book[207] = "Bhikkhupātimokkhapāḷi";
+$book[208] = "Vinayasaṅgaha-aṭṭhakathā";
+$book[209] = "Vajirabuddhi-ṭīkā";
+$book[210] = "Vimativinodanī-ṭīkā (paṭhamo bhāgo)";
+$book[211] = "Vinayālaṅkāra-ṭīkā (paṭhamo bhāgo)";
+$book[212] = "Kaṅkhāvitaraṇīpurāṇa-ṭīkā";
+$book[213] = "Pārājikapāḷi";
+$book[214] = "Pācittiyapāḷi";
+$book[215] = "Mahāvaggapāḷi";
+$book[216] = "Cūḷavaggapāḷi";
+$book[217] = "Parivārapāḷi";
 
 //for($i=2;$i<218;$i++)
-$i=$from;
+$i = $from;
 {
-	$db_file = "../appdata/palicanon/pali_text/p".$i."_pali.db3";
-	$filename="appdata/palicanon/pali_text/p".$i."_pali.db3";
-	PDO_Connect("sqlite:$db_file");
-	$query="CREATE TABLE album (
+    $db_file = "../appdata/palicanon/pali_text/p" . $i . "_pali.db3";
+    $filename = "appdata/palicanon/pali_text/p" . $i . "_pali.db3";
+    PDO_Connect("$db_file");
+    $query = "CREATE TABLE album (
     id           INTEGER PRIMARY KEY ASC AUTOINCREMENT,
 	guid TEXT,
     title         TEXT,
@@ -258,31 +258,30 @@ $i=$from;
         print_r($error[2]);
         exit;
     }
-	
-	echo "create $i ok<br>";
-	
-	$guid=GUIDv4();
-	$query="INSERT INTO album (id, guid,title,file,cover,language,author,target,summary,publish_time,update_time,edition1,type) VALUES ('1','$guid','".$book[$i]."', '$filename','','0','VRI','','','1','1','CSCD4','1')";
-	
+
+    echo "create $i ok<br>";
+
+    $guid = GUIDv4();
+    $query = "INSERT INTO album (id, guid,title,file,cover,language,author,target,summary,publish_time,update_time,edition1,type) VALUES ('1','$guid','" . $book[$i] . "', '$filename','','0','VRI','','','1','1','CSCD4','1')";
+
     $stmt = @PDO_Execute($query);
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
         print_r($error[2]);
         exit;
     }
-	
 
-	echo "insert $i ok<br>";	
-	
-	$query="ALTER TABLE data ADD album INTEGER";	
+    echo "insert $i ok<br>";
+
+    $query = "ALTER TABLE data ADD album INTEGER";
     $stmt = @PDO_Execute($query);
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
         print_r($error[2]);
         exit;
     }
-	
-	$query="UPDATE data SET album = '1' WHERE 1 ";
+
+    $query = "UPDATE data SET album = '1' WHERE 1 ";
     $stmt = @PDO_Execute($query);
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
@@ -290,13 +289,12 @@ $i=$from;
         exit;
     }
 }
-if($from==$to){
-	echo "<h2>齐活!功德无量!all done!</h2>";
-}
-else{
-	echo "<script>";
-	echo "window.location.assign(\"change.php?from=".($from+1)."&to=".$to."\")";
-	echo "</script>";
-	echo "正在载入:".($from+1)."——".$book[$from+1];
+if ($from == $to) {
+    echo "<h2>齐活!功德无量!all done!</h2>";
+} else {
+    echo "<script>";
+    echo "window.location.assign(\"change.php?from=" . ($from + 1) . "&to=" . $to . "\")";
+    echo "</script>";
+    echo "正在载入:" . ($from + 1) . "——" . $book[$from + 1];
 }
 ?>

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff