visuddhinanda 4 yıl önce
ebeveyn
işleme
5c9697043b

+ 5 - 4
app/install/db_update_toc.php

@@ -114,14 +114,14 @@ if (($fp = fopen(_DIR_PALI_TITLE_ . "/" . ($from + 1) . "_{$_file}.csv", "r")) !
 $book = $from + 1;
 
 //删除已有标题
-PDO_Connect("" . _FILE_DB_RESRES_INDEX_);
-$query = " DELETE FROM 'index' WHERE book ='{$book}'  AND  language = '{$_lang}'  ";
+PDO_Connect(_FILE_DB_RESRES_INDEX_);
+$query = "DELETE FROM "._TABLE_RES_INDEX_." WHERE book = ?  AND  language = ?  ";
+PDO_Execute($query, array($book,$_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 "._TABLE_RES_INDEX_." (book , paragraph, title, title_en , level, type , language , author , share , create_time , update_time  ) VALUES (  ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
 $stmt = $PDO->prepare($query);
 if ($_lang == "pali") {
     $type = 1;
@@ -136,6 +136,7 @@ foreach ($arrInserString as $title) {
     } else {
         $author = "";
     }
+	$title[6] = mb_substr($title[6],0,1024);
     $newData = array(
         $book,
         $title[2],

+ 7 - 7
app/palicanon/book_tag.php

@@ -24,16 +24,16 @@ foreach ($arrBookTag as $bookkey => $bookvalue) {
     }
 }
 
-$dns = "" . _FILE_DB_PALI_TOC_;
-$dbh_toc = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_PALITEXT_;
-$dbh_pali_text = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dns = "" . _FILE_DB_RESRES_INDEX_;
-$dbh_res = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_RESRES_INDEX_;
+$dbh_res = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh_res->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 foreach ($output as $key => $value) {
@@ -72,7 +72,7 @@ foreach ($output as $key => $value) {
 
             #查标题
             if (isset($_GET["lang"])) {
-                $query = "SELECT title from 'index' where book=? and paragraph=? and language=?";
+                $query = "SELECT title from "._TABLE_RES_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"]));

+ 7 - 7
app/pcdl/search.php

@@ -94,10 +94,10 @@ switch ($op) {
         }
         PDO_Connect(_FILE_DB_RESRES_INDEX_);
         //查标签
-        $query = "select count(*) from 'index' where tag like '%$word%'";
+        $query = "SELECT count(*) from "._TABLE_RES_INDEX_." where tag like '%$word%'";
         $count = PDO_FetchOne($query);
 
-        $query = "select * from 'index' where tag like '%$word%' limit 0,10";
+        $query = "SELECT * from "._TABLE_RES_INDEX_." where tag like '%$word%' limit 0,10";
         $Fetch = PDO_FetchAll($query);
         $iFetch = count($Fetch);
         if ($iFetch > 0) {
@@ -116,17 +116,17 @@ switch ($op) {
         echo "<div id='author_name'>$word</div>";
         echo "<div id='search_body'>";
         //author id
-        $query = "select id from 'author' where name = '$word'";
+        $query = "SELECT id from 'author' where name = '$word'";
         $arr_author = PDO_FetchAll($query);
         if (count($arr_author) > 0) {
             $author_id = $arr_author[0]["id"];
         }
 
         //查album
-        $query = "select count(*) from 'album' where author = '$author_id'";
+        $query = "SELECT count(*) from 'album' where author = '$author_id'";
         $count = PDO_FetchOne($query);
         if ($count > 0) {
-            $query = "select * from 'album' where author = '$author_id' limit 0,10";
+            $query = "SELECT * from 'album' where author = '$author_id' limit 0,10";
             $Fetch = PDO_FetchAll($query);
             $iFetch = count($Fetch);
             if ($iFetch > 0) {
@@ -139,10 +139,10 @@ switch ($op) {
         }
 
         //查资源
-        $query = "select count(*) from 'index' where author = '$author_id'";
+        $query = "SELECT count(*) from "._TABLE_RES_INDEX_." where author = '$author_id'";
         $count = PDO_FetchOne($query);
         if ($count > 0) {
-            $query = "select * from 'index' where author = '$author_id' limit 0,10";
+            $query = "SELECT * from "._TABLE_RES_INDEX_." where author = '$author_id' limit 0,10";
 
             $Fetch = PDO_FetchAll($query);
             $iFetch = count($Fetch);

+ 1 - 1
app/pcdl/tag_search.php

@@ -16,7 +16,7 @@ if (isset($_POST["order"])) {
 
 PDO_Connect(_FILE_DB_RESRES_INDEX_);
 $tag_string = '{' . $tag . '}';
-$query = "select * from 'index' where tag like '%$tag_string%' ";
+$query = "SELECT * from "._TABLE_RES_INDEX_." where tag like '%$tag_string%' ";
 $Fetch = PDO_FetchAll($query);
 $iFetch = count($Fetch);
 if ($iFetch > 0) {

+ 6 - 6
app/pcdl/update_index.php

@@ -211,12 +211,12 @@ switch ($res_type) {
                 //开始更新索引
                 foreach ($title_data as $oneTitle) {
                     if ($oneTitle["level"] > 0 && $oneTitle["level"] < 8) {
-                        $query = "select * from 'index' where album = '$album_index' and book='" . $oneTitle["book"] . "' and paragraph='" . $oneTitle["paragraph"] . "'";
+                        $query = "SELECT * FROM "._TABLE_RES_INDEX_." where album = '$album_index' and book='" . $oneTitle["book"] . "' and paragraph='" . $oneTitle["paragraph"] . "'";
                         $search_title = PDO_FetchAll($query);
                         $title_en = pali2english($oneTitle["text"]);
                         //找到已有的记录  更新
                         if (count($search_title) != 0) {
-                            $query = "UPDATE 'index' SET title = '" . $oneTitle["text"] . "' ,
+                            $query = "UPDATE "._TABLE_RES_INDEX_." SET title = '" . $oneTitle["text"] . "' ,
 												 title_en = '" . $title_en . "' ,
 												 language = '1' ,
 												 type = '$type',
@@ -237,7 +237,7 @@ switch ($res_type) {
                             if (substr($book, 0, 1) == "b") {
                                 $book = substr($book, 1);
                             }
-                            $query = "INSERT INTO 'index' (id,
+                            $query = "INSERT INTO "._TABLE_RES_INDEX_." (id,
 						book,
 						paragraph,
 						title,
@@ -340,7 +340,7 @@ switch ($res_type) {
         $query = "select * from album where 1";
         $search_album = PDO_FetchAll($query);
         foreach ($search_album as $oneAlbum) {
-            $query = "select id from 'index' where album = '{$oneAlbum["id"]}' and
+            $query = "SELECT id FROM "._TABLE_RES_INDEX_." where album = '{$oneAlbum["id"]}' and
 													   book='{$oneAlbum["book"]}' and
 													   paragraph='-1'";
             $id = PDO_FetchAll($query);
@@ -348,7 +348,7 @@ switch ($res_type) {
             //找到已有的记录  更新
             $title_en = pali2english($oneAlbum["title"]);
             if (count($id) > 0) {
-                $query = "UPDATE 'index' SET title = '{$oneAlbum["title"]}' ,
+                $query = "UPDATE "._TABLE_RES_INDEX_." SET title = '{$oneAlbum["title"]}' ,
 										 title_en = '{$title_en}' ,
 										 language = '{$oneAlbum["language"]}' ,
 										 type = '{$oneAlbum["type"]}',
@@ -368,7 +368,7 @@ switch ($res_type) {
             } else {
                 /*未找到 插入*/
                 $book = $oneAlbum["book"];
-                $query = "INSERT INTO 'index' (id,
+                $query = "INSERT INTO "._TABLE_RES_INDEX_." (id,
 				book,
 				paragraph,
 				title,

+ 6 - 4
app/pcdl/update_translate.php

@@ -123,13 +123,13 @@ echo "<h2>$from</h2>";
             //开始更新索引
             for ($iPar = 0; $iPar < count($paragraph_list); $iPar++) {
                 $oneTitle = $paragraph_list[$iPar];
-                $query = "select * from 'index' where album = '$album_index' and book='" . $book . "' and paragraph='" . $paragraph_list[$iPar]["paragraph"] . "'";
+                $query = "select * from "._TABLE_RES_INDEX_." where album = '$album_index' and book='" . $book . "' and paragraph='" . $paragraph_list[$iPar]["paragraph"] . "'";
                 $search_title = PDO_FetchAll($query);
                 $title_en = $oneTitle["text"];
 
                 //找到已有的记录  更新
                 if (count($search_title) != 0) {
-                    $query = "UPDATE 'index' SET title = '" . $oneTitle["text"] . "' ,
+                    $query = "UPDATE "._TABLE_RES_INDEX_." SET title = '" . $oneTitle["text"] . "' ,
 					                         title_en = '" . $title_en . "' ,
 											 language = '1' ,
 											 type = '$type',
@@ -144,11 +144,13 @@ echo "<h2>$from</h2>";
                         break;
                     }
 
-                } else { /*未找到 插入*/
+                } else { 
+					# 未找到 插入
                     if (substr($book, 0, 1) == "b") {
                         $book = substr($book, 1);
                     }
-                    $query = "INSERT INTO 'index' (id,
+                    $query = "INSERT INTO "._TABLE_RES_INDEX_." 
+					(id,
 					book,
 					paragraph,
 					title,

+ 6 - 6
app/search/title_search.php

@@ -34,7 +34,7 @@ function render_book_list($strWord, $booklist = null)
             $aInputBook["{$oneBook}"] = 1;
         }
     }
-    $query = "select book,count(book) as co from 'index' where \"title_en\" like '%{$strWord}%' or \"title\" like '%{$strWord}%' group by book order by co DESC";
+    $query = "SELECT book,count(book) as co FROM "._TABLE_RES_INDEX_." where title_en like '%{$strWord}%' or title like '%{$strWord}%' group by book order by co DESC";
     $Fetch = PDO_FetchAll($query);
     $iFetch = count($Fetch);
     $newBookList = array();
@@ -128,7 +128,7 @@ switch ($op) {
                 }
                 echo "</div>";
             }
-            $query = "select title from 'index' where \"title_en\" like " . $PDO->quote("%" . $searching . '%') . " OR \"title\" like " . $PDO->quote("%" . $searching . '%') . " group by title limit 0,20";
+            $query = "SELECT title from "._TABLE_RES_INDEX_." where (title_en like " . $PDO->quote("%" . $searching . '%') . " OR title like " . $PDO->quote("%" . $searching . '%') . ") group by id , title limit 20";
             $Fetch = PDO_FetchAll($query);
             $queryTime = (microtime_float() - $time_start) * 1000;
             $iFetch = count($Fetch);
@@ -181,9 +181,9 @@ switch ($op) {
 
             PDO_Connect( _FILE_DB_RESRES_INDEX_);
             if (isset($_GET["booklist"])) {
-                $query = "select * from 'index' where (\"title_en\" like " . $PDO->quote("%" . $_GET["word"] . '%') . " OR \"title\" like " . $PDO->quote("%" . $_GET["word"] . '%') . ") and book in {$_GET["booklist"]} limit 0,50";
+                $query = "SELECT * from "._TABLE_RES_INDEX_." where (title_en like " . $PDO->quote("%" . $_GET["word"] . '%') . " OR title like " . $PDO->quote("%" . $_GET["word"] . '%') . ") and book in {$_GET["booklist"]} limit 50";
             } else {
-                $query = "select * from 'index' where \"title_en\" like " . $PDO->quote("%" . $_GET["word"] . '%') . " OR \"title\" like " . $PDO->quote("%" . $_GET["word"] . '%') . " limit 0,50";
+                $query = "SELECT * from "._TABLE_RES_INDEX_." where title_en like " . $PDO->quote("%" . $_GET["word"] . '%') . " OR title like " . $PDO->quote("%" . $_GET["word"] . '%') . " limit 50";
             }
             $Fetch = PDO_FetchAll($query);
             $queryTime = (microtime_float() - $time_start) * 1000;
@@ -301,7 +301,7 @@ switch ($op) {
                         echo "<div class='dict'>《{$bookname}》 $c1 $c2 </div>";
                         echo "<div class='mean'>$paliword</div>";
 
-                        $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
+                        $query = "SELECT * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
                         $FetchPaliText = PDO_FetchAll($query);
                         $countPaliText = count($FetchPaliText);
                         if ($countPaliText > 0) {
@@ -311,7 +311,7 @@ switch ($op) {
                                 $deep = 0;
                                 $sFirstParentTitle = "";
                                 while ($parent > -1) {
-                                    $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
+                                    $query = "SELECT * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
                                     $FetParent = PDO_FetchAll($query);
                                     if ($sFirstParentTitle == "") {
                                         $sFirstParentTitle = $FetParent[0]["toc"];

+ 1 - 1
app/studio/get_res_json.php

@@ -72,7 +72,7 @@ if ($paragraph == -1) {
 } else {
     //查书中的一个段
     PDO_Connect(_FILE_DB_RESRES_INDEX_);
-    $query = "select * from 'index' where book='{$book}' and paragraph='{$paragraph}' and type < '5' ";
+    $query = "SELECT * from "._TABLE_RES_INDEX_." where book='{$book}' and paragraph='{$paragraph}' and type < '5' ";
     $Fetch = PDO_FetchAll($query);
     $iFetch = count($Fetch);
     if ($iFetch > 0) {