Selaa lähdekoodia

经验值统计改为函数调用

visuddhinanda 5 vuotta sitten
vanhempi
sitoutus
284cdc50d3

+ 1 - 0
app/article/my_article_post.php

@@ -4,6 +4,7 @@ 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"));
 
 $respond=array("status"=>0,"message"=>"");
 

+ 3 - 1
app/article/my_article_put.php

@@ -10,7 +10,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);
-$sth->execute(array(UUID::v4() , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 1 , mTime() ,  mTime() , mTime() ));
+$uuid = UUID::v4();
+add_edit_event("article",array("id"=>$uuid,"action"=>"insert"));
+$sth->execute(array($uuid , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 1 , mTime() ,  mTime() , mTime() ));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();

+ 2 - 0
app/article/my_collect_post.php

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

+ 3 - 1
app/article/my_collect_put.php

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

+ 1 - 0
app/dict/dict_lookup.php

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

+ 48 - 45
app/ucenter/active.php

@@ -3,56 +3,59 @@
 require_once '../path.php';
 require_once "../public/function.php";
 
-define("MAX_INTERVAL",600000);
-define("MIN_INTERVAL",10000);
-
-if(isset($_COOKIE["userid"])){
-	$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);
-	$stmt->execute(array($_COOKIE["userid"]));
-	$row = $stmt->fetch(PDO::FETCH_ASSOC);
-	$new_record = false;
-	$currTime = mTime();
-    if ($row) {
-		//找到,判断是否超时,超时新建,未超时修改
-		$endtime = (int)$row["end"];
-		$id = (int)$row["id"];
-		$start_time = (int)$row["start"];
-		$hit = (int)$row["hit"];
-		if($currTime-$endtime>MAX_INTERVAL){
-			//超时新建
+function add_edit_event($type="",$data=null){
+	define("MAX_INTERVAL",600000);
+	define("MIN_INTERVAL",10000);
+	
+	if(isset($_COOKIE["userid"])){
+		$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);
+		$stmt->execute(array($_COOKIE["userid"]));
+		$row = $stmt->fetch(PDO::FETCH_ASSOC);
+		$new_record = false;
+		$currTime = mTime();
+		if ($row) {
+			//找到,判断是否超时,超时新建,未超时修改
+			$endtime = (int)$row["end"];
+			$id = (int)$row["id"];
+			$start_time = (int)$row["start"];
+			$hit = (int)$row["hit"];
+			if($currTime-$endtime>MAX_INTERVAL){
+				//超时新建
+				$new_record = true;
+			}
+			else{
+				//未超时修改
+				$new_record = false;
+			}
+		} else {
+			//没找到,新建
 			$new_record = true;
 		}
-		else{
-			//未超时修改
-			$new_record = false;
-		}
-    } else {
-		//没找到,新建
-        $new_record = true;
-	}
-
-	if($new_record){
-		$query="INSERT INTO edit ( user_id, start , end  , duration , hit )  VALUES  ( ? , ? , ? , ? , ? ) ";
-		$sth = $dbh->prepare($query);
-		$sth->execute(array($_COOKIE["userid"] , $currTime , ($currTime+MIN_INTERVAL) , MIN_INTERVAL,1) );
-		if (!$sth || ($sth && $sth->errorCode() != 0)) {
-			$error = $dbh->errorInfo();
+	
+		if($new_record){
+			$query="INSERT INTO edit ( user_id, start , end  , duration , hit )  VALUES  ( ? , ? , ? , ? , ? ) ";
+			$sth = $dbh->prepare($query);
+			$sth->execute(array($_COOKIE["userid"] , $currTime , ($currTime+MIN_INTERVAL) , MIN_INTERVAL,1) );
+			if (!$sth || ($sth && $sth->errorCode() != 0)) {
+				$error = $dbh->errorInfo();
+			}
 		}
-	}
-	else{
-
-		$query="UPDATE edit SET end = ? , duration = ? , hit = ? WHERE id = ? ";
-		$sth = $dbh->prepare($query);
-		$sth->execute( array($currTime,($currTime-$start_time), ($hit+1),$id));
-		if (!$sth || ($sth && $sth->errorCode() != 0)) {
-			$error = $dbh->errorInfo();
+		else{
+	
+			$query="UPDATE edit SET end = ? , duration = ? , hit = ? WHERE id = ? ";
+			$sth = $dbh->prepare($query);
+			$sth->execute( array($currTime,($currTime-$start_time), ($hit+1),$id));
+			if (!$sth || ($sth && $sth->errorCode() != 0)) {
+				$error = $dbh->errorInfo();
+			}
 		}
 	}
 }
 
+
 ?>

+ 0 - 3
app/uhome/foot_step_data.php

@@ -46,9 +46,6 @@ if (isset($_GET['timeZone'])) {
 }
 
 // Read and parse our events JSON file into an array of event data arrays.
-//$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
-//$input_arrays = json_decode($json, true);
-//使用cookie传递老师id
 $dns = "sqlite:"._FILE_DB_USER_ACTIVE_;
 $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  

+ 3 - 0
app/usent/sent_post.php

@@ -66,16 +66,19 @@ else{
 }
 
 
+
 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"]));
         # 判断是否已经有了
         $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"]));
 }
 
 

+ 2 - 0
app/usent/update.php

@@ -22,6 +22,8 @@ else{
     $_landmark = "";
 }
 
+add_edit_event("sent",array("book"=>0,"para"=>0));
+
 $aData=json_decode($_POST["data"],TRUE);
 
 PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);

+ 2 - 0
app/uwbw/update.php

@@ -10,6 +10,8 @@ require_once "../ucenter/active.php";
 
 $aData=json_decode($_POST["data"]);
 
+add_edit_event("wbw",array("book"=>0,"para"=>0));
+
 PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
 
 /* 开始一个事务,关闭自动提交 */