Sfoglia il codice sorgente

Merge branch 'master' of https://github.com/visuddhinanda/mint

Bhikkhu-Kosalla 5 anni fa
parent
commit
99d532847a

+ 55 - 0
app/admin/update_user_active_time.php

@@ -0,0 +1,55 @@
+<?php
+require_once '../path.php';
+
+date_default_timezone_set("UTC");
+$logfile = "update_user_active_time_last.txt";
+$last = file_get_contents($logfile);
+$start = strtotime($last." +1 day");
+$end = strtotime($last." +2 day");
+$today = strtotime("today");
+
+$dns = "sqlite:"._FILE_DB_USER_ACTIVE_;
+$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+
+$dns = "sqlite:"._FILE_DB_USER_ACTIVE_INDEX_;
+$dbh_index = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+/* 开始一个事务,关闭自动提交 */
+$dbh_index->beginTransaction();
+$query = "INSERT INTO active_index (user_id, date , duration , hit) VALUES (?, ?, ? , ?)";
+$sth_index = $dbh_index->prepare($query);
+
+$runing=$last;
+while ($end <= $today) {
+	$runing=gmdate("Y-m-d",$start);
+	echo "runing:".$runing."\n";
+
+	# do one day
+	$query = "SELECT user_id, sum(duration) as time , sum(hit) as hit  FROM edit WHERE end between ? and ?  group by user_id ";
+	$stmt = $dbh->prepare($query);
+	$stmt->execute(array($start*1000,$end*1000));
+	while($result = $stmt->fetch(PDO::FETCH_ASSOC))
+	{
+		$user_id = $result["user_id"];
+		$time = $result["time"];
+		$hit = $result["hit"];
+		$sth_index->execute(array($user_id,$start*1000,$time,$hit));
+		echo "$user_id - $time - $hit \n";
+	}
+	$start = $end;
+	$end = strtotime( gmdate("Y-m-d",$end)." +1 day");
+}
+$dbh_index->commit();
+if (!$sth_index || ($sth_index && $sth_index->errorCode() != 0)) {
+	/*  识别错误且回滚更改  */
+	$sth_index->rollBack();
+	$error = $dbh_index->errorInfo();
+	echo "error:".$error[2]."\n";
+}
+
+echo "run until:".$runing."\n";
+echo file_put_contents($logfile,$runing);
+
+?>

+ 1 - 0
app/admin/update_user_active_time_last.txt

@@ -0,0 +1 @@
+2021-02-02

+ 0 - 1
app/collect/index.php

@@ -89,7 +89,6 @@ include "../pcdl/html_head.php";
         .collect_card {
             display: block;
             padding: 1rem 1.5rem;
-            box-shadow: 0 3px 6px rgb(0 0 0 / 16%);
         }
 
         .collect_title {

+ 27 - 9
app/course/course.php

@@ -13,6 +13,20 @@ include "../pcdl/html_head.php";
         width:100%;
         height:100%;
     }
+
+    #course_frame{
+        display:flex;
+    }
+    #course_content{
+        flex:5;
+        margin:1em;
+        padding:10px;
+    }
+    #lesson_list{
+        flex:5;
+        height: calc(100%-100px);
+        overflow-y: scroll;
+    }
 </style>
     
 
@@ -34,10 +48,12 @@ if(count($Fetch)==0)
     exit;
 }
 $course_info = $Fetch[0];
+?>
 
-echo "<div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>";
-echo "<div class='index_inner '>";
-echo "<div style='font-size:140%'>";
+<div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>
+<div class='index_inner '>
+<div style='font-size:140%'>
+<?php
 echo "<a href='../uhome/course.php?userid={$course_info["teacher"]}'>";
 echo ucenter_getA($course_info["teacher"]);
 echo "</a>";
@@ -51,9 +67,11 @@ echo '<button>'.$_local->gui->sign_up.'</button>';
 echo '<button>'.$_local->gui->share.'</button></div>';
 echo "</div>";
 echo '</div>';
-echo "<div  class='index_inner'>";
 
-echo '<div class="card" style="margin:1em;padding:10px;">';
+
+echo "<div id='course_frame' class='index_inner'>";
+
+echo '<div id="course_content" style="">';
     echo '<div class="title">';
     echo $_local->gui->introduction;
     echo '</div>';
@@ -65,14 +83,14 @@ echo '<div class="card" style="margin:1em;padding:10px;">';
     echo '<div id="course_attachment"  class="detail">';
     echo '</div>';   
 echo '</div>';
-
-echo "<div id='lesson_list'>";
+?>
+<div id='lesson_list'>
 
 
-echo "</div>";
+</div>
 
-?>
 </div>
