Browse Source

log列表显示行为字符串

visuddhinanda 5 years ago
parent
commit
1e86aa7fc9
4 changed files with 72 additions and 4 deletions
  1. 1 1
      app/nissaya/get.php
  2. 3 2
      app/public/php/define.php
  3. 1 1
      app/ucenter/active.php
  4. 67 0
      app/ucenter/active_list.php

+ 1 - 1
app/nissaya/get.php

@@ -35,7 +35,7 @@ if(isset($_GET["end"])){
 else{
 	$end = 0;
 }
-add_edit_event(_FIND_IN_NISSAYA_,"{$book}-{$para}-{$begin}-{$end}");
+add_edit_event(_NISSAYA_FIND_,"{$book}-{$para}-{$begin}-{$end}");
 
 PDO_Connect("sqlite:"._FILE_DB_PAGE_INDEX_);
 $query = "SELECT * from m where book=? and para=?";

+ 3 - 2
app/public/php/define.php

@@ -13,12 +13,13 @@ define("_ARTICLE_EDIT_",20);
 define("_ARTICLE_NEW_",21);
 define("_DICT_LOOKUP_",30);
 define("_TERM_EDIT_",40);
-define("_TERM_LOOKUP_",50);
+define("_TERM_LOOKUP_",41);
 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);
+define("_NISSAYA_FIND_",90);
+
 
 ?>

+ 1 - 1
app/ucenter/active.php

@@ -115,7 +115,7 @@ function add_edit_event($type=0,$data=null){
 			$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  ( ? , ? , ? , ? ,? ) ";
+			$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)) {

+ 67 - 0
app/ucenter/active_list.php

@@ -0,0 +1,67 @@
+<html>
+<body>
+<?php 
+//显示log
+require_once '../path.php';
+require_once "../public/function.php";
+require_once "../public/php/define.php";
+
+if(isset($_COOKIE["uid"])){
+	$active_type[10] = "_CHANNEL_EDIT_";
+	$active_type[11] = "_CHANNEL_NEW_";
+	$active_type[20] = "_ARTICLE_EDIT_";
+	$active_type[21] = "_ARTICLE_NEW_";
+	$active_type[30] = "_DICT_LOOKUP_";
+	$active_type[40] = "_TERM_EDIT_";
+	$active_type[41] = "_TERM_LOOKUP_";
+	$active_type[60] = "_WBW_EDIT_";
+	$active_type[70] = "_SENT_EDIT_";
+	$active_type[71] = "_SENT_NEW_";
+	$active_type[80] = "_COLLECTION_EDIT_";
+	$active_type[81] = "_COLLECTION_NEW_";
+	$active_type[90] = "_NISSAYA_FIND_";
+
+	$dns = "sqlite:"._FILE_DB_USER_ACTIVE_LOG_;
+	$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+	$query = "SELECT time,active,content,timezone  FROM log WHERE user_id = ? ";
+		$stmt = $dbh->prepare($query);
+		$stmt->execute(array($_COOKIE["uid"]));
+		echo "<table>";
+		
+		while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
+			echo "<tr>";	
+			foreach ($row as $key => $value) {
+				# code...
+				
+				switch ($key) {
+					case 'active':
+						# code...
+						$output =  isset($active_type[$value])? $active_type[$value] : $value;
+						break;
+					case 'time':
+						# code...
+						$output =  gmdate("Y-m-d H:i:s",($value+$row["timezone"])/1000);
+						break;
+					case 'timezone':
+						# code...
+						$output = round($value/1000/60/60,2) ;
+						break;
+					default:
+						# code...
+						$output =  $value;
+						break;
+				}
+				echo "<td>$output</td>";
+			}
+			echo "</tr>";
+		}
+		
+		echo "</table>";
+}
+else{
+	echo "尚未登录";
+}
+?>
+</body>
+</html>