Pārlūkot izejas kodu

同步 增加channel 表

visuddhinanda 4 gadi atpakaļ
vecāks
revīzija
b1e65c923a

+ 2 - 0
app/db/table.php

@@ -4,6 +4,8 @@
 			  ->set($date)
 			  ->commit();
 		*/
+require_once "../redis/function.php";
+
 class Table
 {
     protected $dbh;

+ 3 - 3
app/sync/login.php

@@ -25,8 +25,6 @@ if(isset($_POST["userid"]) && isset($_POST["password"]) ){
 	if($user->check_password($_POST["userid"],$_POST["password"])){
 		if(isset($_POST["server"])){
 			#本地登录
-			setcookie ( "sync_userid" ,  $_POST["userid"] , 0 ,  "/" , "" ,  false , true );
-			setcookie ( "sync_server" ,  $_POST["server"] , 0 ,  "/" , "" ,  false , true );
 			#在远程主机验证用户身份
 			$phpFile = $_POST["server"]."/app/sync/login.php";
 			$client = new \GuzzleHttp\Client();
@@ -35,8 +33,10 @@ if(isset($_POST["userid"]) && isset($_POST["password"]) ){
 			$arrServerMsg = json_decode($serveMsg,true);
 			if($arrServerMsg["error"]==0){
 				#验证成功
+				setcookie ( "sync_userid" ,  $_POST["userid"] , 0 ,  "/" , "" ,  false , true );
+				setcookie ( "sync_server" ,  $_POST["server"] , 0 ,  "/" , "" ,  false , true );				
 				$redis->hset("sync://key",$_POST["userid"],$arrServerMsg["key"]);
-				$output["message"]="本机登录成功<br>服务器验证成功:msg:".$serveMsg."<br>";
+				$output["message"]="本机登录成功<br>服务器验证成功<br>";
 				$output["message"].="<a href='index.php'>开始同步</a>";
 			}
 			else{

+ 1 - 0
app/sync/sync.js

@@ -2,6 +2,7 @@ var sync_db_list = [
 	{ script: "sync/table_article.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_term.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_article_collect.php", count: -1, finished: 0, enable: false },
+	{ script: "sync/table_channel.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_sentence.php", count: -1, finished: 0, enable: true },
 ];
 var isStop = false;

+ 0 - 2
app/sync/sync.php

@@ -160,7 +160,6 @@ else{
 	$message .= "<div>";
 	if(count($update_to_local)>0){
 		$message .=  "需要更新到目标机".count($update_to_local)."条记录 | ";
-		/*
 		$idInServer = json_encode($update_to_local, JSON_UNESCAPED_UNICODE);
 		$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'get','id'=>"{$idInServer}","key"=>$sync_key,"userid"=>$_COOKIE["userid"]]]);
 		$serverData=(string)$response->getBody();
@@ -176,7 +175,6 @@ else{
 		else{
 			$message .= "数据提取错误 错误信息:{$arrData["message"]} ";
 		}
-		*/
 	}
 	$message .= "</div>";
 

+ 7 - 14
app/sync/table_channel.php

@@ -14,29 +14,22 @@ $input = (object) [
     "receive_time" =>  "receive_time",
     "insert" => [
         'id',
-		'title',
-		'subtitle',
-		'summary',
-		'content',
-		'tag',
 		'owner',
-		'setting',
+		'name',
+		'summary',
 		'status',
+		'lang',
 		'create_time',
 		'modify_time',
 		'receive_time'
     ],
     "update" =>  [
-		'title',
-		'subtitle',
-		'summary',
-		'content',
-		'tag',
 		'owner',
-		'setting',
+		'name',
+		'summary',
 		'status',
-		'modify_time',
-		'receive_time'
+		'lang',
+		'modify_time'
     ]    
 ];
 

+ 1 - 1
app/sync/table_term.php

@@ -8,7 +8,7 @@ $input = (object) [
     "database" =>  _FILE_DB_TERM_,
     "table" =>  "term",
     "uuid" =>  "guid",
-    "sync_id" =>  ["pali","tag","channal"],
+    "sync_id" =>  ["pali","tag","channal","owner"],
     "modify_time" =>  "modify_time",
     "receive_time" =>  "receive_time",
 	"where"=>"",

+ 1 - 1
app/usent/function.php

@@ -192,7 +192,7 @@ class Sent_DB
 					$sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],$data["modify_time"],mTime(),$data["book"],$data["paragraph"],$data["begin"],$data["end"],$data["channal"]));
 				}
 			}
-			else{
+			else if(isset($arrData[0]["id"])){
 				$query = "UPDATE sentence SET text = ? , strlen = ? , editor=?, modify_time= ? ,receive_time = ?   where  id= ?  ";
 				$sth = $this->dbh_sent->prepare($query);
 				foreach ($arrData as $data) {