+
 <script>
     $("#main_video_win").height($("#main_video_win").width()*9/16);
     $.get("../course/course_get.php",

+ 15 - 6
app/course/course_list.php

@@ -5,6 +5,8 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/load_lang.php';
 require_once '../media/function.php';
+require_once '../ucenter/function.php';
+
 
 /*
 状态
@@ -15,18 +17,25 @@ require_once '../media/function.php';
 30 公开连载
 40 已完结
 */
+global $PDO;
+PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+
 if(isset($_GET["teacher"])){
-    $teacher = " teacher = '".$_GET["teacher"]."'";
+    $query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
+    $Fetch = PDO_FetchAll($query,array($_GET["teacher"]));    
 }
 else{
-    $teacher = " 1= 1";
+    $query = "select * from course where 1  order by create_time DESC limit 0,100";
+    $Fetch = PDO_FetchAll($query);
 }
+$userinfo = new UserInfo();
 
-global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+foreach ($Fetch as $key => $value) {
+    # code...
+    $user = $userinfo->getName($value["teacher"]);
+    $Fetch[$key]["teacher_info"] = $user;
+}
 
-$query = "select * from course where $teacher  order by create_time DESC limit 0,100";
-$Fetch = PDO_FetchAll($query);
 echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 
 ?>

BIN
app/course/img/default.jpg


+ 267 - 117
app/course/index.php

@@ -1,136 +1,286 @@
 <?PHP
 include "../pcdl/html_head.php";
 ?>
+
 <body>
 
-<?php
-    require_once("../pcdl/head_bar.php");
-?>
-<style>
-	.content_block{
-		flex: 0 0 auto;
-		width: 25%;
-		padding: 10px;
-	}
-
-	.index_inner{
-		width: 960px;
-		margin-left: auto;
-		margin-right: auto;
-	}
-	.content_inner{
-		display:flex;
-	}
-	.h3{
-		font-size: 16px;
-	}
-	.index_list_categories{
-		margin: 2em 0;
-	}
-	
-	.index_list_categories a:hover{
-		color: var(--tool-link-hover-color);
-	}
-	/*.index_list_categories a,a:link{
+	<?php
+	require_once("../pcdl/head_bar.php");
+	?>
+	<style>
+		.content_block {
+			width: 230px;
+		}
+
+		.index_inner {
+			margin-left: auto;
+			margin-right: auto;
+		}
+
+		.content_inner {
+			display: grid;
+			justify-content: center;
+			grid-gap: 20px;
+		}
+
+		.collect_head_bar {
+			background-color: #212121;
+			height: 280px;
+			padding: 30px;
+			color: white;
+		}
+
+		.section_inner {
+			max-width: 960px;
+			margin: 0 auto;
+		}
+
+		.title_bar {
+			justify-content: space-between;
+			display: flex;
+			margin: 1em 0;
+			align-items: center;
+		}
+
+		h1 {
+			font-size: 42px;
+			font-weight: 700;
+			margin: 0.3em 0;
+		}
+
+		h3 {
+			font-size: 18px;
+			margin: 0;
+		}
+
+		.index_list_categories {
+			padding: 1rem;
+			margin-bottom: 2rem;
+		}
+
+		.index_list_categories a:hover {
+			color: var(--tool-link-hover-color);
+		}
+
+		/*.index_list_categories a,a:link{
 		color: var(--main-color);
 	}*/
-	.index_list_categories button{
-		border: none;
-	}
-	
-	.pd-10{
-		padding:10px;
-	}
-	.card li{
-		white-space: unset;
-	}
-	.card code{
-		white-space: unset;
-	}
+		.index_list_categories button {
+			border: none;
+		}
+
+		.card li {
+			white-space: unset;
+		}
+
+		.card code {
+			white-space: unset;
+		}
+
+		.teacher_photo {
+			width: 230px;
+			height: 178px;
+			background-color: gray;
+			border-radius: 8px;
+		}
+
+		.teacher_text {
+			padding: 0 5px;
+		}
+
+		.teacher_text .title {
+			font-size: 120%;
+			font-weight: 700;
+			margin: 0.5em 0;
+		}
+
+		.teacher_intro {
+			display: -webkit-box;
+			-webkit-box-orient: vertical;
+			overflow: hidden;
+			text-overflow: ellipsis;
+			width: 100%;
+			-webkit-line-clamp: 3;
+		}
+
+		#course_list_complete .card,
+		#course_list_ongoing .card {
+			height: 120px;
+			padding: 0;
+			display: grid;
+			grid-template-columns: 120px 1fr;
+		}
+
+		.course_block {
+			background-color: #f5f5f5;
+			padding: 1rem;
+		}
+
+		.course_right {
+			padding: 10px;
+			display: flex;
+			flex-direction: column;
+			width: calc(100% - 10px);
+		}
+
+		.card_photo {
+			object-fit: cover;
+			border-radius: 20px 0 0 20px;
+		}
+
+		.course_right .title a {
+			font-size: 120%;
+			font-weight: 700;
+			display: -webkit-box;
+			-webkit-box-orient: vertical;
+			overflow: hidden;
+			text-overflow: ellipsis;
+			-webkit-line-clamp: 2;
+			color: var(--main-color);
+		}
+
+		.subtitle {
+			margin-top: auto;
+			display: -webkit-box;
+			-webkit-box-orient: vertical;
+			overflow: hidden;
+			text-overflow: ellipsis;
+			width: 100%;
+			-webkit-line-clamp: 2;
+		}
+
+		@media screen and (min-width:800px) {
+			.index_list_categories {
+				max-width: 760px;
+				margin: 0 auto 3rem auto;
+			}
+
+			.content_inner {
+				grid-template-columns: 230px 230px 230px;
+			}
+
+			h3 {
+				font-size: 22px;
+
+			}
+
+			.course_block h3 {
+				text-align: center;
+				margin: 1em 0;
+			}
+
+			#course_list_ongoing,
+			#course_list_complete {
+				max-width: 600px;
+				margin: 0 auto;
+			}
+		}
+
+		@media screen and (min-width:1020px) {
+			.index_list_categories {
+				max-width: 1020px;
+			}
+
+			.content_inner {
+				grid-template-columns: 230px 230px 230px 230px;
+			}
+		}
 	</style>
