Browse Source

记录用户操作log

visuddhinanda 5 years ago
parent
commit
868269ecc7

+ 2 - 1
app/article/my_article_post.php

@@ -4,7 +4,8 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 require_once "../ucenter/active.php";
-add_edit_event("article",array("id"=>$_POST["id"],"action"=>"update"));
+
+add_edit_event(_ARTICLE_EDIT_,$_POST["id"]);
 
 $respond=array("status"=>0,"message"=>"");
 

+ 3 - 1
app/article/my_article_put.php

@@ -11,7 +11,9 @@ PDO_Connect("sqlite:"._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);
 $uuid = UUID::v4();
-add_edit_event("article",array("id"=>$uuid,"action"=>"insert"));
+//写入日志
+add_edit_event(_ARTICLE_NEW_,$uuid);
+
 $sth->execute(array($uuid , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 1 , mTime() ,  mTime() , mTime() ));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {

+ 1 - 1
app/article/my_collect_post.php

@@ -5,7 +5,7 @@ require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 require_once "../ucenter/active.php";
 
-add_edit_event("collect",array("id"=>$_POST["id"]));
+add_edit_event(_COLLECTION_EDIT_,$_POST["id"]);
 
 $respond=array("status"=>0,"message"=>"");
 

+ 1 - 1
app/article/my_collect_put.php

@@ -11,7 +11,7 @@ PDO_Connect("sqlite:"._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);
 $uuid = UUID::v4();
-add_edit_event("collect",array("id"=>$uuid));
+add_edit_event(_COLLECTION_NEW_,$uuid);
 $sth->execute(array($uuid , $_POST["title"] , "" ,"", "[]" ,  $_COOKIE["userid"] , "" , 1 , mTime() ,  mTime() , mTime() ));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {

+ 1 - 1
app/dict/dict_lookup.php

@@ -149,7 +149,7 @@ switch($op){
 		echo "</div>";
 		break;
 	case "search":
-		add_edit_event("lookup");
+		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 = [];

+ 14 - 0
app/nissaya/get.php

@@ -1,6 +1,7 @@
 <?php
 require_once "../public/_pdo.php";
 require_once "../path.php";
+require_once "../ucenter/active.php";
 
 $result["error"]="";
 $result["data"]=array();
@@ -22,6 +23,19 @@ else{
 	exit;
 }
 
+if(isset($_GET["begin"])){
+	$begin = $_GET["begin"];
+}
+else{
+	$begin = 0;
+}
+if(isset($_GET["end"])){
+	$end = $_GET["end"];
+}
+else{
+	$end = 0;
+}
+add_edit_event(_FIND_IN_NISSAYA_,"{$book}-{$para}-{$begin}-{$end}");
 
 PDO_Connect("sqlite:"._FILE_DB_PAGE_INDEX_);
 $query = "SELECT * from m where book=? and para=?";

+ 29 - 2
app/nissaya/index.php

@@ -16,9 +16,36 @@ require_once "../pcdl/html_head.php";
     width: 100vw;	
 }
 </style>
+<?php
+if(isset($_GET["book"])){
+	$book = $_GET["book"];
+}
+else{
+	$book = 0;
+}
+if(isset($_GET["para"])){
+	$para = $_GET["para"];
+}
+else{
+	$para = 0;
+}
+if(isset($_GET["begin"])){
+	$begin = $_GET["begin"];
+}
+else{
+	$begin = 0;
+}
+if(isset($_GET["end"])){
+	$end = $_GET["end"];
+}
+else{
+	$end = 0;
+}
+?>
 <script>
-_nissaya_book = <?php echo $_GET["book"];?>;
-_nissaya_para = <?php echo $_GET["para"];?>;
+$(document).ready(function () {
+	nissaya_get(<?php echo "{$book},{$para},{$begin},{$end}";?>);
+});
 </script>
 
 <div id="contence">

+ 4 - 18
app/nissaya/nissaya.js

@@ -1,13 +1,8 @@
-var _nissaya_book = 0;
-var _nissaya_para = 0;
 var _nsy_book_dir = "";
 var _nsy_book_id = "";
 
-$(document).ready(function () {
-	nissaya_get(_nissaya_book, _nissaya_para);
-});
-function nissaya_get(book, para) {
-	if (book == 0 || _nissaya_para == 0) {
+function nissaya_get(book, para, begin = 0, end = 0) {
+	if (book == 0 || para == 0) {
 		return;
 	}
 	$.get(
@@ -15,6 +10,8 @@ function nissaya_get(book, para) {
 		{
 			book: book,
 			para: para,
+			begin: begin,
+			end: end,
 		},
 		function (data) {
 			let result = JSON.parse(data);
@@ -23,10 +20,7 @@ function nissaya_get(book, para) {
 					//找到的书的列表
 					for (const iterator of result.data) {
 					}
-					//_nsy_book_dir = data.bookid.split("_")[0];
-					//_nsy_book_id = result.data[0].nsyid;
 					$("#contence").html(render_nissaya_init(result.data[0]));
-					//insert_new_befor(1);
 					insert_new_end(1);
 				}
 			}
@@ -56,14 +50,6 @@ function render_nissaya_init(data) {
 		page: data.nsypagenumber,
 		show: true,
 	});
-	/*
-	let filename = dir + "/" + data.nsyid + "_" + data.nsypagenumber + ".gif";
-	let html = "";
-	html += "<div class='img_box' dir='" + dir + "' book='" + data.nsyid + "' page='" + data.nsypagenumber + "'>";
-	html += "<img src='../../tmp/nissaya/" + filename + "' />";
-	html += "</div>";
-	return html;
-	*/
 }
 
 function insert_new_befor(num = 2) {

+ 1 - 0
app/path.php

@@ -85,5 +85,6 @@ 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");
 
 ?>

+ 15 - 0
app/public/php/define.php

@@ -6,4 +6,19 @@ define("_CONTENT_VISIBILITY_PRIVATE_" , 10);
 define("_CONTENT_VISIBILITY_UNLISTED_" , 20);
 define("_CONTENT_VISIBILITY_PUBLIC_" , 30);
 
+#用户操作
+define("_CHANNEL_EDIT_",10);
+define("_CHANNEL_NEW_",11);
+define("_ARTICLE_EDIT_",20);
+define("_ARTICLE_NEW_",21);
+define("_DICT_LOOKUP_",30);
+define("_TERM_EDIT_",40);
+define("_TERM_LOOKUP_",50);
+define("_WBW_EDIT_",60);
+define("_SENT_EDIT_",70);
+define("_SENT_NEW_",71);
+define("_COLLECTION_EDIT_",80);
+define("_COLLECTION_NEW_",81);
+define("_FIND_IN_NISSAYA_",90);
+
 ?>

+ 1 - 0
app/reader/reader.js

@@ -126,6 +126,7 @@ function reader_draw_para_menu() {
 			html += "<a onclick=\"junp_to_para('" + _reader_book + "','" + strPara + "')\">仅显示此段</a>";
 		}
 		html += "<a onclick=\"edit_wbw('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.edit_now + "</a>";
+		html += "<a  onclick='goto_nissaya(" + _reader_book + "," + strPara + ")'>" + gLocal.gui.show_nissaya + "</a>";
 		html +=
 			"<a onclick=\"copy_para_ref('" + _reader_book + "','" + strPara + "')\">" + gLocal.gui.copy_link + "</a>";
 		html +=

File diff suppressed because it is too large
+ 525 - 535
app/studio/js/data.js


+ 13 - 47
app/studio/plugin/system_export/module_function.js

@@ -10,51 +10,17 @@
  */
 
 function export_copy_doc_sent_link() {
-  let sent_list = _user_sent_buffer.getSent();
-  let sent_link = "";
-  let para = -1;
-  for (const iterator of sent_list) {
-    if (iterator.para != para) {
-      if (para != -1) {
-        sent_link += "\n";
-      }
-      para = iterator.para;
-    }
-    sent_link +=
-      "{{" +
-      iterator.book +
-      "-" +
-      iterator.para +
-      "-" +
-      iterator.start +
-      "-" +
-      iterator.end +
-      "}}\n";
-  }
-  $("#doc_sent_export").val(sent_link);
-  /*
-  const block_list = doc_block();
-  for (const iterator of block_list) {
-    let xmlParInfo = iterator.getElementsByTagName("info")[0];
-    if (xmlParInfo) {
-      let type = getNodeText(xmlParInfo, "type");
-      if (type == "wbw") {
-        let book = getNodeText(xmlParInfo, "book");
-        let para = getNodeText(xmlParInfo, "paragraph");
-        let xmlParData = iterator.getElementsByTagName("data")[0];
-        if (xmlParData) {
-          let ibegin = -1;
-          let iEnd = -1;
-          let word_list = xmlParData.getElementsByTagName("word");
-          for (const xWord of word_list) {
-            const id = xWord.getNodeText(xWord, "id").split("-");
-            if (ibegin == -1) {
-              ibegin = id[3];
-            }
-          }
-        }
-      }
-    }
-  }
-  */
+	let sent_list = _user_sent_buffer.getSent();
+	let sent_link = "";
+	let para = -1;
+	for (const iterator of sent_list) {
+		if (iterator.para != para) {
+			if (para != -1) {
+				sent_link += "\n";
+			}
+			para = iterator.para;
+		}
+		sent_link += "{{" + iterator.book + "-" + iterator.para + "-" + iterator.start + "-" + iterator.end + "}}\n";
+	}
+	$("#doc_sent_export").val(sent_link);
 }

+ 13 - 3
app/term/note.js

@@ -442,7 +442,17 @@ function note_json_html(in_json) {
 		gLocal.gui.related_para +
 		"</a>";
 	output +=
-		"<a  onclick='goto_nissaya(" + in_json.book + "," + in_json.para + ")'>" + gLocal.gui.show_nissaya + "</a>";
+		"<a  onclick='goto_nissaya(" +
+		in_json.book +
+		"," +
+		in_json.para +
+		"," +
+		in_json.begin +
+		"," +
+		in_json.end +
+		")'>" +
+		gLocal.gui.show_nissaya +
+		"</a>";
 	output +=
 		"<a onclick=\"copy_ref('" +
 		in_json.book +
@@ -895,8 +905,8 @@ function copy_ref(book, para, begin, end) {
 	copy_to_clipboard(strRef);
 }
 
-function goto_nissaya(book, para) {
-	window.open("../nissaya/index.php?book=" + book + "&para=" + para, "nissaya");
+function goto_nissaya(book, para, begin = 0, end = 0) {
+	window.open("../nissaya/index.php?book=" + book + "&para=" + para + "&begin=" + begin + "&end=" + end, "nissaya");
 }
 function edit_in_studio(book, para, begin, end) {
 	wbw_channal_list_open(book, [para]);

+ 20 - 1
app/ucenter/active.php

@@ -2,8 +2,10 @@
 //统计用户经验值
 require_once '../path.php';
 require_once "../public/function.php";
+require_once "../public/php/define.php";
 
-function add_edit_event($type="",$data=null){
+
+function add_edit_event($type=0,$data=null){
 	date_default_timezone_set("UTC");
 	define("MAX_INTERVAL",600000);
 	define("MIN_INTERVAL",10000);
@@ -12,6 +14,8 @@ function add_edit_event($type="",$data=null){
 		$dns = "sqlite:"._FILE_DB_USER_ACTIVE_;
 		$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 		$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+		
 		// 查询上次编辑活跃结束时间
 		$query = "SELECT id, end, start,hit  FROM edit WHERE user_id = ? order by end DESC";
 		$stmt = $dbh->prepare($query);
@@ -105,6 +109,21 @@ function add_edit_event($type="",$data=null){
 		}
 		#更新经验总量表结束
 
+		#更新log
+		if($type > 0){
+			$dns = "sqlite:"._FILE_DB_USER_ACTIVE_LOG_;
+			$dbh_log = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+			$dbh_log->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+			$query="INSERT INTO log ( user_id, active , content , time,timezone )  VALUES  ( ? , ? , ? , ? ,? ) ";
+			$sth = $dbh_log->prepare($query);
+			$sth->execute(array($_COOKIE["uid"] , $type , $data, $currTime,$client_timezone ) );
+			if (!$sth || ($sth && $sth->errorCode() != 0)) {
+				$error = $dbh->errorInfo();
+			}			
+		}
+
+		#更新log结束
 	}
 }
 

+ 2 - 2
app/usent/sent_post.php

@@ -73,14 +73,14 @@ PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
 
 $_id = false;
 if( (isset($_POST["id"]) && empty($_POST["id"])) || !isset($_POST["id"]) ){
-    add_edit_event("sent",array("book"=>$_POST["book"],"para"=>$_POST["para"]));
+    add_edit_event(_SENT_EDIT_,"{$_POST["book"]}-{$_POST["para"]}-{$_POST["begin"]}-{$_POST["end"]}@{$_POST["channal"]}");
         # 判断是否已经有了
         $query = "SELECT id FROM sentence WHERE book = ? AND paragraph = ? AND begin = ? AND end = ? AND channal = ? ";
         $_id = PDO_FetchOne($query,array($_POST["book"], $_POST["para"],  $_POST["begin"], $_POST["end"], $_POST["channal"]));
 }
 else{
     $_id = $_POST["id"];
-    add_edit_event("sent",array("id"=>$_POST["id"]));
+    add_edit_event(_SENT_EDIT_,$_POST["id"]);
 }
 
 

+ 42 - 38
app/usent/update.php

@@ -23,7 +23,7 @@ else{
     $_landmark = "";
 }
 
-add_edit_event("sent",array("book"=>0,"para"=>0));
+
 
 $aData=json_decode($_POST["data"],TRUE);
 
@@ -57,57 +57,61 @@ foreach ($aData as $data) {
 $update_list = array(); //已经成功修改数据库的数据 回传客户端
 
 /* 修改现有数据 */
-$PDO->beginTransaction();
-$query="UPDATE sentence SET text= ?  , status = ? , strlen = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
-$sth = $PDO->prepare($query);
+if(count($oldList)>0){
+	add_edit_event(_SENT_EDIT_,"{$oldList[0]["id"]}");	
 
+	$PDO->beginTransaction();
+	$query="UPDATE sentence SET text= ?  , status = ? , strlen = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
+	$sth = $PDO->prepare($query);
 
-foreach ($oldList as $data) {
-	if(isset($data["id"])){
-		if(isset($data["time"])){
-			$modify_time = $data["time"];
-		}
-		else{
-			$modify_time = mTime();
-		}
-		$sth->execute(array($data["text"], $data["status"], mb_strlen($data["text"],"UTF-8"), mTime(),$modify_time,$data["id"]));
-	} 
-}
 
-$PDO->commit();
+	foreach ($oldList as $data) {
+		if(isset($data["id"])){
+			if(isset($data["time"])){
+				$modify_time = $data["time"];
+			}
+			else{
+				$modify_time = mTime();
+			}
+			$sth->execute(array($data["text"], $data["status"], mb_strlen($data["text"],"UTF-8"), mTime(),$modify_time,$data["id"]));
+		} 
+	}
 
-$respond=array("status"=>0,"message"=>"","insert_error"=>"","new_list"=>array());
+	$PDO->commit();
 
-if (!$sth || ($sth && $sth->errorCode() != 0)) {
-	/*  识别错误且回滚更改  */
-	$PDO->rollBack();
-	$error = PDO_ErrorInfo();
-	$respond['status']=1;
-	$respond['message']=$error[2];
-}
-else{
-	#没错误 更新历史记录
-	foreach ($oldList as $data) {
-		$respond['message']=update_historay($data["id"],$_COOKIE["userid"] ,$data["text"],$_landmark);
-		if($respond['message']!==""){
-			$respond['status']=1;
-			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
-			exit;
-		}
+	$respond=array("status"=>0,"message"=>"","insert_error"=>"","new_list"=>array());
+
+	if (!$sth || ($sth && $sth->errorCode() != 0)) {
+		/*  识别错误且回滚更改  */
+		$PDO->rollBack();
+		$error = PDO_ErrorInfo();
+		$respond['status']=1;
+		$respond['message']=$error[2];
 	}
-	$respond['status']=0;
-	$respond['message']="成功";
-	foreach ($oldList as $key => $value) {
-		$update_list[] =  array("id" => $value["id"],"book"=>$value["book"],"paragraph"=>$value["paragraph"],"begin"=>$value["begin"],"end"=>$value["end"],"channal"=>$value["channal"],"text" => $value["text"]);
+	else{
+		#没错误 添加log 更新历史记录 
+		foreach ($oldList as $data) {
+			$respond['message']=update_historay($data["id"],$_COOKIE["userid"] ,$data["text"],$_landmark);
+			if($respond['message']!==""){
+				$respond['status']=1;
+				echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+				exit;
+			}
+		}
+		$respond['status']=0;
+		$respond['message']="成功";
+		foreach ($oldList as $key => $value) {
+			$update_list[] =  array("id" => $value["id"],"book"=>$value["book"],"paragraph"=>$value["paragraph"],"begin"=>$value["begin"],"end"=>$value["end"],"channal"=>$value["channal"],"text" => $value["text"]);
 
+		}
 	}
 }
 
-
 /* 插入新数据 */
 //查询channel语言
 
 if(count($newList)>0){
+	add_edit_event(_SENT_NEW_,"{$newList[0]["book"]}-{$newList[0]["paragraph"]}-{$newList[0]["begin"]}-{$newList[0]["end"]}");	
 	$PDO->beginTransaction();
 	$query = "INSERT INTO sentence (id, 
 									parent,

+ 46 - 49
app/uwbw/update.js

@@ -1,80 +1,77 @@
-var user_wbw_data_buffer=new Array();
+var user_wbw_data_buffer = new Array();
 
-function user_wbw_push_paragraph(blockid){
-	
-}
+function user_wbw_push_paragraph(blockid) {}
 
-function user_wbw_push_word_element(xWord){
-	let wordid=getNodeText(xWord,"id");
+function user_wbw_push_word_element(xWord) {
+	let wordid = getNodeText(xWord, "id");
 	let wId = wordid.split("-")[2];
-	let mWord = doc_word("#"+wordid);
-	let blockid=mWord.block.info("id");
-	user_wbw_push(blockid,wId,com_xmlToString(xWord));	
+	let mWord = doc_word("#" + wordid);
+	let blockid = mWord.block.info("id");
+	user_wbw_push(blockid, wId, com_xmlToString(xWord));
 }
 
-function user_wbw_push_word(wordid){
-	let xWord = doc_word("#"+wordid);
-	let blockid=xWord.block.info("id");	
-	let book=xWord.block.info("book");
-	let para = 	xWord.block.info("paragraph");
+function user_wbw_push_word(wordid) {
+	let xWord = doc_word("#" + wordid);
+	let blockid = xWord.block.info("id");
+	let book = xWord.block.info("book");
+	let para = xWord.block.info("paragraph");
 
 	let aWordid = wordid.split("-");
-	aWordid.length=3;
-	if(para!=aWordid[1]){
+	aWordid.length = 3;
+	if (para != aWordid[1]) {
 		alert("error:paragraph sn.");
 		return;
 	}
-	let newWordid=aWordid.join("-");
+	let newWordid = aWordid.join("-");
 	let wId = aWordid[2];
-	let xAllWord = gXmlBookDataBody.getElementsByTagName("word");	
-	let index=getWordIndex(newWordid);
+	let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
+	let index = getWordIndex(newWordid);
 	let wordData = "";
-	if(xAllWord[index]){
-		for(let i=index;i<xAllWord.length;i++){
-			if(getNodeText(xAllWord[i],"id").split("-")[2]!=wId){
+	if (xAllWord[index]) {
+		for (let i = index; i < xAllWord.length; i++) {
+			if (getNodeText(xAllWord[i], "id").split("-")[2] != wId) {
 				break;
 			}
 			wordData += com_xmlToString(xAllWord[i]);
-			
 		}
-		user_wbw_push(blockid,wId,wordData);
+		user_wbw_push(blockid, wId, wordData);
 	}
-
 }
 
-function user_wbw_push(block_id,wid,data){
+function user_wbw_push(block_id, wid, data) {
 	let d = new Date();
 	let objData = new Object();
-	objData.block_id=block_id;
+	objData.block_id = block_id;
 	objData.word_id = wid;
 	objData.data = data;
 	objData.time = d.getTime();
+	objData.book = doc_block("#" + block_id).info("book");
+	objData.para = doc_block("#" + block_id).info("paragraph");
 	user_wbw_data_buffer.push(objData);
 }
 
-function user_wbw_commit(){
-
-	if(user_wbw_data_buffer.length==0){
+function user_wbw_commit() {
+	if (user_wbw_data_buffer.length == 0) {
 		return;
 	}
-	$.post("../uwbw/update.php",
-	{
-		data:JSON.stringify(user_wbw_data_buffer)
-	},
-	function(data,status){
-		try{
-			let result= JSON.parse(data);
-			if(result.status==0){
-				ntf_show("user wbw"+result.message);
+	$.post(
+		"../uwbw/update.php",
+		{
+			data: JSON.stringify(user_wbw_data_buffer),
+		},
+		function (data, status) {
+			try {
+				let result = JSON.parse(data);
+				if (result.status == 0) {
+					ntf_show("user wbw" + result.message);
+				} else {
+					ntf_show("user wbw error" + result.message);
+				}
+			} catch (e) {
+				console.error("user_wbw_update:" + e + " data:" + data);
+				ntf_show("user wbw");
 			}
-			else{
-				ntf_show("user wbw error"+result.message);
-			}
-		}
-		catch(e){
-			console.error("user_wbw_update:"+e+" data:"+data);
-			ntf_show("user wbw");
 		}
-	});
-	user_wbw_data_buffer=new Array();
-}
+	);
+	user_wbw_data_buffer = new Array();
+}

+ 39 - 22
app/uwbw/update.php

@@ -7,36 +7,53 @@ require_once "../public/_pdo.php";
 require_once "../public/function.php";
 require_once "../ucenter/active.php";
 
+$respond['status']=0;
+$respond['message']="";
 
-$aData=json_decode($_POST["data"]);
+if(isset($_POST["data"])){
+	$aData=json_decode($_POST["data"]);
+}
+else{
+	$respond['status']=1;
+	$respond['message']="no data";
+	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+	exit;
+}
 
-add_edit_event("wbw",array("book"=>0,"para"=>0));
+if(count($aData)>0){
+	add_edit_event(_WBW_EDIT_,"{$aData[0]->book}-{$aData[0]->para}-{$aData[0]->word_id}");
 
-PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+	PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
 
-/* 开始一个事务,关闭自动提交 */
-$PDO->beginTransaction();
-$query="UPDATE wbw SET data= ?  , receive_time= ?  , modify_time= ?   where block_id= ?  and wid= ?  ";
-$sth = $PDO->prepare($query);
+	/* 开始一个事务,关闭自动提交 */
+	$PDO->beginTransaction();
+	$query="UPDATE wbw SET data= ?  , receive_time= ?  , modify_time= ?   where block_id= ?  and wid= ?  ";
+	$sth = $PDO->prepare($query);
 
-foreach ($aData as $data) {
-    $sth->execute(array($data->data,mTime(),$data->time,$data->block_id,$data->word_id));
-}
-$PDO->commit();
+	foreach ($aData as $data) {
+		$sth->execute(array($data->data,mTime(),$data->time,$data->block_id,$data->word_id));
+	}
+	$PDO->commit();
 
-$respond=array("status"=>0,"message"=>"");
+	$respond=array("status"=>0,"message"=>"");
 
-if (!$sth || ($sth && $sth->errorCode() != 0)) {
-	/*  识别错误且回滚更改  */
-	$PDO->rollBack();
-	$error = PDO_ErrorInfo();
-	$respond['status']=1;
-	$respond['message']=$error[2];
+	if (!$sth || ($sth && $sth->errorCode() != 0)) {
+		/*  识别错误且回滚更改  */
+		$PDO->rollBack();
+		$error = PDO_ErrorInfo();
+		$respond['status']=1;
+		$respond['message']=$error[2];
 
+	}
+	else{
+		$respond['status']=0;
+		$respond['message']="成功";
+	}		
+	echo json_encode($respond, JSON_UNESCAPED_UNICODE);	
 }
 else{
-	$respond['status']=0;
-	$respond['message']="成功";
-}		
-echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+	$respond['status']=1;
+	$respond['message']="no data";
+	echo json_encode($respond, JSON_UNESCAPED_UNICODE);	
+}
 ?>

Some files were not shown because too many files changed in this diff