-<div class="index_inner" >
-    
-	<div class="index_list_categories">
-		<div class="title_bar">
-			<span class="title h3"><?php echo $_local->gui->speaker ?></span>	
-			<span class="title_more"><a href="../course"><?php echo $_local->gui->more ?></a></span>
+
+
+	<div class="index_inner">
+		<div id="course_head_bar" class="collect_head_bar">
+			<div class="section_inner">
+				<h1>課程</h1>
+				<div style="max-width:30em">來自世界個地的巴利專家詳細解析聖典</div>
+			</div>
 		</div>
-		<div class="content">
-			<div id="course_list_new" class="content_inner">
+		<div class="index_list_categories">
+			<div class="title_bar">
+				<h3><?php echo $_local->gui->speaker ?></h3>
+				<span class="title_more"><a href="../course"><?php echo $_local->gui->more ?></a></span>
+			</div>
+			<div class="content">
+				<div id="course_list_new" class="content_inner">
 
 
 
+				</div>
 			</div>
 		</div>
-	</div>
-	<script>
-	$.get("../course/teacher_list.php",function(data,status){
-		let xDiv = document.getElementById("course_list_new");
-		if(xDiv){
-			xDiv.innerHTML=data;
-		}
-	});
-	</script>
-	<div class="course_block">	
-		<div class="title" >
-		<?php echo $_local->gui->in_progress; ?>
+		<script>
+			$.get("../course/teacher_list.php", function(data, status) {
+				let xDiv = document.getElementById("course_list_new");
+				if (xDiv) {
+					xDiv.innerHTML = data;
+				}
+			});
+		</script>
+		<div class="course_block">
+			<h3>
+				<?php echo $_local->gui->in_progress; ?>
+			</h3>
+			<div id="course_list_ongoing">
+			</div>
 		</div>
-		<div id="course_list_ongoing">
-		</div >
-	</div>	
 
-	<div class="course_block">	
-		<div class="title" >
-		<?php echo $_local->gui->already_over; ?>
+		<div class="course_block">
+			<h3>
+				<?php echo $_local->gui->already_over; ?>
+			</h3>
+			<div id="course_list_complete">
+			</div>
 		</div>
-		<div id="course_list_complete">
-		</div >
+
+		<script>
+			var speaker = "<?php echo $_local->gui->speaker . ':' . $row['teacher'] ?>";
+
+			$.get("../course/course_list.php", function(data, status) {
+				let arrData = JSON.parse(data);
+				let html_complete = "";
+				let html_ongoing = "";
+
+				for (const iterator of arrData) {
+					let html = "";
+					html += '<div class="card">';
+					html += '<div style="height:120px;width:120px;">';
+					html += '<img src="../../tmp/images/course/' + iterator.id + '.jpg" alt="cover" width="120" height="120"  class="card_photo">';
+					html += '</div>';
+					html += '<div class="course_right">';
+					html += '<div class="title"><a href="../course/course.php?id=' + iterator.id + '">' + iterator.title + '</a></div>';
+
+					//教师名字
+					html += '<div class="author">'+gLocal.gui.speaker+':';
+					html += "<a href='../uhome/course.php?userid="+iterator.teacher+"'>"
+					html += iterator.teacher_info.nickname;
+					html += "</a>";
+					html += '</div>';
+
+					html += '<div class="subtitle">' + iterator.subtitle + '</div>';
+
+					/*let summary = "";
+					try {
+						summary = marked(iterator.summary);
+					} catch (e) {}
+					html += '<div class="summary">' + summary + '</div>';*/
+					html += '</div>';
+					html += '</div>';
+					if (iterator.status == 40) {
+						html_complete += html;
+					} else if (iterator.status == 30 || iterator.status == 20) {
+						html_ongoing += html;
+					}
+				}
+				$("#course_list_complete").html(html_complete);
+				$("#course_list_ongoing").html(html_ongoing);
+				$("img").one("error", function() {
+					$(this).attr("src", "../course/img/default.jpg");
+				});
+			});
+		</script>
+
 	</div>
 
-    <script>
-
-	$.get("../course/course_list.php",function(data,status){
-        let arrData = JSON.parse(data);
-        let html_complete="";
-        let html_ongoing="";
-		
-        for (const iterator of arrData) {
-			let html="";
-			html += '<div class="card" style="display:flex;margin:1em;padding:10px;">';
-			html += '<div style="flex:3;max-width:15em;">';
-			html += '<img src="../../tmp/images/course/'+iterator.id+'.jpg" alt="cover" width="200" height="200">'
-            html += '</div>';
-            html += '<div style="flex:7;padding:5px;">';
-            html +=  '<div class="title" style="padding-bottom:5px;font-size:110%;font-weight:600;"><a href="../course/course.php?id='+iterator.id+'">'+iterator.title+'</a></div>';
-			html += '<div class="summary"  style="padding-bottom:5px;">'+iterator.subtitle+'</div>';
-			let summary = "";
-			try{
-				summary = marked(iterator.summary);
-			}
-			catch(e){
-			}
-            html += '<div class="summary"  style="padding-bottom:5px;">'+summary+'</div>';
-            html += '</div>';
-            html += '<div style="flex:3;max-width:15em;">';
-            html += '</div>';
-            html += '</div>';
-			if(iterator.status==40){
-				html_complete += html;
-			}
-			else if(iterator.status==30 || iterator.status==20 ){
-				html_ongoing += html;
-			}
-        }
-		$("#course_list_complete").html(html_complete);
-		$("#course_list_ongoing").html(html_ongoing);
-		$("img").one("error", function(){  
-    	$(this).attr("src", "../course/img/default.jpg");   
-	});
-	});
-	</script>	
-
-    </div>
-
-<?php
-include "../pcdl/html_foot.php";
-?>
+	<?php
+	include "../pcdl/html_foot.php";
+	?>

+ 5 - 1
app/course/list_new.php

@@ -13,7 +13,11 @@ $Fetch = PDO_FetchAll($query);
 
 foreach ($Fetch as $row) {
     echo '<div class="card">';
-    echo '<div class="card_photo"></div>';
+    echo '<div>';
+    /* 需協助完善封面代碼...
+    echo '<img src="../../tmp/images/course/' . $iterator['id'] . '.jpg" alt="cover" width="120" height="120"  class="card_photo">';
+*/
+    echo '</div>';
     echo '<div class="course_right">';
     echo '<div class="title"><a href="../course/course.php?id=' . $row["id"] . '">' . $row["title"] . '</a></div>';
     echo '<div class="author">' . $_local->gui->speaker . ':';

+ 16 - 12
app/course/teacher_list.php

@@ -7,23 +7,27 @@ require_once '../public/load_lang.php';
 require_once '../ucenter/function.php';
 
 global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+PDO_Connect("sqlite:" . _FILE_DB_COURSE_);
 $query = "select teacher,count(*) as co from course where 1 group by teacher order by co DESC limit 0,4";
 $Fetch = PDO_FetchAll($query);
 
-foreach($Fetch as $value){
+foreach ($Fetch as $value) {
     echo '<div class="content_block">';
-    echo '<div class="card pd-10">';
-    echo '<div class="title" style="padding-bottom:5px;font-size:110%;font-weight:600;"><a href="../uhome/course.php?userid='.$value['teacher'].'">'.ucenter_getA($value['teacher']).'</a></div>';
-    
-    $query = "select id, title  from course where teacher = '{$value['teacher']}'  order by create_time DESC limit 0,5";
-    $FetchTeacher = PDO_FetchAll($query);
-    foreach($FetchTeacher as $row){
-        echo '<div class="title" style="padding-bottom:5px;"><a href="../course/course.php?id='.$row["id"].'">'.$row["title"].'</a></div>';
+    echo '<div class="teacher_photo"></div>';
+    echo '<div class="teacher_text">';
+    echo '<div class="title"><a href="../uhome/course.php?userid=' . $value['teacher'] . '">' . ucenter_getA($value['teacher']) . '</a></div>';
+    echo '<div class="teacher_intro">';
+    PDO_Connect("sqlite:" . _FILE_DB_USERINFO_);
+    $query = "select bio from profile where user_id = ? limit 0,10";
+    $Fetch = PDO_FetchAll($query,array($value['teacher']));
+    if($Fetch){
+        echo $Fetch[0]["bio"];
+    }
+    else{
+        echo "";
+    }
+    echo '</div>';
 
-    }    
     echo '</div>';
     echo '</div>';
 }
-
-?>

+ 1 - 8
app/pcdl/index.php

@@ -6,12 +6,6 @@ require_once '../pcdl/html_head.php';
 	<script language="javascript" src="../pcdl/index.js"></script>
 
 	<style>
-		.content_block {
-			flex: 0 0 auto;
-			width: 25%;
-			padding: 10px;
-		}
-
 		.content_inner {
 			display: flex;
 		}
@@ -100,8 +94,7 @@ require_once '../pcdl/html_head.php';
 		}
 
 		.card_photo {
-			height: 100%;
-			background: gray;
+			object-fit: cover;
 			border-radius: 20px 0 0 20px;
 		}
 

+ 122 - 116
app/public/js/comm.js

@@ -2,150 +2,156 @@ var VisibleMenu = ""; // 記錄目前顯示的子選單的 ID
 
 // 顯示或隱藏子選單
 function switchMenu(theMainMenu, theSubMenu, theEvent) {
-  var SubMenu = document.getElementById(theSubMenu);
-  if (SubMenu.style.display == "none") {
-    // 顯示子選單
-    SubMenu.style.display = "block";
-    hideMenu(); // 隱藏子選單
-    VisibleMenu = theSubMenu;
-  } else {
-    // 隱藏子選單
-    if (theEvent != "MouseOver" || VisibleMenu != theSubMenu) {
-      SubMenu.style.display = "none";
-      VisibleMenu = "";
-    }
-  }
+	var SubMenu = document.getElementById(theSubMenu);
+	if (SubMenu.style.display == "none") {
+		// 顯示子選單
+		SubMenu.style.display = "block";
+		hideMenu(); // 隱藏子選單
+		VisibleMenu = theSubMenu;
+	} else {
+		// 隱藏子選單
+		if (theEvent != "MouseOver" || VisibleMenu != theSubMenu) {
+			SubMenu.style.display = "none";
+			VisibleMenu = "";
+		}
+	}
 }
 
 // 隱藏子選單
 function hideMenu() {
-  if (VisibleMenu != "") {
-    document.getElementById(VisibleMenu).style.display = "none";
-  }
-  VisibleMenu = "";
+	if (VisibleMenu != "") {
+		document.getElementById(VisibleMenu).style.display = "none";
+	}
+	VisibleMenu = "";
 }
 function com_show_sub_tree(obj) {
-  eParent = obj.parentNode;
-  var x = eParent.getElementsByTagName("ul");
-  if (x[0].style.display == "none") {
-    x[0].style.display = "block";
-    obj.getElementsByTagName("span")[0].innerHTML = "-";
-  } else {
-    x[0].style.display = "none";
-    obj.getElementsByTagName("span")[0].innerHTML = "+";
-  }
+	eParent = obj.parentNode;
+	var x = eParent.getElementsByTagName("ul");
+	if (x[0].style.display == "none") {
+		x[0].style.display = "block";
+		obj.getElementsByTagName("span")[0].innerHTML = "-";
+	} else {
+		x[0].style.display = "none";
+		obj.getElementsByTagName("span")[0].innerHTML = "+";
+	}
 }
 
 //check if the next sibling node is an element node
 function com_get_nextsibling(n) {
-  let x = n.nextSibling;
-  if (x != null) {
-    while (x.nodeType != 1) {
-      x = x.nextSibling;
-      if (x == null) {
-        return null;
-      }
-    }
-  }
-  return x;
+	let x = n.nextSibling;
+	if (x != null) {
+		while (x.nodeType != 1) {
+			x = x.nextSibling;
+			if (x == null) {
+				return null;
+			}
+		}
+	}
+	return x;
 }
 
 function com_guid(trim = true, hyphen = false) {
-  //guid生成器
-  if (trim) {
-    if (hyphen) {
-      var tmp = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
-    } else {
-      var tmp = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-    }
-  } else {
-    if (hyphen) {
-      var tmp = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
-    } else {
-      var tmp = "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}";
-    }
-  }
+	//guid生成器
+	if (trim) {
+		if (hyphen) {
+			var tmp = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
+		} else {
+			var tmp = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+		}
+	} else {
+		if (hyphen) {
+			var tmp = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
+		} else {
+			var tmp = "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}";
+		}
+	}
 
-  var guid = tmp.replace(/[xy]/g, function (c) {
-    var r = (Math.random() * 16) | 0,
-      v = c == "x" ? r : (r & 0x3) | 0x8;
-    return v.toString(16);
-  });
-  return guid.toUpperCase();
+	var guid = tmp.replace(/[xy]/g, function (c) {
+		var r = (Math.random() * 16) | 0,
+			v = c == "x" ? r : (r & 0x3) | 0x8;
+		return v.toString(16);
+	});
+	return guid.toUpperCase();
 }
 function com_uuid() {
-  //guid生成器
-  let tmp = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
-  let uuid = tmp.replace(/[xy]/g, function (c) {
-    var r = (Math.random() * 16) | 0,
-      v = c == "x" ? r : (r & 0x3) | 0x8;
-    return v.toString(16);
-  });
-  return uuid.toLowerCase();
+	//guid生成器
+	let tmp = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
+	let uuid = tmp.replace(/[xy]/g, function (c) {
+		var r = (Math.random() * 16) | 0,
+			v = c == "x" ? r : (r & 0x3) | 0x8;
+		return v.toString(16);
+	});
+	return uuid.toLowerCase();
 }
 function com_xmlToString(elem) {
-  var serialized;
-  try {
-    serializer = new XMLSerializer();
-    serialized = serializer.serializeToString(elem);
-  } catch (e) {
-    serialized = elem.xml;
-  }
-  return serialized;
+	var serialized;
+	try {
+		serializer = new XMLSerializer();
+		serialized = serializer.serializeToString(elem);
+	} catch (e) {
+		serialized = elem.xml;
+	}
+	return serialized;
 }
 
 function com_getPaliReal(inStr) {
-  var paliletter = "abcdefghijklmnoprstuvyāīūṅñṭḍṇḷṃ";
-  var output = "";
-  inStr = inStr.toLowerCase();
-  inStr = inStr.replace(/ṁ/g, "ṃ");
-  inStr = inStr.replace(/ŋ/g, "ṃ");
-  for (x in inStr) {
-    if (paliletter.indexOf(inStr[x]) != -1) {
-      output += inStr[x];
-    }
-  }
-  return output;
+	var paliletter = "abcdefghijklmnoprstuvyāīūṅñṭḍṇḷṃ";
+	var output = "";
+	inStr = inStr.toLowerCase();
+	inStr = inStr.replace(/ṁ/g, "ṃ");
+	inStr = inStr.replace(/ŋ/g, "ṃ");
+	for (x in inStr) {
+		if (paliletter.indexOf(inStr[x]) != -1) {
+			output += inStr[x];
+		}
+	}
+	return output;
 }
 
 function getCookie(c_name) {
-  if (document.cookie.length > 0) {
-    c_start = document.cookie.indexOf(c_name + "=");
-    if (c_start != -1) {
-      c_start = c_start + c_name.length + 1;
-      c_end = document.cookie.indexOf(";", c_start);
-      if (c_end == -1) c_end = document.cookie.length;
-      return unescape(document.cookie.substring(c_start, c_end));
-    } else {
-      return "";
-    }
-  } else {
-    return "";
-  }
+	if (document.cookie.length > 0) {
+		c_start = document.cookie.indexOf(c_name + "=");
+		if (c_start != -1) {
+			c_start = c_start + c_name.length + 1;
+			c_end = document.cookie.indexOf(";", c_start);
+			if (c_end == -1) c_end = document.cookie.length;
+			return unescape(document.cookie.substring(c_start, c_end));
+		} else {
+			return "";
+		}
+	} else {
+		return "";
+	}
+}
+
+function setTimeZone() {
+	const date = new Date();
+	const timezone = date.getTimezoneOffset();
+	setCookie("timezone", timezone, 10);
 }
 
 function setCookie(c_name, value, expiredays) {
-  var exdate = new Date();
-  exdate.setDate(exdate.getDate() + expiredays);
-  document.cookie =
-    c_name +
-    "=" +
-    escape(value) +
-    (expiredays == null ? "" : "; expires=" + exdate.toGMTString() + ";path=/");
+	var exdate = new Date();
+	exdate.setDate(exdate.getDate() + expiredays);
+	document.cookie =
+		c_name + "=" + escape(value) + (expiredays == null ? "" : "; expires=" + exdate.toGMTString() + ";path=/");
 }
 
 function copy_to_clipboard(strInput) {
-  const input = document.createElement("input");
-  input.setAttribute("readonly", "readonly");
-  input.setAttribute("value", strInput);
-  document.body.appendChild(input);
-  //	input.setSelectionRange(0, strInput.length);
-  //	input.focus();
-  input.select();
-  if (document.execCommand("copy")) {
-    document.execCommand("copy");
-    console.log("复制成功");
-    ntf_show("“" + strInput + "”" + gLocal.gui.copied_to_clipboard);
-  }
-  document.body.removeChild(input);
+	const input = document.createElement("input");
+	input.setAttribute("readonly", "readonly");
+	input.setAttribute("value", strInput);
+	document.body.appendChild(input);
+	//	input.setSelectionRange(0, strInput.length);
+	//	input.focus();
+	input.select();
+	if (document.execCommand("copy")) {
+		document.execCommand("copy");
+		console.log("复制成功");
+		ntf_show("“" + strInput + "”" + gLocal.gui.copied_to_clipboard);
+	}
+	document.body.removeChild(input);
 }
+
+//所有页面都需要在加载的的时候设置浏览器时区
+setTimeZone();

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

@@ -0,0 +1,9 @@
+<?PHP
+# 内容的可见性,应用于文集,用户译文等 当有些内容不适合删除时,disable 代替 deleted
+define("_CONTENT_VISIBILITY_DELETED_" , -1);
+define("_CONTENT_VISIBILITY_DISABLE_" , 0);
+define("_CONTENT_VISIBILITY_PRIVATE_" , 10);
+define("_CONTENT_VISIBILITY_UNLISTED_" , 20);
+define("_CONTENT_VISIBILITY_PUBLIC_" , 30);
+
+?>

+ 0 - 4
app/public/php/test_dir.php

@@ -1,4 +0,0 @@
-<?php 
-echo __dir__;
-echo $_SERVER['DOCUMENT_ROOT'];
-?>

+ 56 - 5
app/ucenter/active.php

@@ -4,13 +4,14 @@ require_once '../path.php';
 require_once "../public/function.php";
 
 function add_edit_event($type="",$data=null){
+	date_default_timezone_set("UTC");
 	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);  
+		$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);
@@ -20,9 +21,9 @@ function add_edit_event($type="",$data=null){
 		$currTime = mTime();
 		if ($row) {
 			//找到,判断是否超时,超时新建,未超时修改
-			$endtime = (int)$row["end"];
 			$id = (int)$row["id"];
 			$start_time = (int)$row["start"];
+			$endtime = (int)$row["end"];
 			$hit = (int)$row["hit"];
 			if($currTime-$endtime>MAX_INTERVAL){
 				//超时新建
@@ -37,23 +38,73 @@ function add_edit_event($type="",$data=null){
 			$new_record = true;
 		}
 	
+		#获取客户端时区偏移 beijing = +8
+		if(isset($_COOKIE["timezone"])){
+			$client_timezone = (0-(int)$_COOKIE["timezone"])*60*1000;
+		}
+		else{
+			$client_timezone = 0;
+		}
+		
+		$this_active_time=0;//时间增量
 		if($new_record){
-			$query="INSERT INTO edit ( user_id, start , end  , duration , hit )  VALUES  ( ? , ? , ? , ? , ? ) ";
+			#新建
+			$query="INSERT INTO edit ( user_id, start , end  , duration , hit , timezone )  VALUES  ( ? , ? , ? , ? , ? ,?) ";
 			$sth = $dbh->prepare($query);
-			$sth->execute(array($_COOKIE["userid"] , $currTime , ($currTime+MIN_INTERVAL) , MIN_INTERVAL,1) );
+			#最小思考时间
+			$sth->execute(array($_COOKIE["userid"] , ($currTime-MIN_INTERVAL) ,$currTime ,  MIN_INTERVAL,1 ,$client_timezone ) );
 			if (!$sth || ($sth && $sth->errorCode() != 0)) {
 				$error = $dbh->errorInfo();
 			}
+			$this_active_time=MIN_INTERVAL;
 		}
 		else{
-	
+			#修改
+			$this_active_time=$currTime-$endtime;
 			$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();
 			}
+			
 		}
+
+		#更新经验总量表
+		#计算客户端日期 unix时间戳 以毫秒计
+		$client_currtime = $currTime + $client_timezone;
+		$client_date = strtotime(gmdate("Y-m-d",$client_currtime/1000))*1000;
+		
+		#查询是否存在
+		$query = "SELECT id,duration,hit  FROM active_index WHERE user_id = ? and date = ?";
+		$sth = $dbh->prepare($query);
+		$sth->execute(array($_COOKIE["userid"],$client_date));
+		$row = $sth->fetch(PDO::FETCH_ASSOC);
+		if ($row) {
+			#更新
+			$id = (int)$row["id"];
+			$duration = (int)$row["duration"];
+			$hit = (int)$row["hit"];
+			#修改
+			$query="UPDATE active_index SET duration = ? , hit = ? WHERE id = ? ";
+			$sth = $dbh->prepare($query);
+			$sth->execute( array(($duration+$this_active_time), ($hit+1),$id));
+			if (!$sth || ($sth && $sth->errorCode() != 0)) {
+				$error = $dbh->errorInfo();
+			}			
+		}
+		else{
+			#新建
+			$query="INSERT INTO active_index ( user_id, date , duration , hit )  VALUES  ( ? , ? , ? , ?  ) ";
+			$sth = $dbh->prepare($query);
+			#最小思考时间
+			$sth->execute(array($_COOKIE["userid"] , $client_date ,  MIN_INTERVAL,1 ) );
+			if (!$sth || ($sth && $sth->errorCode() != 0)) {
+				$error = $dbh->errorInfo();
+			}
+		}
+		#更新经验总量表结束
+
 	}
 }
 

+ 46 - 1
app/ucenter/active_analysis.php

@@ -1,3 +1,48 @@
 <?php
 
-?>
+?>
+
+<html>
+<body>
+<script src="https://code.highcharts.com/stock/highstock.js"></script>
+<script src="https://code.highcharts.com/stock/modules/data.js"></script>
+<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
+
+
+<div id="container" style="height: 400px; min-width: 310px"></div>
+
+<script>
+Highcharts.getJSON('active_get.php', function (data) {
+
+// create the chart
+Highcharts.stockChart('container', {
+
+
+	rangeSelector: {
+		selected: 2
+	},
+
+	title: {
+		text: 'Pali Step'
+	},
+
+	series: [{
+		type: 'ohlc',
+		name: 'AAPL Stock Price',
+		data: data,
+		dataGrouping: {
+			units: [[
+				'week', // unit name
+				[1] // allowed multiples
+			], [
+				'month',
+				[1, 2, 3, 4, 6]
+			]]
+		}
+	}]
+});
+});
+
+</script>
+</body>
+</html>

+ 33 - 0
app/ucenter/active_get.php

@@ -0,0 +1,33 @@
+<?php 
+//统计用户经验值
+require_once '../path.php';
+require_once "../public/function.php";
+
+$output=array();
+if(isset($_GET["userid"])){
+	$userid = $_GET["userid"];
+}
+else if(isset($_COOKIE["userid"])){
+	$userid = $_COOKIE["userid"];
+}
+else{
+	exit;
+}
+if(isset($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 date,duration,hit  FROM active_index WHERE user_id = ? ";
+	$sth = $dbh->prepare($query);
+	$sth->execute(array($userid));
+	$last = 0;
+	while($row = $sth->fetch(PDO::FETCH_ASSOC)){
+		$curr = $last+$row["duration"]/3600000;
+		$output[]=array($row["date"],number_format($last,3,".",""),number_format($curr,3,".",""),number_format($last,3,".",""),number_format($curr,3,".",""));
+		$last = $curr;
+	}
+
+	$json =  json_encode($output);
+	echo str_replace('"','',$json);
+}
+?>

+ 38 - 0
app/uhome/foot_step.php

@@ -28,6 +28,13 @@ include "../pcdl/html_head.php";
 <link href='../lib/fullcalendar/main.css' rel='stylesheet' />
 <script src='../lib/fullcalendar/main.js'></script>
 
+<script src="https://code.highcharts.com/stock/highstock.js"></script>
+<script src="https://code.highcharts.com/stock/modules/data.js"></script>
+<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
+
+
+<div id="container" style="height: 400px; min-width: 310px"></div>
+
 <script>
 
   document.addEventListener('DOMContentLoaded', function() {
@@ -58,6 +65,37 @@ include "../pcdl/html_head.php";
     calendar.render();
   });
 
+
+  Highcharts.getJSON('../ucenter/active_get.php', function (data) {
+
+  // create the chart
+  Highcharts.stockChart('container', {
+
+
+    rangeSelector: {
+      selected: 2
+    },
+
+    title: {
+      text: 'Pali Step'
+    },
+
+    series: [{
+      type: 'ohlc',
+      name: '每日收获',
+      data: data,
+      dataGrouping: {
+        units: [[
+          'week', // unit name
+          [1] // allowed multiples
+        ], [
+          'month',
+          [1, 2, 3, 4, 6]
+        ]]
+      }
+    }]
+  });
+  });
 </script>
 <style>
 

+ 4 - 2
app/usent/sent_post.php

@@ -32,13 +32,15 @@ $respond['editor']=$_COOKIE["userid"];
 #先查询对此channal是否有权限修改
 $cooperation = 0;
 $text_lang = "en";
+$channel_status = 0;
 if(isset($_POST["channal"])){
    PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
-    $query = "SELECT owner, lang FROM channal WHERE id=?";
+    $query = "SELECT owner, lang , status FROM channal WHERE id=?";
     $fetch = PDO_FetchRow($query,array($_POST["channal"]));
     
     if($fetch){
         $text_lang = $fetch["lang"];
+        $channel_status = $fetch["status"];
     }
     $respond['lang']=$text_lang;
     if($fetch && $fetch["owner"]==$_COOKIE["userid"]){
@@ -122,7 +124,7 @@ else{
                                 $_POST["text"],
                                 $text_lang ,
                                 1,
-                                7,
+                                $channel_status,
                                 mb_strlen($_POST["text"],"UTF-8"),
                                 mTime(),
                                 mTime(),

+ 17 - 4
app/usent/update.php

@@ -6,6 +6,7 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 require_once "../usent/function.php";
+require_once "../channal/function.php";
 require_once "../ucenter/active.php";
 
 #检查是否登陆
@@ -130,14 +131,26 @@ if(count($newList)>0){
 						VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 	$sth = $PDO->prepare($query);
 
+	$channel_info = new Channal();
+
 	foreach ($newList as $data) {
 			$uuid = UUID::v4();
-			if($data["parent"]){
+			if(isset($data["parent"])){
 				$parent = $data["parent"];
 			}
 			else{
 				$parent  = "";
 			}
+
+			$queryChannel = $channel_info->getChannal($data["channal"]);
+			if($queryChannel == false){
+				$lang = $data["language"];
+				$status = 10;
+			}
+			else{
+				$lang = $queryChannel["lang"];
+				$status = $queryChannel["status"];
+			}
 			$sth->execute(array($uuid,
 						$parent,
 						$data["book"], 
@@ -145,13 +158,13 @@ if(count($newList)>0){
 						$data["begin"], 
 						$data["end"], 
 						$data["channal"], 
-						$data["tag"], 
+						isset($data["tag"])? $data["tag"]:"", 
 						$data["author"], 
 						$_COOKIE["userid"],
 						$data["text"],
-						$data["language"],
+						$lang,
 						1,
-						7,
+						$status,
 						mb_strlen($data["text"],"UTF-8"),
 						mTime(),
 						mTime(),