Explorar o código

merge from mint-migrate-wbw

visuddhinanda %!s(int64=4) %!d(string=hai) anos
pai
achega
87a9aa9276
Modificáronse 95 ficheiros con 2194 adicións e 1119 borrados
  1. 4 4
      public/app/admin/update_user_active_time.php
  2. 24 0
      public/app/api/bootstrap.php
  3. 24 0
      public/app/api/controller/controller.php
  4. 32 0
      public/app/api/controller/sent_prs.php
  5. 220 0
      public/app/api/controller/user_dicts.php
  6. 80 0
      public/app/api/controller/user_operation_logs.php
  7. 9 0
      public/app/api/model/sent_prs.php
  8. 9 0
      public/app/api/model/user_dicts.php
  9. 9 0
      public/app/api/model/user_operation_dailys.php
  10. 9 0
      public/app/api/model/user_operation_frames.php
  11. 9 0
      public/app/api/model/user_operation_logs.php
  12. 34 0
      public/app/api/sent_prs.php
  13. 34 0
      public/app/api/user_dicts.php
  14. 10 8
      public/app/article/add_article_to_collect.php
  15. 6 6
      public/app/article/collect_get.php
  16. 5 4
      public/app/article/collect_list.php
  17. 20 19
      public/app/article/function.php
  18. 2 10
      public/app/article/list.php
  19. 8 6
      public/app/article/list_article_in_collect.php
  20. 4 4
      public/app/article/list_new.php
  21. 3 3
      public/app/article/my_article_post.php
  22. 16 3
      public/app/article/my_article_put.php
  23. 5 5
      public/app/article/my_collect_post.php
  24. 17 4
      public/app/article/my_collect_put.php
  25. 198 0
      public/app/auth/README.md
  26. 159 0
      public/app/auth/api.php
  27. 0 1
      public/app/auth/casbin-test.php
  28. 6 4
      public/app/channal/card.php
  29. 2 3
      public/app/channal/channal.js
  30. 10 10
      public/app/channal/function.php
  31. 10 7
      public/app/channal/get.php
  32. 9 7
      public/app/channal/my_channal_get.php
  33. 8 5
      public/app/channal/my_channal_post.php
  34. 3 3
      public/app/channal/my_channal_put.php
  35. 2 2
      public/app/collect/card.php
  36. 33 19
      public/app/collect/function.php
  37. 4 4
      public/app/collect/list.php
  38. 18 2
      public/app/commit/commit.php
  39. 5 0
      public/app/config.sample.php
  40. 5 11
      public/app/db/channel.php
  41. 2 1
      public/app/db/database.php
  42. 5 3
      public/app/db/test.php
  43. 5 5
      public/app/db/wbw_block.php
  44. 16 12
      public/app/dict/dict_lookup.php
  45. 11 10
      public/app/dict/redis_import_user.php
  46. 4 4
      public/app/dict/redis_pali_word_statistic.php
  47. 13 10
      public/app/doc/edit_wbw.php
  48. 31 90
      public/app/doc/fork.php
  49. 165 165
      public/app/doc/fork_channel.php
  50. 6 6
      public/app/doc/load_channal_para.php
  51. 29 33
      public/app/doc/pcs2db.php
  52. 2 2
      public/app/pali_sent/get_sim.php
  53. 3 1
      public/app/pali_sent/pali_sent_list.php
  54. 2 2
      public/app/pcdl/reader1.php
  55. 15 0
      public/app/public/snowflakeid.php
  56. 6 0
      public/app/setting.php
  57. 1 1
      public/app/share/function.php
  58. 65 83
      public/app/studio/dict_updata_wbw.php
  59. 1 1
      public/app/studio/index_head.php
  60. 70 3
      public/app/studio/js/editor.js
  61. 3 3
      public/app/studio/js/wizard.js
  62. 9 10
      public/app/studio/pc_get_word_num.php
  63. 19 17
      public/app/studio/project.php
  64. 21 18
      public/app/studio/project_load_article.php
  65. 29 25
      public/app/studio/project_load_db.php
  66. 2 2
      public/app/studio/sent/sent.php
  67. 17 13
      public/app/term/channal_list.php
  68. 6 6
      public/app/term/note.js
  69. 34 36
      public/app/term/note.php
  70. 1 1
      public/app/term/term_get.php
  71. 35 19
      public/app/ucenter/active.php
  72. 9 8
      public/app/ucenter/active_get.php
  73. 5 6
      public/app/ucenter/active_log_get.php
  74. 5 5
      public/app/ucenter/active_log_list.php
  75. 148 0
      public/app/ucenter/setting-test.html
  76. 118 0
      public/app/udict/my_dict_list.js
  77. 11 104
      public/app/udict/my_dict_list.php
  78. 6 6
      public/app/uhome/foot_step_data.php
  79. 5 5
      public/app/upgrade/upgrade_pali_toc.php
  80. 37 43
      public/app/usent/function.php
  81. 25 9
      public/app/usent/get.php
  82. 1 1
      public/app/usent/historay_get.php
  83. 3 7
      public/app/usent/new.php
  84. 2 2
      public/app/usent/new_block.php
  85. 40 55
      public/app/usent/sent_post.php
  86. 1 1
      public/app/usent/sent_pr_merge.php
  87. 18 3
      public/app/usent/sent_query.php
  88. 14 18
      public/app/usent/update.php
  89. 28 88
      public/app/uwbw/create_wbw.php
  90. 2 2
      public/app/uwbw/get_index.php
  91. 3 3
      public/app/uwbw/update.php
  92. 3 3
      public/app/uwbw/update_analytics.php
  93. 4 4
      public/app/uwbw/wbw_analyse.php
  94. 10 10
      public/app/uwbw/wbw_channel_list.php
  95. 3 0
      public/package.json

+ 4 - 4
public/app/admin/update_user_active_time.php

@@ -9,14 +9,14 @@ $start = strtotime($last . " +1 day");
 $end = strtotime($last . " +2 day");
 $today = strtotime("today");
 
-$dbh = new PDO(_FILE_DB_USER_ACTIVE_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh = new PDO(_FILE_DB_USER_ACTIVE_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$dbh_index = new PDO(_FILE_DB_USER_ACTIVE_INDEX_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh_index = new PDO(_FILE_DB_USER_ACTIVE_INDEX_, _DB_USERNAME_, _DB_PASSWORD_, 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 (?, ?, ? , ?)";
+$query = "INSERT INTO "._TABLE_SRC_USER_OPERATION_DAILY_." (user_id, date_int , duration , hit) VALUES (?, ?, ? , ?)";
 $sth_index = $dbh_index->prepare($query);
 
 $runing = $last;
@@ -25,7 +25,7 @@ while ($end <= $today) {
     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 ";
+    $query = "SELECT user_id, sum(duration) as time , sum(hit) as hit  FROM "._TABLE_SRC_USER_OPERATION_FRAME_." 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)) {

+ 24 - 0
public/app/api/bootstrap.php

@@ -0,0 +1,24 @@
+<?php
+require "../../vendor/autoload.php";
+
+use Illuminate\Database\Capsule\Manager as Capsule;
+
+$capsule = new Capsule;
+$capsule->addConnection([
+	'driver' => 'pgsql',
+	'host' => '127.0.0.1',
+	'port' => '5432',
+	'database' => 'mint',
+	'username' =>  'postgres',
+	'password' => '123456',
+	'charset' => 'utf8',
+	'options' => [
+		PDO::ATTR_PERSISTENT => true,
+	],
+	'prefix' => '',
+	'prefix_indexes' => true,
+	'schema' => 'public',
+	'sslmode' => 'prefer',
+]);
+$capsule->setAsGlobal();
+$capsule->bootEloquent();

+ 24 - 0
public/app/api/controller/controller.php

@@ -0,0 +1,24 @@
+<?php
+require_once __DIR__."/../../redis/function.php";
+
+Class Controller{
+	protected $redis;
+	protected $response;
+
+	function __construct($redis=true) {
+		if($redis){
+			$this->redis = redis_connect();
+		}
+		$response = ["ok"=>true,"message"=>"","data"=>null];
+	}
+
+	public function error($message){
+		$this->response = ["ok"=>false,"message"=>$message,"data"=>null];
+		echo json_encode($this->response, JSON_UNESCAPED_UNICODE);
+	}
+
+	public function ok($data){
+		$this->response = ["ok"=>true,"message"=>"","data"=>$data];
+		echo json_encode($this->response, JSON_UNESCAPED_UNICODE);
+	}
+}

+ 32 - 0
public/app/api/controller/sent_prs.php

@@ -0,0 +1,32 @@
+<?php
+require_once __DIR__."/../model/sent_prs.php";
+require_once __DIR__."/controller.php";
+
+
+Class CtlSentPr extends Controller{
+	public function index(){
+		$result = SentPr::find($_GET["id"]);
+		echo $result["content"];
+	}	
+	public function create(){
+		$result = SentPr::find($_GET["id"]);
+		echo $result["content"];
+	}	
+		
+	public function show(){
+		$result = SentPr::find($_GET["id"]);
+		if($result){
+			$this->ok($result);
+		}else{
+			$this->error("没有查询到数据");
+		}
+	}
+	public function update(){
+		$result = SentPr::find($_GET["id"]);
+		echo $result["content"];
+	}	
+	public function delete(){
+		$result = SentPr::find($_GET["id"]);
+		echo $result["content"];
+	}
+} 

+ 220 - 0
public/app/api/controller/user_dicts.php

@@ -0,0 +1,220 @@
+<?php
+require_once __DIR__."/../model/user_dicts.php";
+require_once __DIR__."/controller.php";
+
+
+Class CtlUserDict extends Controller{
+	public function index(){
+		$result=false;
+		$indexCol = ['id','word','type','grammar','mean','factors','confidence','updated_at'];
+		switch ($_GET["view"]) {
+			case 'user':
+				# code...
+				$table = UserDict::select($indexCol)
+									->where('creator_id', $_COOKIE["user_id"])
+									->where('source', '<>', "_SYS_USER_WBW_");
+				if(isset($_GET["search"])){
+					$table->where('word', 'like', $_GET["search"]."%");
+				}
+				if(isset($_GET["order"]) && isset($_GET["dir"])){
+					$table->orderBy($_GET["order"],$_GET["dir"]);
+				}else{
+					$table->orderBy('updated_at','desc');
+				}
+				$count = $table->count();
+				if(isset($_GET["limit"])){
+					$offset = 0;
+					if(isset($_GET["offset"])){
+						$offset = $_GET["offset"];
+					}
+					$table->skip($offset)->take($_GET["limit"]);
+				}			
+				$result = $table->get();
+				break;
+			case 'word':
+				$result = UserDict::select($indexCol)
+									->where('word', $_GET["word"])
+									->orderBy('created_at','desc')
+									->get();				
+				break;
+			default:
+				# code...
+				break;
+		}
+		if($result){
+			$this->ok(["rows"=>$result,"count"=>$count]);
+		}else{
+			$this->error("没有查询到数据");
+		}
+
+	}	
+	public function create(){
+		if(!isset($_COOKIE["user_id"])){
+			$this->error("not login");
+		}
+		$_data = json_decode($_POST["data"],true);
+		switch($_POST["view"]){
+			case "wbw":
+				#查询用户重复的数据
+				$iOk = 0;
+				$updateOk=0;
+				foreach ($_data as $key => $word) {
+					# code...
+					$isDoesntExist = UserDict::where('creator_id', $_COOKIE["user_id"])
+										->where('word',$word["word"])
+										->where('type',$word["type"])
+										->where('grammar',$word["grammar"])
+										->where('parent',$word["parent"])
+										->where('mean',$word["mean"])
+										->where('factors',$word["factors"])
+										->where('factormean',$word["factormean"])
+										->where('source','_USER_WBW_')
+										->doesntExist();
+					
+					if($isDoesntExist){
+						#不存在插入数据
+						$word["source"]='_USER_WBW_';
+						$word["creator_id"]=$_COOKIE["user_id"];
+						$id = UserDict::insertGetId($word);
+						$updateOk = $this->update_sys_wbw($word);
+						$this->update_redis($word);
+						$iOk++;
+					}
+				}
+				$this->ok([$iOk,$updateOk]);
+				break;
+			case "dict":
+				break;
+		}
+	}	
+		
+	public function show(){
+		$result = UserDict::find($_GET["id"]);
+		if($result){
+			$this->ok($result);
+		}else{
+			$this->error("没有查询到数据");
+		}
+	}
+	public function update(){
+		$data = json_decode($_POST["data"],true);
+
+		$result = UserDict::where('id', $data["id"])
+						  ->update($data);
+		if($result){
+			$updateOk = $this->update_sys_wbw($data);
+			$this->update_redis($data);
+			$this->ok([$result,$updateOk]);
+		}else{
+			$this->error("没有查询到数据");
+		}
+	}	
+	public function delete(){
+		$arrId = json_decode($_GET["id"],true) ;
+		$count = 0;
+		foreach ($arrId as $key => $id) {
+			# code...
+			$data = UserDict::find($id);
+			$result = UserDict::where('id', $id)
+							->where('creator_id', $_COOKIE["user_id"])
+							->delete();
+			if($result){
+				$count++;
+				$updateOk = $this->update_sys_wbw($data);	
+				$this->update_redis($data);
+			}
+		}
+		$this->ok([$count,$updateOk]);
+	}
+
+	/*
+	更新系统wbw汇总表
+	*/
+	private function update_sys_wbw($data){
+		#查询用户重复的数据
+		$count = UserDict::where('word',$data["word"])
+		->where('type',$data["type"])
+		->where('grammar',$data["grammar"])
+		->where('parent',$data["parent"])
+		->where('mean',$data["mean"])
+		->where('factors',$data["factors"])
+		->where('factormean',$data["factormean"])
+		->where('source','_USER_WBW_')
+		->count();
+		if($count==0){
+			#删除数据
+			$result = UserDict::where('word',$data["word"])
+			->where('type',$data["type"])
+			->where('grammar',$data["grammar"])
+			->where('parent',$data["parent"])
+			->where('mean',$data["mean"])
+			->where('factors',$data["factors"])
+			->where('factormean',$data["factormean"])
+			->where('source','_SYS_USER_WBW_')
+			->delete();
+			return($result);
+
+		}else{
+			#更新或新增
+			#查询最早上传这个数据的用户
+			$creator_id = UserDict::where('word',$data["word"])
+							->where('type',$data["type"])
+							->where('grammar',$data["grammar"])
+							->where('parent',$data["parent"])
+							->where('mean',$data["mean"])
+							->where('factors',$data["factors"])
+							->where('factormean',$data["factormean"])
+							->where('source','_USER_WBW_')
+							->orderby("created_at",'asc')
+							->value("creator_id");
+			$result = UserDict::updateOrInsert(
+				[
+					'word'=>$data["word"],
+					'type'=>$data["type"],
+					'grammar'=>$data["grammar"],
+					'parent'=>$data["parent"],
+					'mean'=>$data["mean"],
+					'factors'=>$data["factors"],
+					'factormean'=>$data["factormean"],
+					'source'=>"_SYS_USER_WBW_"
+				],
+				[
+					'creator_id' => $creator_id,
+					'ref_counter' => $count
+				]);
+			return($result);
+		}
+	}
+
+	private function update_redis($word){
+		#更新 redis
+
+		if ($this->redis != false) {
+			{
+				$Fetch = UserDict::where(['word'=>$word['word'],"source"=>"_SYS_USER_WBW_"])->get();
+				$redisWord=array();
+				foreach ($Fetch as  $one) {
+					# code...
+					$redisWord[] = array(
+									$one["id"],
+									$one["word"],
+									$one["type"],
+									$one["grammar"],
+									$one["parent"],
+									$one["mean"],
+									$one["note"],
+									$one["factors"],
+									$one["factormean"],
+									$one["status"],
+									$one["confidence"],
+									$one["creator_id"],
+									$one["source"],
+									$one["language"]
+									);
+				}
+				$this->redis->hSet("dict://user",$word['word'],json_encode($redisWord,JSON_UNESCAPED_UNICODE));			
+			}
+		}
+		#更新redis结束
+	}
+} 

+ 80 - 0
public/app/api/controller/user_operation_logs.php

@@ -0,0 +1,80 @@
+<?php
+require_once __DIR__."/../model/user_operation_logs.php";
+require_once __DIR__."/../model/user_operation_frames.php";
+require_once __DIR__."/../model/user_operation_dailys.php";
+require_once __DIR__."/controller.php";
+
+
+Class CtlUserOperationLog extends Controller{
+	public function index(){
+		$result=false;
+		switch ($_GET["view"]) {
+			case 'day':
+				# code...
+				$result = UserOperationDaily::where('user_id', $_COOKIE["user_id"])
+											->get();		
+				$count = UserOperationDaily::where('user_id', $_COOKIE["user_id"])
+											->count();
+				break;
+			case 'frame':
+				$result = UserOperationFrame::where('user_id', $_COOKIE["user_id"])
+									->get();		
+				$count = UserOperationFrame::where('user_id', $_COOKIE["user_id"])
+				->count();
+				break;
+			case 'log':
+				$result = UserOperationLog::where('user_id', $_COOKIE["user_id"])
+											->whereBeteen()
+											->get();
+				$count = UserOperationLog::where('user_id', $_COOKIE["user_id"])
+											->count();
+				break;
+			default:
+				# code...
+				break;
+		}
+		if($result){
+			$this->ok(["rows"=>$result,"count"=>$count]);
+		}else{
+			$this->error("没有查询到数据");
+		}
+
+	}	
+	public function create($op_type = "", $content = null){
+		if(!isset($_COOKIE["user_id"])){
+			$this->error("not login");
+			return false;
+		}
+
+		if(isset($_POST["data"])){
+			$_data = json_decode($_POST["data"],true);
+		}else{
+			$_data = ['op_type'=>$op_type,"content"=>$content];
+		}
+		#获取客户端时区偏移 beijing = +8
+		if(!isset($_data['timezone'])){
+			if (isset($_COOKIE["timezone"])) {
+				$_data['timezone'] = (0 - (int) $_COOKIE["timezone"]) * 60 * 1000;
+			} else{
+				$_data['timezone'] = 0;
+			}	
+		}
+		$_data["user_id"] = $_COOKIE["user_id"];
+		UserOperationLog::insert($_data);
+
+
+		
+	}	
+		
+	public function show(){
+		$result = UserOperationLog::find($_GET["id"]);
+		if($result){
+			$this->ok($result);
+		}else{
+			$this->error("没有查询到数据");
+		}
+	}
+	/*
+	更新系统wbw汇总表
+	*/
+}

+ 9 - 0
public/app/api/model/sent_prs.php

@@ -0,0 +1,9 @@
+<?php
+require __DIR__."/../bootstrap.php";
+
+
+use Illuminate\Database\Eloquent\Model as Model;
+class SentPr extends Model
+{
+
+}

+ 9 - 0
public/app/api/model/user_dicts.php

@@ -0,0 +1,9 @@
+<?php
+require __DIR__."/../bootstrap.php";
+
+
+use Illuminate\Database\Eloquent\Model as Model;
+class UserDict extends Model
+{
+
+}

+ 9 - 0
public/app/api/model/user_operation_dailys.php

@@ -0,0 +1,9 @@
+<?php
+require __DIR__."/../bootstrap.php";
+
+
+use Illuminate\Database\Eloquent\Model as Model;
+class UserOperationDaily extends Model
+{
+
+}

+ 9 - 0
public/app/api/model/user_operation_frames.php

@@ -0,0 +1,9 @@
+<?php
+require __DIR__."/../bootstrap.php";
+
+
+use Illuminate\Database\Eloquent\Model as Model;
+class UserOperationFrame extends Model
+{
+
+}

+ 9 - 0
public/app/api/model/user_operation_logs.php

@@ -0,0 +1,9 @@
+<?php
+require __DIR__."/../bootstrap.php";
+
+
+use Illuminate\Database\Eloquent\Model as Model;
+class UserOperationLog extends Model
+{
+
+}

+ 34 - 0
public/app/api/sent_prs.php

@@ -0,0 +1,34 @@
+<?php
+require_once __DIR__."/controller/sent_prs.php";
+
+
+$SentPr = new CtlSentPr;
+
+switch ($_REQUEST["op"]) {
+	case 'index':
+		# get
+		$SentPr->index();
+		break;
+	case 'create':
+		# post
+		$SentPr->create();
+		break;
+	case 'show':
+		# get
+		$SentPr->show();
+		break;	
+	case 'update':
+		# post
+		$SentPr->update();
+		break;	
+	case 'delete':
+		# get
+		$SentPr->delete();
+		break;	
+	default:
+		# code...
+		break;
+}
+
+
+

+ 34 - 0
public/app/api/user_dicts.php

@@ -0,0 +1,34 @@
+<?php
+require_once __DIR__."/controller/user_dicts.php";
+
+
+$UserDict = new CtlUserDict;
+
+switch ($_REQUEST["op"]) {
+	case 'index':
+		# get
+		$UserDict->index();
+		break;
+	case 'create':
+		# post
+		$UserDict->create();
+		break;
+	case 'show':
+		# get
+		$UserDict->show();
+		break;	
+	case 'update':
+		# post
+		$UserDict->update();
+		break;	
+	case 'delete':
+		# get
+		$UserDict->delete();
+		break;	
+	default:
+		# code...
+		break;
+}
+
+
+

+ 10 - 8
public/app/article/add_article_to_collect.php

@@ -1,6 +1,8 @@
 <?php
 //添加文章到文集
-
+# TODO 需要判断文集的修改权限
+# TODO children >0 不能删除
+# TODO 因为要保证顺序不变,已经存在的不能删除
 require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
@@ -16,21 +18,21 @@ if(isset($_POST["id"])){
     $dirty_collect = array();
     $data = json_decode($_POST["data"]);
     $title = $_POST["title"];
-    PDO_Connect(_FILE_DB_USER_ARTICLE_);
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
     $article_id=$_POST["id"];
     //找出脏的collect
-    $query = "SELECT collect_id FROM article_list  WHERE article_id = ? ";
+    $query = "SELECT collect_id FROM "._TABLE_ARTICLE_COLLECTION_."  WHERE article_id = ? ";
     $collect = PDO_FetchAll($query,array($article_id));
     foreach ($collect as $key => $value) {
         # code...
         $dirty_collect[$value["collect_id"]] = 1;
     }
-    $query = "DELETE FROM article_list WHERE article_id = ? ";
+    $query = "DELETE FROM "._TABLE_ARTICLE_COLLECTION_." WHERE article_id = ? ";
      PDO_Execute($query,array($article_id));
      if(count($data)>0){
         /* 开始一个事务,关闭自动提交 */
         $PDO->beginTransaction();
-        $query = "INSERT INTO article_list (collect_id, article_id,level,title) VALUES (?, ?, ? , ?)";
+        $query = "INSERT INTO "._TABLE_ARTICLE_COLLECTION_." (collect_id, article_id,level,title) VALUES (?, ?, ? , ?)";
         $sth = $PDO->prepare($query);
         foreach ($data as $row) {
             $sth->execute(array($row,$article_id,1,$title));
@@ -46,7 +48,7 @@ if(isset($_POST["id"])){
      }
 
      # 更新collect
-     $query = "SELECT collect_id FROM article_list WHERE article_id  = ?";
+     $query = "SELECT collect_id FROM "._TABLE_ARTICLE_COLLECTION_." WHERE article_id  = ?";
      $collect = PDO_FetchAll($query,array($article_id));
      foreach ($collect as $key => $value) {
         # code...
@@ -54,9 +56,9 @@ if(isset($_POST["id"])){
     }
      foreach ($dirty_collect as $key => $value) {
          # code...
-         $query = "SELECT level,article_id as article , title FROM article_list WHERE collect_id  = ?";
+         $query = "SELECT level,article_id as article , title FROM "._TABLE_ARTICLE_COLLECTION_." WHERE collect_id  = ? order by id ASC";
          $collect_info = PDO_FetchAll($query,array($key));
-         $query = "UPDATE collect SET article_list = ? WHERE id = ? ";
+         $query = "UPDATE "._TABLE_COLLECTION_." SET article_list = ? WHERE uid = ? ";
          $strArticleList = json_encode($collect_info, JSON_UNESCAPED_UNICODE);
          $stmt = PDO_Execute($query,array( $strArticleList ,$key));
          if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {

+ 6 - 6
public/app/article/collect_get.php

@@ -18,16 +18,16 @@ if(isset($_GET["id"])){
 		echo json_encode(array(), JSON_UNESCAPED_UNICODE);
         exit;
 	}
-    PDO_Connect(_FILE_DB_USER_ARTICLE_);
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
     $id=$_GET["id"];
-    $query = "select * from collect  where id = ? ";
+    $query = "SELECT uid as id,title, subtitle,summary,article_list,owner,setting,status,lang,create_time,modify_time from "._TABLE_COLLECTION_."  where uid = ? ";
     $Fetch = PDO_FetchRow($query,array($id));
     if($Fetch){
         $userinfo = new UserInfo();
         $user = $userinfo->getName($Fetch["owner"]);
         $Fetch["username"] = $user;
         #查询文集中文档列表
-        $query = "select level,article_id as article,title from article_list  where collect_id = ? ";
+        $query = "SELECT level,article_id as article,title from "._TABLE_ARTICLE_COLLECTION_."  where collect_id = ? order by id ASC";
         $fArticle_list = PDO_FetchAll($query,array($id));    
         $Fetch["article_list"] = json_encode($fArticle_list, JSON_UNESCAPED_UNICODE);
         echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
@@ -36,9 +36,9 @@ if(isset($_GET["id"])){
 }
 else if(isset($_GET["article"])){
     # 给文章编号,查文集信息
-    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
     $article=$_GET["article"];
-    $query = "SELECT collect_id FROM article_list  WHERE article_id = ? ";
+    $query = "SELECT collect_id FROM "._TABLE_ARTICLE_COLLECTION_."  WHERE article_id = ? ";
     $Fetch = PDO_FetchAll($query,array($article));
     
     /*  使用一个数组的值执行一条含有 IN 子句的预处理语句 */
@@ -50,7 +50,7 @@ else if(isset($_GET["article"])){
     /*  创建一个填充了和params相同数量占位符的字符串 */
     $place_holders = implode(',', array_fill(0, count($params), '?'));
 
-    $query = "SELECT * FROM collect WHERE id IN ($place_holders)";
+    $query = "SELECT * FROM "._TABLE_COLLECTION_." WHERE uid IN ($place_holders)";
 
     $Fetch = PDO_FetchAll($query,$params);
         echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);

+ 5 - 4
public/app/article/collect_list.php

@@ -8,14 +8,15 @@ require_once '../ucenter/function.php';
 
 
 if(isset($_GET["userid"])){
-    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
     $userid=$_GET["userid"];
-    $query = "SELECT * from collect  where owner = ? and status <> 0 order by modify_time DESC";
+    $query = "SELECT uid as id,title,subtitle,summary,article_list,owner,status,lang,create_time,modify_time from "._TABLE_COLLECTION_."  where owner = ? and status <> 0 order by modify_time DESC";
     $Fetch = PDO_FetchAll($query,array($userid));
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
-    exit;
+}else{
+	echo json_encode(array(), JSON_UNESCAPED_UNICODE);	
 }
 
-echo json_encode(array(), JSON_UNESCAPED_UNICODE);	
+
 
 ?>

+ 20 - 19
public/app/article/function.php

@@ -6,7 +6,7 @@ require_once "../db/table.php";
 class Article extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_USER_ARTICLE_, "article", "", "",$redis);
+		parent::__construct(_FILE_DB_USER_ARTICLE_, _TABLE_ARTICLE_, _DB_USERNAME_,_DB_PASSWORD_,$redis);
     }
 
     public function getInfo($id){
@@ -19,14 +19,14 @@ class Article extends Table
 				$output["owner"]=$this->redis->hGet("article://".$id,"owner");
 				$output["summary"]=$this->redis->hGet("article://".$id,"summary");
 				$output["lang"]=$this->redis->hGet("article://".$id,"lang");
-				$output["tag"]=$this->redis->hGet("article://".$id,"tag");
+				$output["tag"]="";
 				$output["status"]=$this->redis->hGet("article://".$id,"status");
 				$output["create_time"]=$this->redis->hGet("article://".$id,"create_time");
 				$output["modify_time"]=$this->redis->hGet("article://".$id,"modify_time");
 				return $output;
 			}
 		}
-        $query = "SELECT id,title,owner,subtitle,summary,lang,tag,status,create_time,modify_time FROM article WHERE id= ? ";
+        $query = "SELECT uid as id,title,owner,subtitle,summary,lang,status,create_time,modify_time FROM "._TABLE_ARTICLE_." WHERE uid= ? ";
         $stmt = $this->dbh->prepare($query);
         $stmt->execute(array($id));
         $output = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -40,7 +40,6 @@ class Article extends Table
 				$this->redis->hSet("article://".$id,"summary",$output["summary"]);
 				$this->redis->hSet("article://".$id,"lang",$output["lang"]);
 				$this->redis->hSet("article://".$id,"owner",$output["owner"]);
-				$this->redis->hSet("article://".$id,"tag",$output["tag"]);
 				$this->redis->hSet("article://".$id,"status",$output["status"]);
 				$this->redis->hSet("article://".$id,"create_time",$output["create_time"]);
 				$this->redis->hSet("article://".$id,"modify_time",$output["modify_time"]);
@@ -60,7 +59,7 @@ class Article extends Table
 				return $content;
 			}
 		}
-        $query = "SELECT content FROM article WHERE id= ? ";
+        $query = "SELECT content FROM ".$this->table." WHERE uid= ? ";
         $stmt = $this->dbh->prepare($query);
         $stmt->execute(array($id));
         $output = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -77,39 +76,41 @@ class Article extends Table
 
 	public function getPower($id,$collectionId=""){
 		#查询用户对此是否有权限	
-		if(isset($_COOKIE["userid"])){
-			$userId = $_COOKIE["userid"];
+		if(isset($_COOKIE["user_uid"])){
+			$userId = $_COOKIE["user_uid"];
 		}
 		else{
 			$userId=0;
 		}
+
 		if($this->redis!==false){
 			$power = $this->redis->hGet("power://article/".$id,$userId);
 			if($power!==FALSE){
 				return $power;
 			}
 		}
+
 		$iPower = 0;
-		$query = "SELECT owner,status FROM article WHERE id=?  ";
+		$query = "SELECT owner,status FROM "._TABLE_ARTICLE_." WHERE uid=?  ";
 		$stmt = $this->dbh->prepare($query);
 		$stmt->execute(array($id));
 		$channel = $stmt->fetch(PDO::FETCH_ASSOC);
 		if($channel){
-			if(!isset($_COOKIE["userid"])){
+			if(!isset($_COOKIE["user_uid"])){
 				#未登录用户
 				if($channel["status"]==30){
 					#全网公开有读取和建议权限
-					return 10;
+					$iPower =  10;
 				}
 				else{
 					#其他状态没有任何权限
-					return 0;
+					$iPower =  0;
 				}
 			}
 			else{
-				if($channel["owner"]==$_COOKIE["userid"]){
+				if($channel["owner"]==$_COOKIE["user_uid"]){
 					#自己的
-					return 30;
+					$iPower =  30;
 				}
 				else if($channel["status"]>=30){
 					#全网公开的 可以提交pr
@@ -118,9 +119,9 @@ class Article extends Table
 			}
 		}
 		#查询共享权限,如果共享权限更大,覆盖上面的的
-		$sharePower = share_get_res_power($_COOKIE["userid"],$id);
+		$sharePower = share_get_res_power($_COOKIE["user_uid"],$id);
 		if($collectionId!=""){
-			$sharePowerCollection = share_get_res_power($_COOKIE["userid"],$collectionId);
+			$sharePowerCollection = share_get_res_power($_COOKIE["user_uid"],$collectionId);
 		}
 		else{
 			$sharePowerCollection =0;
@@ -132,7 +133,7 @@ class Article extends Table
 			$iPower=$sharePowerCollection;
 		}
 		if($this->redis!==false){
-			$this->redis->hSet("power://article/".$id,$_COOKIE["userid"],$iPower);
+			$this->redis->hSet("power://article/".$id,$_COOKIE["user_uid"],$iPower);
 		}
 		return $iPower;
 	}
@@ -143,12 +144,12 @@ class Article extends Table
 class ArticleList extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_USER_ARTICLE_, "article_list", "", "",$redis);
+		parent::__construct(_FILE_DB_USER_ARTICLE_, _TABLE_ARTICLE_COLLECTION_, _DB_USERNAME_,_DB_PASSWORD_,$redis);
     }
 
 	function upgrade($collectionId,$articleList=array()){
 		# 更新 article_list 表
-		$query = "DELETE FROM article_list WHERE collect_id = ? ";
+		$query = "DELETE FROM ".$this->table." WHERE collect_id = ? ";
 		$stmt = $this->dbh->prepare($query);
 		if($stmt){
 			$stmt->execute(array($collectionId));
@@ -157,7 +158,7 @@ class ArticleList extends Table
 		if(count($articleList)>0){
 			/* 开始一个事务,关闭自动提交 */
 			$this->dbh->beginTransaction();
-			$query = "INSERT INTO article_list (collect_id, article_id,level,title) VALUES ( ?, ?, ? , ? )";
+			$query = "INSERT INTO ".$this->table." (collect_id, article_id,level,title) VALUES ( ?, ?, ? , ? )";
 			$sth = $this->dbh->prepare($query);
 			foreach ($articleList as $row) {
 				$sth->execute(array($collectionId,$row["article"],$row["level"],$row["title"]));

+ 2 - 10
public/app/article/list.php

@@ -5,24 +5,16 @@ require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../ucenter/function.php';
-PDO_Connect(""._FILE_DB_USER_ARTICLE_);
+PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
 if(isset($_GET["userid"])){
     $userid=$_GET["userid"];
-    $query = "SELECT * from article  where owner = ? and status <> 0 order by modify_time DESC";
+    $query = "SELECT uid as id , title,subtitle ,summary,content,owner,setting,status,lang,create_time,modify_time from "._TABLE_ARTICLE_."  where owner = ? and status <> 0 order by modify_time DESC";
     $Fetch = PDO_FetchAll($query,array($userid));
     if($Fetch){
-        /*
-        $userinfo = new UserInfo();
-        $user = $userinfo->getName($Fetch["owner"]);
-        $Fetch["username"] = $user;
-        */
         echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
         exit;
     }
 }
-else{
-
-}
 
 echo json_encode(array(), JSON_UNESCAPED_UNICODE);	
 

+ 8 - 6
public/app/article/list_article_in_collect.php

@@ -1,5 +1,5 @@
 <?php
-//查询term字典
+//查询某article 在哪几个collection里面出现
 
 require_once "../config.php";
 require_once "../public/_pdo.php";
@@ -8,21 +8,23 @@ require_once '../ucenter/function.php';
 
 $output  = array();
 if(isset($_GET["id"])){
-    PDO_Connect(""._FILE_DB_USER_ARTICLE_);
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
     $article_id=$_GET["id"];
-    $query = "SELECT collect_id as id from article_list  where article_id = ?  ";
+    $query = "SELECT collect_id as id from "._TABLE_ARTICLE_COLLECTION_."  where article_id = ?  ";
     $exist = PDO_FetchAll($query,array($article_id));
     $exist_id = array();
+	#查询已经存在的collection详细信息
     for ($i=0; $i < count($exist) ; $i++) { 
         # query collect title
-        $query = "SELECT title from collect  where id = ?  ";
+        $query = "SELECT title from "._TABLE_COLLECTION_."  where uid = ?  ";
         $exist[$i]["title"] = PDO_FetchOne($query,array($exist[$i]["id"]));        
         $exist_id[$exist[$i]["id"]] = 1;
     }
     $output["exist"] = $exist;
 
-    $query = "SELECT id,title from collect  where owner = ? AND status <> 0 order by modify_time DESC limit 0,50";
-    $others = PDO_FetchAll($query,array($_COOKIE["userid"])); 
+	#查询所有的
+    $query = "SELECT uid as id,title from "._TABLE_COLLECTION_."  where owner = ? AND status <> 0 order by modify_time DESC limit 50";
+    $others = PDO_FetchAll($query,array($_COOKIE["user_uid"])); 
     foreach ($others as $key => $value) {
         # remove exist record
         if(!isset($exist_id[$value["id"]])){

+ 4 - 4
public/app/article/list_new.php

@@ -24,8 +24,8 @@ require_once '../collect/function.php';
     else{
         $begin = 0;
     }
-    PDO_Connect(_FILE_DB_USER_ARTICLE_);
-    $query = "SELECT id,title,subtitle,summary,owner,modify_time from article  where status >= 30 ";
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid as id,title,subtitle,summary,owner,modify_time from "._TABLE_ARTICLE_."  where status >= 30 ";
     
     if(isset($_GET["orderby"])){
         switch ($_GET["orderby"]) {
@@ -42,7 +42,7 @@ require_once '../collect/function.php';
     else{
         $query .="ORDER BY modify_time DESC";
     }
-    $query .=" LIMIT $begin , $onepage ";
+    $query .=" LIMIT $onepage OFFSET $begin  ";
     $Fetch = PDO_FetchAll($query);
     $collect_info = new CollectInfo();
     foreach ($Fetch as $key => $value) {
@@ -50,7 +50,7 @@ require_once '../collect/function.php';
         $userinfo = new UserInfo();
         $user = $userinfo->getName($value["owner"]);
         $Fetch[$key]["username"] = $user;
-        $query = "SELECT collect_id from article_list  where article_id = ? ";
+        $query = "SELECT collect_id from "._TABLE_ARTICLE_COLLECTION_."  where article_id = ? ";
         $collect = PDO_FetchRow($query,array($Fetch[$key]["id"]));
         if($collect){
             $Fetch[$key]["collect"] = $collect_info->get($collect["collect_id"]);

+ 3 - 3
public/app/article/my_article_post.php

@@ -54,11 +54,11 @@ if(isset($_POST["import"]) && $_POST["import"]=='on'){
 }
 
 
-PDO_Connect(_FILE_DB_USER_ARTICLE_);
+PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
 
-$query="UPDATE article SET title = ? , subtitle = ? , summary = ?, lang = ? , content = ?  , tag = ? , setting = ? , status = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
+$query="UPDATE "._TABLE_ARTICLE_." SET title = ? , subtitle = ? , summary = ?, lang = ? , content = ?   , setting = ? , status = ? , updated_at=now()  , modify_time= ?   where  uid = ?  ";
 $sth = $PDO->prepare($query);
-$sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$_POST["summary"] ,$_POST["lang"], $_content , $_POST["tag"] , "{}" , $_POST["status"] ,   mTime() , mTime() , $_POST["id"]));
+$sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$_POST["summary"] ,$_POST["lang"], $_content  , "{}" , $_POST["status"] ,   mTime() , $_POST["id"]));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();

+ 16 - 3
public/app/article/my_article_put.php

@@ -29,15 +29,28 @@ if(isset($_POST["content"])){
 else{
 	$content = "";
 }
-PDO_Connect(_FILE_DB_USER_ARTICLE_);
+PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
 
-$query="INSERT INTO article ( id,  title  , subtitle  , summary , content   , tag  , owner, setting  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
+$query="INSERT INTO "._TABLE_ARTICLE_." ( 
+			uid,  
+			title  , 
+			subtitle  , 
+			summary , 
+			content  , 
+			owner, 
+			owner_id, 
+			editor_id, 
+			setting  , 
+			status  , 
+			create_time , 
+			modify_time    
+			)  VALUES  (  ? ,  ? , ? , ? , ? , ? , ? , ? ,? ,?, ? , ? ) ";
 $sth = $PDO->prepare($query);
 $uuid = UUID::v4();
 //写入日志
 add_edit_event(_ARTICLE_NEW_,$uuid);
 #新建文章默认私有
-$sth->execute(array($uuid , $_POST["title"] , "" ,"", $content , "" , $_COOKIE["userid"] , "{}" , 10 , mTime() ,  mTime() , mTime() ));
+$sth->execute(array($uuid , $_POST["title"] , "" ,"", $content  , $_COOKIE["user_uid"] , $_COOKIE["user_id"] , $_COOKIE["user_id"] , "{}" , 10 , mTime() ,  mTime()  ));
 
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();

+ 5 - 5
public/app/article/my_collect_post.php

@@ -29,11 +29,11 @@ if($power<20){
 
 add_edit_event(_COLLECTION_EDIT_,$_POST["id"]);
 
-PDO_Connect(_FILE_DB_USER_ARTICLE_);
+PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
 
-$query="UPDATE collect SET title = ? , subtitle = ? , summary = ?, article_list = ?  ,  status = ? , lang = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
+$query="UPDATE "._TABLE_COLLECTION_." SET title = ? , subtitle = ? , summary = ?, article_list = ?  ,  status = ? , lang = ? , updated_at= now()  , modify_time= ?   where  uid = ?  ";
 $sth = $PDO->prepare($query);
-$sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$_POST["summary"], $_POST["article_list"] , $_POST["status"] , $_POST["lang"] ,  mTime() , mTime() , $_POST["id"]));
+$sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$_POST["summary"], $_POST["article_list"] , $_POST["status"] , $_POST["lang"] ,  mTime() ,  $_POST["id"]));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();
@@ -46,13 +46,13 @@ else{
 		$redis->del("power://collection/".$_POST["id"]);
 	}
     # 更新 article_list 表
-    $query = "DELETE FROM article_list WHERE collect_id = ? ";
+    $query = "DELETE FROM "._TABLE_ARTICLE_COLLECTION_." WHERE collect_id = ? ";
     PDO_Execute($query,array($_POST["id"]));
     $arrList = json_decode($_POST["article_list"]);
     if(count($arrList)>0){
         /* 开始一个事务,关闭自动提交 */
         $PDO->beginTransaction();
-        $query = "INSERT INTO article_list (collect_id, article_id,level,title,children) VALUES ( ? , ?, ?, ? , ? )";
+        $query = "INSERT INTO "._TABLE_ARTICLE_COLLECTION_." (collect_id, article_id,level,title,children) VALUES ( ? , ?, ?, ? , ? )";
         $sth = $PDO->prepare($query);
         foreach ($arrList as $row) {
             $sth->execute(array($_POST["id"],$row->article,$row->level,$row->title,$row->children));

+ 17 - 4
public/app/article/my_collect_put.php

@@ -24,11 +24,24 @@ if(!isset($_POST["title"])){
 $uuid = UUID::v4();
 add_edit_event(_COLLECTION_NEW_,$uuid);
 
-PDO_Connect(""._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 , $_POST["title"] , "" ,"", "[]" ,  $_COOKIE["userid"] , "" , $_POST["status"] , mTime() ,  mTime() , mTime() ));
+PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
+$query="INSERT INTO "._TABLE_COLLECTION_." ( 
+		uid ,  
+		title  , 
+		subtitle  , 
+		summary , 
+		article_list   , 
+		owner, 
+		owner_id, 
+		editor_id, 
+		lang  , 
+		status  , 
+		create_time , 
+		modify_time    
+		)  VALUES  (  ? , ? , ?  , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
+$sth = $PDO->prepare($query);
+$sth->execute(array($uuid , $_POST["title"] , "" ,"", "[]" ,  $_COOKIE["user_uid"] ,  $_COOKIE["user_id"],  $_COOKIE["user_id"], "" , $_POST["status"] , mTime() ,  mTime() ));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();

+ 198 - 0
public/app/auth/README.md

@@ -0,0 +1,198 @@
+# 权限管理
+
+## 业务需求
+
+实现网站资源的权限管理。设置和查询某用户对某资源的拥有的权限。权限包括但不限于 转让,创建,修改,删除,读取等。
+
+## 业务实现
+
+分为三个部分
+1. 角色管理-所有用户都至少有一个角色
+2. 资源-所有资源都在一个资源树上资源树的根节点称为studio 也就是github的orginaze。
+3. 权限设置-某角色对某资源有某种权限
+4. 权限查询-某用户对某资源是否有某种权限
+4. 资源列表-某用户列出某资源的直接子资源(有读取或更高权限)的列表
+
+## 角色
+
+每个studio 必定拥有下面的几种角色。
+角色权限有从高到低的权限继承关系。高级角色必定有低级角色的所有权限。
+角色由高到低分别是
+1. 拥有者(owner)——一个资源的拥有者只限一个
+	- 转让
+1. 管理员(manager)
+	- 分享权限给其他人(share)
+3. 编辑者(editor)
+	- 建立资源(create)
+	- 修改资源(update)
+	- 删除资源(delete)
+4. 成员(member)
+	- 读取(read)
+
+每一个studio 建立的时候默认建立上述角色。
+
+群组权限管理用新建角色的方法。每个群组在建立的时候,在该studio下新建一个角色。
+此角色对任何资源都没有权限。需要手工指定某资源对这个群组的权限。添加成员实际上是将某user加到这个角色。
+
+网站建立的时候默认建立一个"public" studio。
+所有的注册用户都加入 public/member 角色。
+所有访问网站者,包括未登录者,都加入 public/visitor 角色。
+当某资源设置为全网公开,实际上是分享读取权限给public/visitor
+
+## 资源
+资源为树结构
+
+- studio
+	- channel
+		- translation
+		- orginal
+		- nissaya
+		- commentray
+		- term
+		- wbw
+	- collection-templet
+		- article-templet
+			- sentence
+	- user dictionary
+	- group
+	- course
+		- lesson
+
+网站建立时,建立根资源节点
+
+- root
+	- studio
+
+user-01 账号建立时,同时建立studio-01.并在 root/studio 下面建立下面的父资源。
+
+- studio-01
+	- channel
+	- collection-templet
+	- user-dictionary
+	- group
+	- course
+
+user-01 建立 channel-01 挂在 studio-01/channel下面
+
+- root
+	- studio
+		- studio-01
+			- channel
+				- channel-01
+## 授权
+
+1. 注册用户user-01在注册时同时注册一个与用户名相同的studio-01。
+1. 添加角色 public/member/user-01
+1. 添加角色 studio-01/owner
+1. 建立studio-01下所有默认资源根节点
+1. 建立studio-01下所有默认角色
+1. user-01与studio-01绑定。不能转让。
+2. 设置user-01为 studio-01/owner。这样,此用户拥有该studio-01下全部权限。 
+3. user-01 添加新的channel-01 为 在studio-01/channel 添加子资源 channel-01
+4. user-01 将 channel-01 分享 给 user-02 = 授权 studio-01/channel/channel-01 给 studio-02/owner 
+
+## 鉴权
+
+- 只对角色进行鉴权操作
+- 需要获取某角色在某资源节点下所有子资源列表(包括自己拥有的,共享资源等)
+- 需要获取某角色在某资源下是否有某操作的权限
+- 需要获取某用户(实际上是studio/owner角色)在某资源节点下所有子资源列表
+- 需要获取某用户(实际上是studio/owner角色)在某资源下是否有某操作的权限
+
+
+## 接口
+
+每个api 有五个接口
+1. **index** 列出资源列表(如:用户的所有文章)
+1. **create** 创建资源
+1. **show** 获取单个资源详细信息
+1. **update** 修改资源
+1. **delete** 删除资源
+
+针对这五个接口实现鉴权函数。就是说在api::***中将会调用如下函数。
+
+1. api::index
+	- auth::Index($user,$resId,$resType)
+1. api::create
+	- auth::UserCanCreate($user,$resId,$resType)
+	- auth::UserCteate($user,$resId,$resType)
+1. api::show
+	- auth::UserCanRead($user,$resId,$resType)
+1. api::update
+	- auth::UserCanUpdate($user,$resId,$resType)
+	- auth::DeletePolicy($role,$resId,$resType,$act) // 删除授权
+	- auth::CreatePolicy($role,$resId,$resType,$act) // 授权
+1. api::delete
+	- auth::DeleteObject($role,$resId,$resType) // 删除资源
+
+## 场景模拟
+
+### step-0 网站建立
+
+网站建立时,建立根资源节点
+
+- root
+	- studio
+
+### 注册新用户
+
+1. 注册用户user-01在注册时同时注册一个与用户名相同的studio-01。
+	- root
+		- studio
+			studio-01
+1. 添加角色 public/member/user-01
+1. 建立studio-01下所有默认资源根节点
+	- studio-01
+		- channel
+		- collection-templet
+		- user-dictionary
+		- group
+		- course
+1. 建立studio-01下所有默认角色和继承关系
+	- studio-01
+		- owner
+		- manager
+		- editor
+		- member
+1. 将user-01与studio-01/owner 绑定
+1. user-01与studio-01绑定。不能转让。
+
+
+### 用户添加channel
+
+user-01 建立 channel-01 挂在 studio-01/channel下面
+
+- root
+	- studio
+		- studio-01
+			- channel
+				- channel-01
+
+添加channel-01下面的资源根节点
+- channel-01
+	- translation
+	- orginal
+	- nissaya
+	- commentray
+	- term
+	- wbw
+
+>句子译文挂在 channel-01/translation下面。这样能够实现channel-01的信息如标题等和译文的修改分开鉴权。
+比如我是channel-01的拥有者。我把channel-01的翻译权限给user-02。我希望user-02修改译文,而不是channel名称。
+我只需分享channel-01/translation的edit权限给user-02。
+
+### user-01修改channel信息
+鉴权:user-01 是否 有channel写入权限
+auth::UserCanUpdate($user-01,"channel-01","channel")
+
+
+### 在channel下添加译文
+
+鉴权:user-01 是否 有译文写入权限
+
+auth::UserCanUpdate($user-01,"channel-01/translation","channel/translation")
+
+### 分享channel
+user-01将channel-01的翻译权限给user-02
+
+auth::CreatePolicy("studio-02/owner","channel-01/translation","channel/translation","edit") // 授权

+ 159 - 0
public/app/auth/api.php

@@ -0,0 +1,159 @@
+<?php
+require_once '../../vendor/autoload.php';
+require_once '../config.php';
+
+use Casbin\Enforcer;
+use CasbinAdapter\Medoo\Adapter as DatabaseAdapter;
+
+define("IDPrefixTranslation" , "it_");
+define("IDPrefixChannel", "ic_");
+define("IDPrefixArticle", "ia_");
+define("IDPrefixUser" , "iu_");
+define("IDPrefixOrg"  , "io_");
+define("IDPrefixOrgGroup", "iog_");
+
+// 资源分组:版本风格
+define("ResStudio" , "s_studio");
+// 资源分组:版本风格
+define("ResChannel" , "s_channel");
+// 资源分组:文章
+define("ResArticle" , "s_article");
+// 资源分组:文集
+define("ResArticle" , "s_collection");
+// 资源分组:译文(版本风格 + 文章)句子库
+define("ResTranslation" , "s_translation");
+// 资源分组:逐词译段落
+define("ResArticle" , "s_wbw");
+// 资源分组:术语
+define("ResArticle" , "s_term");
+// 资源分组:用户字典
+define("ResArticle" , "s_userdict");
+
+// 组织拥有者 转让
+define("RoleOrgOwner" , "r_owner");
+// 组织管理员 创建 删除 修改 文章/文集模版 channel group
+define("RoleOrgAdmin" , "r_admin");
+// 组织编辑 修改译文
+define("RoleOrgEditor" , "r_editor");
+// 组织成员 读取任意资源
+define("RoleOrgMember" , "r_member");
+// 组织访客(比如未注册用户) 只读取公开资源
+define("RoleOrgVisitor" , "r_visitor");
+
+// 权限:角色分组
+define("GroupRole" , "g");
+// 权限:资源分组
+define("GroupRes" , "g2");
+
+// 权限:阅读权限
+define("PermRead" , "p_read");
+// 权限:翻译权限
+define("PermTrans" , "p_trans");
+// 权限:修改权限
+define("PermWrite" , "p_write");
+// 权限:创建
+define("PermCreate" , "p_create");
+// 权限:删除
+define("PermDelete" , "p_delete");
+// 权限:修改
+define("PermUpdate" , "p_update");
+
+/*
+
+所有的注册用户都加入 public/member 角色
+所有访问网站者,包括未登录者,都加入 public/visitor 角色
+注册用户在注册时同时注册一个与用户名相同的studio
+
+*/
+
+class CasbinAuth{
+	protected $config = [
+		'database_type' => Database["type"],
+		'server' => Database['server'],
+		'database_name' => Database['name'],
+		'username' => Database['user'],
+		'password' => Database['password'],
+		'port' => Database['port'],
+	];
+	protected $adapter;
+	protected $e;
+	function __construct() {
+		$this->adapter = DatabaseAdapter::newAdapter($config);
+		$this->e = new Enforcer(__DIR__.'/rbac.model.conf', $adapter);
+	}
+
+	/*
+	列出某用户有权限的资源列表
+	例如 zhang3 在 org1 下的 所有 有权限的 channel 列表
+	Index( "zhang3" , "org1" , "channel" )
+	*/
+	public function IndexRes($user,$resNodeId,$resType){
+
+	}
+
+	/*
+	某用户某个资源列表
+	例如 zhang3 在 org1 下的 所有 channel 列表
+	Index( "zhang3" , "org1" , "channel" )
+	*/
+	public function UserCanReadRes($user,$resNodeId,$resType){
+
+	}
+
+	/*
+	某用户建立某个资源
+	*/
+	public function UserCreateRes($user,$resNode,$resType){
+
+	}
+	/*
+	查询某用户是否可以建立某个资源
+	*/
+	public function UserCanCreateRes($user,$resNode,$resType){
+
+	}
+
+	/*
+	某用户删除某个资源
+	*/
+	public function UserDeleteRes($user,$resId,$resType){
+
+	}
+	/*
+	查询某用户是否可以删除某个资源
+	*/
+	public function UserCanDeleteRes($user,$resId,$resType){
+
+	}
+
+	/*
+	查询某用户是否可以修改某个资源
+	返回值 true/fasle
+	*/
+	public function CanUpdateRes($user,$resId,$resType){
+
+	}
+
+
+	public function setRoleRight($role,$resId,$resType,$right){
+
+	}
+	public function testRoleRight($role,$resId,$resType,$right){
+		
+	}
+
+	public function setUserRight($user,$resId,$resType,$right){
+
+	}
+	public function testUserRight($user,$resId,$resType,$right){
+		
+	}
+
+	public function addRole($user,$role){
+
+	}
+
+	public function removeRole($user,$role){
+		
+	}
+}

+ 0 - 1
public/app/auth/casbin-test.php

@@ -2,7 +2,6 @@
 
 require_once '../../vendor/autoload.php';
 require_once '../config.php';
-require_once '../config.php';
 
 use Casbin\Enforcer;
 use CasbinAdapter\Medoo\Adapter as DatabaseAdapter;

+ 6 - 4
public/app/channal/card.php

@@ -1,5 +1,7 @@
 <?php
-//
+/*
+显示channel简介卡片
+*/
 
 require_once "../config.php";
 require_once "../public/_pdo.php";
@@ -10,16 +12,16 @@ require_once '../public/load_lang.php';
 if (isset($_GET["id"])) {
 	$output["id"]=$_GET["id"];
 	PDO_Connect( _FILE_DB_CHANNAL_);
-	$query = "SELECT name,create_time,owner,summary,lang FROM channal  WHERE id = ? ";
+	$query = "SELECT name,created_at,owner_uid ,summary,lang FROM "._TABLE_CHANNEL_."  WHERE uid = ? ";
 	$channel = PDO_FetchRow($query, array($_GET["id"]));
 	$strData="";
 	if ($channel) {
 		$_userinfo = new UserInfo();
-		$name = $_userinfo->getName($channel["owner"]);
+		$name = $_userinfo->getName($channel["owner_uid"]);
 
 		$strData .= "<div>{$_local->gui->name}:".$channel["name"]."</div>";
 		$strData .=  "<div>{$_local->gui->owner}:".$name["nickname"]."</div>";
-		$strData .=  "<div>{$_local->gui->created_time}:".date("Y/m/d",$channel["create_time"]/1000)."</div>";
+		$strData .=  "<div>{$_local->gui->created_time}:".$channel["created_at"]."</div>";
 		$strData .=  "<div>{$_local->gui->language}:".$channel["lang"]."</div>";
 		$strData .=  "<div>{$_local->gui->introduction}:".$channel["summary"]."</div>";
 	} else {

+ 2 - 3
public/app/channal/channal.js

@@ -118,18 +118,17 @@ function my_channal_list() {
 								html += "<div style='flex:1;'>";
 								html +=
 									"<a href='../channal/my_channal_edit.php?id=" +
-									iterator.id +
+									iterator.uid +
 									"'>✏️" +
 									gLocal.gui.edit +
 									"</a></div><div style='flex:1;'>";
-								html += " <a onclick=\"channel_share('" + iterator.id + "')\">🔑"+gLocal.gui.share_to+"</a>";
+								html += " <a onclick=\"channel_share('" + iterator.uid + "')\">🔑"+gLocal.gui.share_to+"</a>";
 								html += "</div>";
 
 								break;
 							default:
 								break;
 						}
-
 						html += "</div>";
 					}
 					$("#my_channal_list").html(html);

+ 10 - 10
public/app/channal/function.php

@@ -6,11 +6,11 @@ require_once "../db/table.php";
 class Channal extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_CHANNAL_, "channal", "", "",$redis);
+		parent::__construct(_FILE_DB_CHANNAL_, _TABLE_CHANNEL_, _DB_USERNAME_,_DB_PASSWORD_,$redis);
     }
 
     public function getChannal($id){
-        $query = "SELECT * FROM channal WHERE id= ? ";
+        $query = "SELECT * FROM ".$this->table." WHERE uid =? ";
         $stmt = $this->dbh->prepare($query);
         $stmt->execute(array($id));
         $channal = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -24,7 +24,7 @@ class Channal extends Table
 	public function getTitle($id)
 	{
 		if (isset($id)) {
-			$query = "SELECT name FROM channal  WHERE id = ? ";
+			$query = "SELECT name FROM ".$this->table."  WHERE  uid = ? ";
 			$stmt = $this->dbh->prepare($query);
 			$stmt->execute(array($id));
 			$channal = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -48,8 +48,8 @@ class Channal extends Table
 	}
 	public function getPower($id){
 		#查询用户对此channel是否有权限
-		if(isset($_COOKIE["userid"])){
-			$userId = $_COOKIE["userid"];
+		if(isset($_COOKIE["user_id"])){
+			$userId = $_COOKIE["user_id"];
 		}
 		else{
 			$userId='0';
@@ -61,12 +61,12 @@ class Channal extends Table
 			}
 		}
 		$channelPower = 0;
-		$query = "SELECT owner,status FROM channal WHERE id=? and status>0 ";
+		$query = "SELECT owner_uid,status FROM "._TABLE_CHANNEL_." WHERE uid=? and status>0 ";
 		$stmt = $this->dbh->prepare($query);
 		$stmt->execute(array($id));
 		$channel = $stmt->fetch(PDO::FETCH_ASSOC);
 		if($channel){
-			if(!isset($_COOKIE["userid"])  ){
+			if(!isset($_COOKIE["user_id"])  ){
 				#未登录用户
 				if($channel["status"]==30){
 					#全网公开有建议权限
@@ -78,7 +78,7 @@ class Channal extends Table
 				}
 				
 			}
-			if($channel["owner"]==$_COOKIE["userid"]){
+			if($channel["owner_uid"]==$_COOKIE["user_uid"]){
 				return 30;
 			}
 			else if($channel["status"]>=30){
@@ -87,12 +87,12 @@ class Channal extends Table
 			}
 		}
 		#查询共享权限,如果共享权限更大,覆盖上面的的
-		$sharePower = share_get_res_power($_COOKIE["userid"],$id);
+		$sharePower = share_get_res_power($_COOKIE["user_uid"],$id);
 		if($sharePower>$channelPower){
 			$channelPower=$sharePower;
 		}
 		if($this->redis){
-			$this->redis->hSet("power://channel/".$id,$_COOKIE["userid"],$channelPower);
+			$this->redis->hSet("power://channel/".$id,$_COOKIE["user_uid"],$channelPower);
 		}
 		
 		return $channelPower;

+ 10 - 7
public/app/channal/get.php

@@ -27,17 +27,18 @@ foreach ($my_group as $key => $value) {
 $channelList = array();
 
 //找自己的
-PDO_Connect(_FILE_DB_CHANNAL_);
-$query = "SELECT id,owner,name,status,lang FROM channal WHERE owner = ?  LIMIT 0,100";
-$Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
+PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT uid,owner_uid,name,status,lang FROM "._TABLE_CHANNEL_." WHERE owner_uid = ?  LIMIT 100";
+$Fetch_my = PDO_FetchAll($query,array($_COOKIE["user_uid"]));
 
+#去掉重复的
 foreach ($Fetch_my as $key => $value) {
 	# code...
-	$channelList[$value["id"]]=array("id"=>$value["id"],"owner"=>$value["owner"],"name"=>$value["name"],"power"=>30,"status"=>$value["status"],"lang"=>$value["lang"]);
+	$channelList[$value["uid"]]=array("uid"=>$value["uid"],"owner_uid"=>$value["owner_uid"],"name"=>$value["name"],"power"=>30,"status"=>$value["status"],"lang"=>$value["lang"]);
 }
 
 # 找协作的
-$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
+$coop_channal =  share_res_list_get($_COOKIE["user_uid"],2);
 foreach ($coop_channal as $key => $value) {
 	# return res_id,res_type,power res_title  res_owner_id
 	if(isset($channelList[$value["res_id"]])){
@@ -46,7 +47,7 @@ foreach ($coop_channal as $key => $value) {
 		}
 	}
 	else{
-		$channelList[$value["res_id"]]=array("id"=>$value["res_id"],"owner"=>$value["res_owner_id"],"name"=>$value["res_title"],"power"=>(int)$value["power"],"status"=>(int)$value["status"],"lang"=>(int)$value["lang"]);
+		$channelList[$value["res_id"]]=array("uid"=>$value["res_id"],"owner_uid"=>$value["res_owner_id"],"name"=>$value["res_title"],"power"=>(int)$value["power"],"status"=>(int)$value["status"],"lang"=>(int)$value["lang"]);
 	}
 }
 
@@ -56,11 +57,13 @@ $output = array();
 foreach ($channelList as $key => $value) {
     # code...
 	$new = $value;
-	$name = $_userinfo->getName($value["owner"]);	
+	$name = $_userinfo->getName($value["owner_uid"]);	
 	$new["username"] = $name["username"];
 	$new["nickname"] = $name["nickname"];	
 	$new["count"] = 0;
     $new["all"] = 1;
+    $new["owner"] = $value["owner_uid"];
+
     $output[]=$new;
 }
 

+ 9 - 7
public/app/channal/my_channal_get.php

@@ -1,5 +1,5 @@
 <?php
-//查询term字典
+//获取我的channel 列表,已经废弃
 
 require_once "../config.php";
 require_once "../public/_pdo.php";
@@ -9,12 +9,13 @@ require_once '../group/function.php';
 
 
 if(isset($_GET["id"])){
-    PDO_Connect(""._FILE_DB_CHANNAL_);
+    PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
     $id=$_GET["id"];
-    $query = "SELECT * FROM channal  WHERE id = ? ";
+    $query = "SELECT uid as id ,owner_uid as owner, name , summary , status , lang , create_time,modify_time  FROM "._TABLE_CHANNEL_."  WHERE uid=? ";
 	$Fetch = PDO_FetchRow($query,array($id));
 
-	#获取协作者
+	#TODO获取协作者
+	/*
 	if($Fetch){
 		$user_info = new UserInfo();
 		$group_info = new GroupInfo();
@@ -31,12 +32,13 @@ if(isset($_GET["id"])){
 		}
 		$Fetch["coop"]=$coop;
 	}
+	*/
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 }
 else{
-    PDO_Connect(""._FILE_DB_CHANNAL_);
-    $query = "SELECT * FROM channal  WHERE owner = ? ";
-    $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
+    PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid as id ,owner_uid as owner, name , summary , status , lang , create_time,modify_time FROM "._TABLE_CHANNEL_."  WHERE owner_uid = ? ";
+    $Fetch = PDO_FetchAll($query,array($_COOKIE["user_uid"]));
     echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
 }
 

+ 8 - 5
public/app/channal/my_channal_post.php

@@ -1,4 +1,7 @@
 <?php
+/*
+修改channel
+*/
 require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
@@ -8,7 +11,7 @@ require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 
 #先查询对此channal是否有权限修改
-PDO_Connect(_FILE_DB_CHANNAL_);
+PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
 $cooperation = 0;
 if(isset($_POST["id"])){
 	$redis = redis_connect();
@@ -30,9 +33,9 @@ if($channelPower<30){
 
 $channelOldInfo = $channel->getChannal($_POST["id"]);
 
-$query="UPDATE channal SET name = ? ,  summary = ?,  status = ? , lang = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
+$query="UPDATE "._TABLE_CHANNEL_." SET editor_id=?, name = ? ,  summary = ?,  status = ? , lang = ? , updated_at = now()  , modify_time= ?   where uid = ?  ";
 $sth = $PDO->prepare($query);
-$sth->execute(array($_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] ,  mTime() , mTime() , $_POST["id"]));
+$sth->execute(array($_COOKIE["user_id"],$_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] ,  mTime() , $_POST["id"]));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();
@@ -47,7 +50,7 @@ else{
 	}
     // 设置 句子库和逐词译库可见性
     PDO_Connect(_FILE_DB_SENTENCE_);
-    $query="UPDATE sentence SET language = ?  , status = ? where  channal = ?  ";
+    $query="UPDATE "._TABLE_SENTENCE_." SET language = ?  , status = ? where  channel_uid = ?  ";
     $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
     if (!$sth || ($sth && $sth->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
@@ -57,7 +60,7 @@ else{
 
 	// 设置 逐词译库可见性
 	PDO_Connect(_FILE_DB_USER_WBW_);
-	$query="UPDATE "._TABLE_USER_WBW_BLOCK_." SET lang = ?  , status = ? where  channal = ?  ";
+	$query="UPDATE "._TABLE_USER_WBW_BLOCK_." SET lang = ?  , status = ? where  channel_uid = ?  ";
 	$sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
 	if (!$sth || ($sth && $sth->errorCode() != 0)) {
 		$error = PDO_ErrorInfo();

+ 3 - 3
public/app/channal/my_channal_put.php

@@ -6,10 +6,10 @@ require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 if(isset($_COOKIE["userid"])){
-	PDO_Connect(_FILE_DB_CHANNAL_);
-	$query="INSERT INTO channal ( id,  owner  , name  , summary ,  status  , lang, create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ?  ) ";
+	PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+	$query="INSERT INTO "._TABLE_CHANNEL_." ( uid,  owner_uid  , editor_id, name  , summary ,  status  , lang, create_time , modify_time    )  VALUES  ( ?,? , ? , ? , ? , ? , ? , ? , ?  ) ";
 	$sth = $PDO->prepare($query);
-	$sth->execute(array(UUID::v4() , $_COOKIE["userid"] , $_POST["name"] , "" , $_POST["status"] ,$_POST["lang"]  ,  mTime() ,  mTime() , mTime() ));
+	$sth->execute(array(UUID::v4() , $_COOKIE["user_uid"] , $_COOKIE["user_id"] , $_POST["name"] , "" , $_POST["status"] ,$_POST["lang"]  ,  mTime() ,  mTime() ));
 	$respond=array("status"=>0,"message"=>"");
 	if (!$sth || ($sth && $sth->errorCode() != 0)) {
 		$error = PDO_ErrorInfo();

+ 2 - 2
public/app/collect/card.php

@@ -8,8 +8,8 @@ require_once '../ucenter/function.php';
 
 if (isset($_GET["id"])) {
 	$output["id"]=$_GET["id"];
-	PDO_Connect( _FILE_DB_USER_ARTICLE_);
-	$query = "SELECT title,create_time,owner,summary FROM collect  WHERE id = ? ";
+	PDO_Connect( _FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
+	$query = "SELECT title,create_time,owner,summary FROM "._TABLE_COLLECTION_."  WHERE uid = ? ";
 	$result = PDO_FetchRow($query, array($_GET["id"]));
 	$strData="";
 	if ($result) {

+ 33 - 19
public/app/collect/function.php

@@ -11,8 +11,8 @@ class CollectInfo
 	private $_redis;
 	private $errorMsg;
     public function __construct($redis=false) {
-        $dns = ""._FILE_DB_USER_ARTICLE_;
-        $this->dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $dns = _FILE_DB_USER_ARTICLE_;
+        $this->dbh = new PDO($dns, _DB_USERNAME_,_DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 		$this->_redis=$redis;
         $buffer = array();
@@ -30,7 +30,7 @@ class CollectInfo
             return $buffer[$id];
         }
         if($this->dbh){
-            $query = "SELECT id,title,owner,status,lang,article_list FROM collect WHERE id= ?";
+            $query = "SELECT uid as id,title,owner,status,lang,article_list FROM "._TABLE_COLLECTION_." WHERE uid= ?";
             $stmt = $this->dbh->prepare($query);
             $stmt->execute(array($id));
 			$collect = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@ class CollectInfo
             return array();
         }
         if($this->dbh){
-            $query = "SELECT article_id FROM article_list WHERE collect_id= ? limit 0,1000";
+            $query = "SELECT article_id FROM "._TABLE_ARTICLE_COLLECTION_." WHERE collect_id= ? limit 1000";
             $stmt = $this->dbh->prepare($query);
             $stmt->execute(array($id));
 			$article_list = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -72,39 +72,41 @@ class CollectInfo
 
 	public function getPower($id){
 		#查询用户对此是否有权限	
-		if(isset($_COOKIE["userid"])){
-			$userId = $_COOKIE["userid"];
+		if(isset($_COOKIE["user_uid"])){
+			$userId = $_COOKIE["user_uid"];
 		}
 		else{
 			$userId='0';
 		}
+		/*
 		if($this->_redis!==false){
 			$power = $this->_redis->hGet("power://collection/".$id,$userId);
 			if($power!==FALSE){
 				return $power;
 			}
 		}
+		*/
 		$iPower = 0;
-		$query = "SELECT owner,status FROM collect WHERE id=?  ";
+		$query = "SELECT owner,status FROM "._TABLE_COLLECTION_." WHERE uid=?  ";
 		$stmt = $this->dbh->prepare($query);
 		$stmt->execute(array($id));
 		$result = $stmt->fetch(PDO::FETCH_ASSOC);
 		if($result){
-			if(!isset($_COOKIE["userid"])){
+			if(!isset($_COOKIE["user_uid"])){
 				#未登录用户
 				if($result["status"]==30){
 					#全网公开有读取和建议权限
-					return 10;
+					$iPower =  10;
 				}
 				else{
 					#其他状态没有任何权限
-					return 0;
+					$iPower =  0;
 				}
 			}
 			else{
-				if($result["owner"]==$_COOKIE["userid"]){
+				if($result["owner"]==$_COOKIE["user_uid"]){
 					#自己的
-					return 30;
+					$iPower =  30;
 				}
 				else if($result["status"]>=30){
 					#全网公开的 可以提交pr
@@ -128,15 +130,15 @@ class CollectInfo
 	
 		if (count($arrData) > 0) {
 			$this->dbh->beginTransaction();
-			$query="UPDATE collect SET title = ? , 
+			$query="UPDATE "._TABLE_COLLECTION_." SET title = ? , 
 									   subtitle = ? , 
 									   summary = ?, 
 									   article_list = ?  ,  
 									   status = ? , 
 									   lang = ? , 
-									   receive_time= ?  , 
+									   updated_at= now()  , 
 									   modify_time= ?   
-									   where  id = ?  ";
+									   where  uid = ?  ";
 			$sth = $this->dbh->prepare($query);
 			foreach ($arrData as $data) {
 				$sth->execute(array(
@@ -146,7 +148,6 @@ class CollectInfo
 									$data["article_list"] , 
 									$data["status"] , 
 									$data["lang"] ,  
-									$data["receive_time"] , 
 									$data["modify_time"] , 
 									$data["id"])
 								);
@@ -182,7 +183,7 @@ class CollectInfo
 		$respond=array("status"=>0,"message"=>"");
 		if (count($arrData) > 0) {
 			$this->dbh->beginTransaction();
-			$query="INSERT INTO collect ( id,  title  , subtitle  , summary , article_list , owner, lang  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ?  , ? , ? , ? , ? , ? , ? , ? ) ";
+			$query="INSERT INTO "._TABLE_COLLECTION_." ( uid,  title  , subtitle  , summary , article_list , owner, lang  , status  , create_time , modify_time    )  VALUES  (  ? , ? , ?  , ? , ? , ? , ? , ? , ? , ? ) ";
 			$sth = $this->dbh->prepare($query);
 			$newDataList=array();
 			foreach ($arrData as $data) {
@@ -217,7 +218,7 @@ class CollectInfo
 						$newData["owner"]=$data["owner"];
 					}
 					else{
-						$newData["owner"]=$_COOKIE["userid"];
+						$newData["owner"]=$_COOKIE["user_uid"];
 					}	
 					if(isset($data["lang"])){
 						$newData["lang"]=$data["lang"];
@@ -244,7 +245,20 @@ class CollectInfo
 						$newData["modify_time"]=mTime();
 					}
 					$newDataList[]=$newData;
-					$sth->execute(array($newData["id"] , $newData["title"] , $newData["subtitle"] ,$newData["summary"], $newData["article_list"] , $newData["owner"] , $newData["lang"] , $newData["status"] , $newData["create_time"] ,  $newData["modify_time"] , mTime() ));				
+					$sth->execute(
+							array(
+								$newData["id"] , 
+								$newData["title"] , 
+								$newData["subtitle"] ,
+								$newData["summary"], 
+								$newData["article_list"] , 
+								$newData["owner"] , 
+								$newData["lang"] , 
+								$newData["status"] , 
+								$newData["create_time"] ,  
+								$newData["modify_time"] 
+								)
+							);				
 				}
 				else{
 					$this->errorMsg="标题不能为空";

+ 4 - 4
public/app/collect/list.php

@@ -23,8 +23,8 @@ require_once '../ucenter/function.php';
     else{
         $begin = 0;
     }
-    PDO_Connect(_FILE_DB_USER_ARTICLE_);
-    $query = "SELECT * FROM collect  where  status>=30 ";
+    PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid as id,title,subtitle,summary,owner,article_list FROM "._TABLE_COLLECTION_."  where  status>=30 ";
     if(isset($_GET["orderby"])){
         switch ($_GET["orderby"]) {
             case 'like':
@@ -40,8 +40,8 @@ require_once '../ucenter/function.php';
     else{
         $query .="ORDER BY modify_time DESC";
     }
-    $query .=" LIMIT ? , ? ";
-    $Fetch = PDO_FetchAll($query,array($begin,$onepage));
+    $query .=" LIMIT ? OFFSET ? ";
+    $Fetch = PDO_FetchAll($query,array($onepage,$begin));
     foreach ($Fetch as $key => $value) {
         # code...
         $userinfo = new UserInfo();

+ 18 - 2
public/app/commit/commit.php

@@ -37,10 +37,26 @@ if($destChannelPower<10){
 	exit;		
 }
 
-$db_trans_sent = new PDO(_FILE_DB_SENTENCE_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$db_trans_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $db_trans_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-$query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND channal = ?  ";
+$query = "SELECT uid as id,
+parent_uid as parent,
+block_uid as block_id,
+channel_uid as channal,
+book_id as book,
+paragraph,
+word_start as begin,
+word_end as end,
+author,
+editor_uid as editor,
+content as text,
+language,
+version as ver,
+status,
+strlen,
+modify_time,
+create_time FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND channel_uid = ?  ";
 $stmt = $db_trans_sent->prepare($query);
 
 if($stmt){

+ 5 - 0
public/app/config.sample.php

@@ -36,6 +36,11 @@ define("Database",[
 ]);
 
 
+# 雪花id
+define("SnowFlake",[
+	"DatacenterId"=>1,
+	"WorkerId"=>1
+]);
 /*
 Redis 设置,
 */

+ 5 - 11
public/app/db/channel.php

@@ -1,21 +1,15 @@
 <?php
+/*
+废弃
+*/
 require_once "../config.php";
 require_once "../db/table.php";
 require_once "../public/function.php";
-/*
-CREATE TABLE likes (
-    id            INTEGER      PRIMARY KEY AUTOINCREMENT,
-    like_type     VARCHAR (16) NOT NULL,
-    resource_type VARCHAR (32) NOT NULL,
-    resource_id   CHAR (36)    NOT NULL,
-    user_id       INTEGER      NOT NULL,
-    created_at    TIMESTAMP DEFAULT CURRENT_TIMESTAMP     NOT NULL //只做初始化,更新时不自动更新
-);
-*/
+
 class Channel extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_CHANNAL_, "channal", "", "",$redis);
+		parent::__construct(_FILE_DB_CHANNAL_, _TABLE_CHANNEL_, _DB_USERNAME_,_DB_PASSWORD_,$redis);
     }
 
 	public function  index(){

+ 2 - 1
public/app/db/database.php

@@ -6,7 +6,7 @@
 class Database
 {
     // specify your own database credentials
-    private $host = '127.0.0.1';
+    private $host = 'localhost';
     private $db_name = 'mint';
     private $username = 'postgras';
     private $password = '123456';
@@ -22,6 +22,7 @@ class Database
             'driver' => 'pgsql',
             'host' => $this->host,
             'database' => $this->db_name,
+            'port' => 5432,
             'username' => $this->username,
             'password' => $this->password,
             'charset' => 'utf8',

+ 5 - 3
public/app/db/test.php

@@ -1,6 +1,6 @@
 <?php
-require "../vendor/autoload.php";
-require "../config/database.php";
+require_once '../../vendor/autoload.php';
+require "./database.php";
 use Illuminate\Database\Capsule\Manager as Capsule;
 
 $dbclass = new Database();
@@ -13,4 +13,6 @@ $capsule->setAsGlobal();
 $capsule->bootEloquent();
 
 
-$users = Capsule::table('user')->where('id', '=', 1)->get();
+$users = Capsule::table('wbw_blocks')->where('id', '=', 129195)->get();
+
+var_dump($users);

+ 5 - 5
public/app/db/wbw_block.php

@@ -6,22 +6,22 @@ require_once "../channal/function.php";
 class WbwBlock extends Table
 {
     function __construct($redis=false) {
-		parent::__construct(_FILE_DB_USER_WBW_, _TABLE_USER_WBW_BLOCK_, "", "",$redis);
+		parent::__construct(_FILE_DB_USER_WBW_, _TABLE_USER_WBW_BLOCK_, _DB_USERNAME_, _DB_PASSWORD_,$redis);
     }
 
 	public function getPower($blockId){
 		$channelInfo = new Channal($this->redis);
 		$power = 0;
-		$query = "SELECT channal,owner from "._TABLE_USER_WBW_BLOCK_."   where id= ?  ";
+		$query = "SELECT channel_uid , creator_uid  from "._TABLE_USER_WBW_BLOCK_."   where uid= ?  ";
 		$row = $this->fetch($query,array($blockId));
 		if($row ){
-			if(empty($row["channal"])){
-				if($row["owner"]==$_COOKIE["userid"]){
+			if(empty($row["channel_uid"])){
+				if($row["creator_uid"]==$_COOKIE["userid"]){
 					$power = 30;
 				}
 			}
 			else{
-				$power = $channelInfo->getPower($row["channal"]);
+				$power = $channelInfo->getPower($row["channel_uid"]);
 			}
 		}
 		return $power;

+ 16 - 12
public/app/dict/dict_lookup.php

@@ -106,7 +106,7 @@ $right_word_list = "";
 				}
 
 				
-                $query = "SELECT dict.id,dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
+                $query = "SELECT dict.id,dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 30";
                 $Fetch = PDO_FetchAll($query, array($x));
                 $iFetch = count($Fetch);
                 $count_return += $iFetch;
@@ -337,6 +337,7 @@ function lookup_user($word){
 
 	$output ="";
 	$Fetch=array();
+	
 	if($redis){
 		$wordData = $redis->hGet("dict://user",$word);
 			if($wordData){
@@ -347,7 +348,7 @@ function lookup_user($word){
 						$Fetch[] = array("id"=>$one[0],
 										"pali"=>$one[1],
 										"type"=>$one[2],
-										"gramma"=>$one[3],
+										"grammar"=>$one[3],
 										"parent"=>$one[4],
 										"mean"=>$one[5],
 										"note"=>$one[6],
@@ -355,8 +356,8 @@ function lookup_user($word){
 										"factormean"=>$one[8],
 										"status"=>$one[9],
 										"confidence"=>$one[10],
-										"creator"=>$one[11],
-										"dict_name"=>$one[12],
+										"creator_id"=>$one[11],
+										"source"=>$one[12],
 										"lang"=>$one[13],
 										);
 					}						
@@ -366,9 +367,10 @@ function lookup_user($word){
 				#  没找到就不找了
 			}
 	}
-	else{
-		PDO_Connect("" . _FILE_DB_WBW_);
-		$query = "SELECT *  from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
+	else
+	{
+		PDO_Connect(_FILE_DB_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
+		$query = "SELECT *  from " . _TABLE_DICT_WBW_ . " where word = ? and source='_SYS_USER_WBW_' limit 100";
 		$Fetch = PDO_FetchAll($query, array($word));
 	}
 	
@@ -378,12 +380,12 @@ function lookup_user($word){
 		$count_return++;
 		$userlist = array();
 		foreach ($Fetch as $value) {
-			if (isset($userlist[$value["creator"]])) {
-				$userlist[$value["creator"]] += 1;
+			if (isset($userlist[$value["creator_id"]])) {
+				$userlist[$value["creator_id"]] += 1;
 			} else {
-				$userlist[$value["creator"]] = 1;
+				$userlist[$value["creator_id"]] = 1;
 			}
-			$userwordcase = $value["type"] . "#" . $value["gramma"];
+			$userwordcase = $value["type"] . "#" . $value["grammar"];
 			$parent = $value["parent"];
 			if(empty($parent)){
 				$parent = "_null_";
@@ -508,7 +510,9 @@ function lookup_term($word){
 			}
 	}
 	else{
-		PDO_Connect("" . _FILE_DB_WBW_);
+		exit;
+		#TODO 查询term 表
+		PDO_Connect(_FILE_DB_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 		$query = "SELECT *  from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
 		$Fetch = PDO_FetchAll($query, array($word));
 	}

+ 11 - 10
public/app/dict/redis_import_user.php

@@ -6,37 +6,38 @@ $rediskey = "dict://user";
 if (PHP_SAPI == "cli") {
 	$redis = redis_connect();
 	if ($redis != false) {
-		$dbh = new PDO(_FILE_DB_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true));
+		$dbh = new PDO(_FILE_DB_WBW_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 		$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-		$query = "SELECT pali from dict where pali !='' group by pali";
+		$query = "SELECT word from "._TABLE_DICT_WBW_." group by word";
 		$stmtPli = $dbh->query($query);
 		while ($word = $stmtPli->fetch(PDO::FETCH_ASSOC)) {
 			# code...
-			$query = "SELECT * from dict where pali = ? ";
+			$query = "SELECT * from "._TABLE_DICT_WBW_." where word = ? and source = '_USER_DATA_' ";
 			$stmt = $dbh->prepare($query);
-			$stmt->execute(array($word["pali"]));
+			$stmt->execute(array($word["word"]));
 			if ($stmt) {
 				$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
 				$redisWord=array();
 				foreach ($Fetch as  $one) {
 					# code...
-					$redisWord[] = array($one["id"],
-										$one["pali"],
+					$redisWord[] = array(
+									$one["id"],
+									$one["word"],
 									$one["type"],
 									$one["gramma"],
-									$one["parent"],
+									$one["base"],
 									$one["mean"],
 									$one["note"],
 									$one["factors"],
 									$one["factormean"],
 									$one["status"],
 									$one["confidence"],
-									$one["creator"],
-									$one["dict_name"],
+									$one["creator_id"],
+									$one["source"],
 									$one["language"]
 									);
 				}
-				$redis->hSet($rediskey,$word["pali"],json_encode($redisWord,JSON_UNESCAPED_UNICODE));
+				$redis->hSet($rediskey,$word["word"],json_encode($redisWord,JSON_UNESCAPED_UNICODE));
 			}
 		}
 	}

+ 4 - 4
public/app/dict/redis_pali_word_statistic.php

@@ -103,20 +103,20 @@ if (PHP_SAPI == "cli") {
 
 				break;
 			case 'update':
-				$dbh = new PDO(_FILE_DB_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true,PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY));
+				$dbh = new PDO(_FILE_DB_WBW_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true,PDO::SQLITE_ATTR_OPEN_FLAGS => PDO::SQLITE_OPEN_READONLY));
 				$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 				
-				$query = "SELECT pali from dict where 1  group by pali";
+				$query = "SELECT word from "._TABLE_DICT_WBW_."  group by word";
 				$stmt = $dbh->prepare($query);
 				$stmt->execute();
 				$count = 0;
 				while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
 					# code...
-					$word = $redis->hGet($strKey, $row["pali"]);
+					$word = $redis->hGet($strKey, $row["word"]);
 					if($word){
 						$eWord = json_decode($word,true);
 						$eWord["user"]=1;
-						$redis->hSet($strKey, $row["pali"],json_encode($eWord,JSON_UNESCAPED_UNICODE));
+						$redis->hSet($strKey, $row["word"],json_encode($eWord,JSON_UNESCAPED_UNICODE));
 						$count++;
 					}
 				}		

+ 13 - 10
public/app/doc/edit_wbw.php

@@ -40,15 +40,15 @@ echo "</fieldset>";
 echo "<fieldset>";
 echo "<legend>{$_local->gui->channel} ({$_local->gui->required})</legend>";
 echo "<div>";
-PDO_Connect(""._FILE_DB_CHANNAL_);
-$query = "SELECT * from channal where owner = ?   limit 0,100";
-$Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
+PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT * from "._TABLE_CHANNEL_." where owner_uid = ?   limit 100";
+$Fetch = PDO_FetchAll($query,array($_COOKIE["user_uid"]));
 $i=0;
 foreach($Fetch as $row){
     echo '<div class="file_list_row" style="padding:5px;">';
 
     echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-    echo '<input name="channal" value="'.$row["id"].'" ';
+    echo '<input name="channal" value="'.$row["uid"].'" ';
     if($i==0){
         echo "checked";
     }
@@ -59,8 +59,9 @@ foreach($Fetch as $row){
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
     // 查询逐词解析库
     PDO_Connect(_FILE_DB_USER_WBW_);
-    $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
-    $FetchWBW = PDO_FetchOne($query);
+	#TODO $strQueryParaList 改为预处理
+    $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channel_uid = ? and book_id=? and paragraph in {$strQueryParaList}  limit 100";
+    $FetchWBW = PDO_FetchOne($query,array($row["uid"],$book));
     echo '</div>';
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
     if($FetchWBW==0){
@@ -69,14 +70,16 @@ foreach($Fetch as $row){
     }
     else{
         echo $FetchWBW.$_local->gui->para;
-        echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+        echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["uid"]}'>open</a>";
     }
     echo '</div>';
 
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-    PDO_Connect(""._FILE_DB_SENTENCE_);
-    $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
-    $FetchWBW = PDO_FetchOne($query);
+    PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
+	#TODO $strQueryParaList 改为预处理
+
+    $query = "SELECT count(*) from "._TABLE_SENTENCE_." where channel_uid = ? and book_id= ? and paragraph in {$strQueryParaList}  limit 100";
+    $FetchWBW = PDO_FetchOne($query,array($row["uid"],$book));
     echo '</div>';
     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
     if($FetchWBW==0){

+ 31 - 90
public/app/doc/fork.php

@@ -42,15 +42,15 @@ if (isset($_GET["channel"]) == false) {
     echo "<h2>选择一个空白的版风存储新的文档</h2>";
     echo "<form action='fork.php' method='get'>";
     echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
-    PDO_Connect("" . _FILE_DB_CHANNAL_);
-    $query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
-    $Fetch = PDO_FetchAll($query);
+    PDO_Connect( _FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid,name,lang,status,create_time from "._TABLE_CHANNEL_." where owner_uid = ?   limit 100";
+    $Fetch = PDO_FetchAll($query,$_COOKIE["user_uid"]);
     $i = 0;
     foreach ($Fetch as $row) {
         echo '<div class="file_list_row" style="padding:5px;display:flex;">';
 
         echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-        echo '<input name="channel" value="' . $row["id"] . '" ';
+        echo '<input name="channel" value="' . $row["uid"] . '" ';
         if ($i == 0) {
             echo "checked";
         }
@@ -60,7 +60,7 @@ if (isset($_GET["channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
         PDO_Connect(_FILE_DB_USER_WBW_);
-        $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channel_uid = '{$row["uid"]}' and book_id='{$mbook}' and paragraph in ({$paragraph})  limit 100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -68,14 +68,14 @@ if (isset($_GET["channel"]) == false) {
             echo $_local->gui->blank;
         } else {
             echo $FetchWBW . $_local->gui->para;
-            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["uid"]}'>open</a>";
         }
         echo '</div>';
 
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        PDO_Connect(_FILE_DB_SENTENCE_);
-        $query = "SELECT count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-        $FetchWBW = PDO_FetchOne($query);
+        PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_,_DB_PASSWORD_);
+        $query = "SELECT count(*) from "._TABLE_SENTENCE_." where channel_uid = ? and book_id=? and paragraph in ({$paragraph})  limit 1000";
+        $FetchWBW = PDO_FetchOne($query,array($row["uid"],$mbook));
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
         if ($FetchWBW == 0) {
@@ -99,7 +99,7 @@ if (isset($_GET["channel"]) == false) {
 
 //if(isset($_GET["doc_id"]))
 {
-    PDO_Connect("" . _FILE_DB_FILEINDEX_);
+    PDO_Connect( _FILE_DB_FILEINDEX_,_DB_USERNAME_,_DB_PASSWORD_);
     $doc_id = $_GET["doc_id"];
     $query = "SELECT * from fileindex where id= ? ";
     $Fetch = PDO_FetchAll($query, array($doc_id));
@@ -144,13 +144,13 @@ if (isset($_GET["channel"]) == false) {
                     //$dest=$dir_user_base.$userid.$dir_mydocument.$filename;
                     //复制数据
                     //打开逐词解析数据库
-                    $dns = "" . _FILE_DB_USER_WBW_;
-                    $dbhWBW = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+                    $dns = _FILE_DB_USER_WBW_;
+                    $dbhWBW = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
                     $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
                     //打开译文数据库
-                    $dns = "" . _FILE_DB_SENTENCE_;
-                    $dbhSent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+                    $dns = _FILE_DB_SENTENCE_;
+                    $dbhSent = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
                     $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
                     //逐词解析新数据数组
@@ -173,7 +173,7 @@ if (isset($_GET["channel"]) == false) {
                             case 2:
                                 //译文
                                 $blockid = $blocks[$i]->block_id;
-                                $query = "select * from sent_block where id= ? ";
+                                $query = "SELECT * from "._TABLE_SENTENCE_BLOCK_." where uid= ? ";
                                 $stmt = $dbhSent->prepare($query);
                                 $stmt->execute(array($blockid));
                                 $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -198,31 +198,6 @@ if (isset($_GET["channel"]) == false) {
                                         ));
                                 }
 
-                                $query = "select * from sentence where block_id= ? ";
-                                $stmtSent = $dbhSent->prepare($query);
-                                $stmtSent->execute(array($fBlock[0]["id"]));
-                                $fBlockData = $stmtSent->fetchAll(PDO::FETCH_ASSOC);
-                                foreach ($fBlockData as $value) {
-                                    array_push($arrSentNewBlockData,
-                                        array(UUID::V4(),
-                                            $arrSentBlockTransform[$value["block_id"]],
-                                            $value["book"],
-                                            $value["paragraph"],
-                                            $value["begin"],
-                                            $value["end"],
-                                            $value["channal"],
-                                            $value["tag"],
-                                            $value["author"],
-                                            $_COOKIE["userid"],
-                                            $value["text"],
-                                            $value["language"],
-                                            $value["ver"],
-                                            $value["status"],
-                                            mTime(),
-                                            mTime(),
-                                        ));
-
-                                }
 
                                 break;
                             case 3:
@@ -234,7 +209,7 @@ if (isset($_GET["channel"]) == false) {
                             case 6:
                                 #逐词解析
                                 $blockid = $blocks[$i]->block_id;
-                                $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id= ? ";
+                                $query = "SELECT uid,book_id,paragraph,style,lang,status from "._TABLE_USER_WBW_BLOCK_." where uid= ? ";
                                 $stmt = $dbhWBW->prepare($query);
                                 $stmt->execute(array($blockid));
                                 $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -244,16 +219,15 @@ if (isset($_GET["channel"]) == false) {
                                 if (count($fBlock) > 0) {
                                     array_push($arrNewBlock,
                                         array($newBlockId,
-                                            $fBlock[0]["id"],
+                                            $fBlock[0]["uid"],
                                             $_GET["channel"],
                                             $_COOKIE["userid"],
-                                            $fBlock[0]["book"],
+                                            $fBlock[0]["book_id"],
                                             $fBlock[0]["paragraph"],
                                             $fBlock[0]["style"],
                                             $fBlock[0]["lang"],
                                             $fBlock[0]["status"],
-                                            mTime(),
-                                            mTime(),
+                                            mTime()
                                         ));
                                 }
 
@@ -288,7 +262,18 @@ if (isset($_GET["channel"]) == false) {
 
                     if (count($arrNewBlock) > 0) {
                         $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ( uid ,
+                                                                           parent_id ,
+                                                                           channel_uid ,
+                                                                           creator_uid ,
+                                                                           book_id ,
+                                                                           paragraph ,
+                                                                           style ,
+                                                                           lang ,
+                                                                           status ,
+                                                                           modify_time ,
+                                                                           updated_at)
+                                                                           VALUES (?,?,?,?,?,?,?,?,?,?,now())";
                         $stmtNewBlock = $dbhWBW->prepare($query);
                         foreach ($arrNewBlock as $oneParam) {
                             $stmtNewBlock->execute($oneParam);
@@ -327,50 +312,6 @@ if (isset($_GET["channel"]) == false) {
 
                     //不复刻译文
 
-                    //译文 block数据块
-                    /*
-                    if(count($arrSentNewBlock)>0){
-                    $dbhSent->beginTransaction();
-                    $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
-                    $stmtSentNewBlock = $dbhSent->prepare($query);
-                    foreach($arrSentNewBlock as $oneParam){
-                    //print_r($oneParam);
-                    $stmtSentNewBlock->execute($oneParam);
-                    }
-                    // 提交更改
-                    $dbhSent->commit();
-                    if (!$stmtSentNewBlock || ($stmtSentNewBlock && $stmtSentNewBlock->errorCode() != 0)) {
-                    $error = $dbhSent->errorInfo();
-                    echo "error - $error[2] <br>";
-                    }
-                    else{
-                    //译文 block块复刻成功
-                    $count=count($arrNewBlock);
-                    echo "wbw block $count recorders.<br/>";
-                    }
-                    }
-
-                    if(count($arrSentNewBlockData)>0){
-                    // 开始一个事务,逐词解析数据 关闭自动提交
-                    $dbhSent->beginTransaction();
-                    $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','channal','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
-                    $stmtSentData = $dbhSent->prepare($query);
-                    foreach($arrSentNewBlockData as $oneParam){
-                    $stmtSentData->execute($oneParam);
-                    }
-                    // 提交更改
-                    $dbhSent->commit();
-                    if (!$stmtSentData || ($stmtSentData && $stmtSentData->errorCode() != 0)) {
-                    $error = $dbhSent->errorInfo();
-                    echo "error - $error[2] <br>";
-                    }
-                    else{
-                    //译文 数据 复刻成功
-                    $count=count($arrSentNewBlockData);
-                    echo "new translation $count recorders.";
-                    }
-                    }
-                     */
 
                     //插入记录到文件索引
                     $filesize = 0;

+ 165 - 165
public/app/doc/fork_channel.php

@@ -1,9 +1,13 @@
 <?php
 
-/*拷贝其他人的文件
- *
- *
- */
+/*
+*拷贝其他人的逐词解析数据
+ *输入参数
+ *src_channel
+ *dest_channel
+ *bookid
+ *paragraph
+*/
 require_once '../studio/index_head.php';
 ?>
 <body id="file_list_body" >
@@ -52,16 +56,16 @@ if (isset($_GET["dest_channel"]) == false) {
     echo "<input type='hidden' name='book' value='{$_GET["book"]}' />";
     echo "<input type='hidden' name='para' value='{$_GET["para"]}' />";
     echo "<input type='hidden' name='src_channel' value='{$_GET["src_channel"]}' />";
-    PDO_Connect(_FILE_DB_CHANNAL_);
-    $query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+    PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid,name,lang,status,create_time from "._TABLE_CHANNEL_." where owner_uid = '{$_COOKIE["user_uid"]}'   limit 100";
     $Fetch = PDO_FetchAll($query);
     $i = 0;
-    PDO_Connect( _FILE_DB_USER_WBW_);	
+    PDO_Connect( _FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);	
     foreach ($Fetch as $row) {
         echo '<div class="file_list_row" style="padding:5px;display:flex;">';
 
         echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-        echo '<input name="dest_channel" value="' . $row["id"] . '" ';
+        echo '<input name="dest_channel" value="' . $row["uid"] . '" ';
         if ($i == 0) {
             echo "checked";
         }
@@ -70,7 +74,7 @@ if (isset($_GET["dest_channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channel_uid = '{$row["uid"]}' and book_id = '{$mbook}' and paragraph in ({$paragraph})  limit 100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -78,7 +82,7 @@ if (isset($_GET["dest_channel"]) == false) {
             echo $_local->gui->blank;
         } else {
             echo $FetchWBW . $_local->gui->para;
-            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+            echo "<a href='../studio/editor.php?op=openchannal&book={$mbook}&para={$paragraph}&channal={$row["uid"]}'>open</a>";
         }
         echo '</div>';
 
@@ -94,184 +98,180 @@ if (isset($_GET["dest_channel"]) == false) {
     exit;
 }
 
-PDO_Connect( _FILE_DB_USER_WBW_);	
+PDO_Connect( _FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);	
 
 $channelInfo= new Channal($redis);
 
 $srcPower = (int)$channelInfo->getPower($_GET["src_channel"]);
-
 {
 
-	{
-
         if ($srcPower == 30) {
             //自己的文档
             echo "这是自己的文档,不能复刻。";
         } else {
             //别人的文档
-            //查询以前自己是否曾经复刻
-            $query = "SELECT * from "._TABLE_USER_WBW_BLOCK_." where parent_channel=? and owner=? ";
-            $FetchSelf = PDO_FetchAll($query,array($_GET["src_channel"],$_COOKIE["userid"]));
-            $iFetchSelf = count($FetchSelf);
-            if ($iFetchSelf > 0) {
-                //以前打开过
-                echo "文档已经复刻";
-                echo "正在<a href='../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$FetchSelf[0]["channal"]}'>打开</a>文档";
-                echo "<script>";
-                echo "window.location.assign(\"../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$FetchSelf[0]["channal"]}\");";
-                echo "</script>";
-            } else {
+			{
                 //以前没打开过
-                echo "<h3>共享的文档,正在fork...</h3>";
-                echo "<div style='display:none;'>";
-
-				{
-                    //复制数据
-                    //打开逐词解析数据库
-                    $dns = _FILE_DB_USER_WBW_;
-                    $dbhWBW = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
-                    $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+			echo "<h3>共享的文档,正在fork...</h3>";
+			echo "<div style='display:none;'>";
 
-                    //逐词解析新数据数组
-                    $arrNewBlock = array();
-                    $arrNewBlockData = array();
-                    $arrBlockTransform = array();
+		
+			//复制数据
+			//打开逐词解析数据库
+			$dns = _FILE_DB_USER_WBW_;
+			$dbhWBW = new PDO($dns,_DB_USERNAME_,_DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
+			$dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-                    $blocks = $_para;
-                    for ($i = 0; $i < count($blocks); $i++) {
-						$query = "SELECT id from "._TABLE_USER_WBW_BLOCK_." where book= ? and paragraph = ? and channal = ? ";
-						$stmt = $dbhWBW->prepare($query);
-						$stmt->execute(array($_GET["book"],$iPara,$_GET["dest_channel"]));
-						$fDest = $stmt->fetch(PDO::FETCH_ASSOC);
-						if($fDest){
-							#旧的逐词解析数据块wbw_block id 
-							$destId = $fDest["id"];
-						}
-						#逐词解析
-						$iPara = $blocks[$i];
-						$query = "SELECT * from "._TABLE_USER_WBW_BLOCK_." where book= ? and paragraph = ? and channal = ? ";
-						$stmt = $dbhWBW->prepare($query);
-						$stmt->execute(array($_GET["book"],$iPara,$_GET["src_channel"]));
-						$fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
-						if(isset($destId)){
-							$newBlockId = $destId;
-						}
-						else{
-							$newBlockId = UUID::V4();
-						}
-						$arrBlockTransform[$fBlock[0]["id"]] = $newBlockId;
-						if (count($fBlock) > 0) {
-							array_push($arrNewBlock,
-								array($newBlockId,
-									"",
-									$_GET["dest_channel"],
-									$_GET["src_channel"],
-									$_COOKIE["userid"],
-									$fBlock[0]["book"],
-									$fBlock[0]["paragraph"],
-									$fBlock[0]["style"],
-									$fBlock[0]["lang"],
-									$fBlock[0]["status"],
-									mTime(),
-									mTime(),
-									mTime()
-								));
-						}
+			//逐词解析新数据数组
+			$arrNewBlock = array();
+			$arrNewBlockData = array();
+			$arrBlockTransform = array();
 
-						$query = "SELECT * from "._TABLE_USER_WBW_." where block_id= ? ";
-						$stmtWBW = $dbhWBW->prepare($query);
-						$stmtWBW->execute(array($fBlock[0]["id"]));
-						$fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
-						foreach ($fBlockData as $value) {
-							array_push($arrNewBlockData,
-								array(UUID::V4(),
-									$arrBlockTransform[$value["block_id"]],
-									$value["book"],
-									$value["paragraph"],
-									$value["wid"],
-									$value["word"],
-									$value["data"],
-									mTime(),
-									mTime(),
-									$value["status"],
-									$_COOKIE["userid"],
-								));
+			$blocks = $_para;
+			for ($i = 0; $i < count($blocks); $i++) {
+				#查找是否有旧的wbw_block数据
+				$query = "SELECT uid from "._TABLE_USER_WBW_BLOCK_." where book_id= ? and paragraph = ? and channel_uid = ? ";
+				$stmt = $dbhWBW->prepare($query);
+				$stmt->execute(array($_GET["book"],$blocks[$i],$_GET["dest_channel"]));
+				$fDest = $stmt->fetch(PDO::FETCH_ASSOC);
+				if($fDest){
+					#旧的逐词解析数据块wbw_block id 
+					$destId = $fDest["uid"];
+				}
+				#复制源wbw_block
+				$iPara = $blocks[$i];
+				$query = "SELECT uid,book_id,paragraph,style,lang,status from "._TABLE_USER_WBW_BLOCK_." where book_id= ? and paragraph = ? and channel_uid = ? ";
+				$stmt = $dbhWBW->prepare($query);
+				$stmt->execute(array($_GET["book"],$iPara,$_GET["src_channel"]));
+				$fSrcBlock = $stmt->fetch(PDO::FETCH_ASSOC);
+				if(isset($destId)){
+					#有旧的wbw_block uuid 使用旧的uuid
+					$newBlockId = $destId;
+				}
+				else{
+					$newBlockId = UUID::V4();
+				}
+				
+				if ($fSrcBlock) {
+					$arrBlockTransform[$fSrcBlock["uid"]] = $newBlockId;
+					array_push($arrNewBlock,
+						array($newBlockId,
+							"",
+							$_GET["dest_channel"],
+							$_GET["src_channel"],
+							$_COOKIE["userid"],
+							$fSrcBlock["book_id"],
+							$fSrcBlock["paragraph"],
+							$fSrcBlock["style"],
+							$fSrcBlock["lang"],
+							$fSrcBlock["status"],
+							mTime(),
+							mTime()
+						));
+				}
+				#复制源数据
+				$query = "SELECT block_uid, book_id,paragraph,wid,word,data,status from "._TABLE_USER_WBW_." where block_uid= ? ";
+				$stmtWBW = $dbhWBW->prepare($query);
+				$stmtWBW->execute(array($fSrcBlock["uid"]));
+				$fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
+				foreach ($fBlockData as $value) {
+					array_push($arrNewBlockData,
+						array(UUID::V4(),
+							$arrBlockTransform[$value["block_uid"]],
+							$value["book_id"],
+							$value["paragraph"],
+							$value["wid"],
+							$value["word"],
+							$value["data"],
+							mTime(),
+							mTime(),
+							$value["status"],
+							$_COOKIE["userid"],
+						));
 
-						}
+				}
 
-                    }
+			}
 
-					# 查找目标block是否存在
+			# 查找目标block是否存在
 
-					//删除旧的逐词解析block数据块
-					$query = "DELETE from "._TABLE_USER_WBW_BLOCK_." where  paragraph = ? AND book = ? AND channal = ? ";
-					$stmt = $dbhWBW->prepare($query);
-					$stmt->execute(array($iPara,$_GET["book"],$_GET["dest_channel"]));
-					
-                    //新增逐词解析block数据块
-                    if (count($arrNewBlock) > 0) {
-                        $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','parent_channel','owner','book','paragraph','style','lang','status','modify_time','receive_time','create_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
-                        $stmtNewBlock = $dbhWBW->prepare($query);
-                        foreach ($arrNewBlock as $oneParam) {
-                            $stmtNewBlock->execute($oneParam);
-                        }
-                        // 提交更改
-                        $dbhWBW->commit();
-                        if (!$stmtNewBlock || ($stmtNewBlock && $stmtNewBlock->errorCode() != 0)) {
-                            $error = $dbhWBW->errorInfo();
-                            echo "error - $error[2] <br>";
-							exit;
-                        } else {
-                            //逐词解析block块复刻成功
-                            $count = count($arrNewBlock);
-                            echo "wbw block $count recorders.<br/>";
-                        }
-                    }
+			//删除旧的逐词解析block数据块
+			$query = "DELETE from "._TABLE_USER_WBW_BLOCK_." where  paragraph = ? AND book_id = ? AND channel_uid = ? ";
+			$stmt = $dbhWBW->prepare($query);
+			$stmt->execute(array($iPara,$_GET["book"],$_GET["dest_channel"]));
+			
+			//新增逐词解析block数据块
+			if (count($arrNewBlock) > 0) {
+				$dbhWBW->beginTransaction();
+				$query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." (uid , parent_id , channel_uid , parent_channel_uid , creator_uid , book_id , paragraph , style , lang , status , modify_time , create_time , updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,now())";
+				$stmtNewBlock = $dbhWBW->prepare($query);
+				foreach ($arrNewBlock as $oneParam) {
+					$stmtNewBlock->execute($oneParam);
+				}
+				// 提交更改
+				$dbhWBW->commit();
+				if (!$stmtNewBlock || ($stmtNewBlock && $stmtNewBlock->errorCode() != 0)) {
+					$error = $dbhWBW->errorInfo();
+					echo "error - $error[2] <br>";
+					exit;
+				} else {
+					//逐词解析block块复刻成功
+					$count = count($arrNewBlock);
+					echo "wbw block $count recorders.<br/>";
+				}
+			}
 
-					//删除逐词解析数据块
-					if(isset($destId)){
-						$query = "DELETE from "._TABLE_USER_WBW_." where  block_id = ? ";
-						$stmt = $dbhWBW->prepare($query);
-						$stmt->execute($destId);
-					}
-					
-                    if (count($arrNewBlockData) > 0) {
-                        // 开始一个事务,逐词解析数据 关闭自动提交
-                        $dbhWBW->beginTransaction();
-                        $query = "INSERT INTO "._TABLE_USER_WBW_." ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
-                        $stmtWbwData = $dbhWBW->prepare($query);
-                        foreach ($arrNewBlockData as $oneParam) {
-                            $stmtWbwData->execute($oneParam);
-                        }
-                        // 提交更改
-                        $dbhWBW->commit();
-                        if (!$stmtWbwData || ($stmtWbwData && $stmtWbwData->errorCode() != 0)) {
-                            $error = $dbhWBW->errorInfo();
-                            echo "error - $error[2] <br>";
-							exit;
-                        } else {
-                            //逐词解析 数据 复刻成功
-                            $count = count($arrNewBlockData);
-                            echo "new wbw $count recorders.";
-                        }
-                    }
-
-                   {
-                        //成功
-                        echo "doc list updata 1 recorders.";
-                        echo "</div>";
-                        echo "<h3>复刻成功</h3>";
-                        echo "正在<a href='../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$_GET["dest_channel"]}'>打开</a>文档";
-                        echo "<script>";
-                        echo "window.location.assign(\"../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$_GET["dest_channel"]}\");";
-                        echo "</script>";
-                    }
-                }
+			//删除旧的wbw逐词解析数据块
+			if(isset($destId)){
+				$query = "DELETE from "._TABLE_USER_WBW_." where  block_uid = ? ";
+				$stmt = $dbhWBW->prepare($query);
+				$stmt->execute(array($destId));
+			}
+			
+			if (count($arrNewBlockData) > 0) {
+				// 开始一个事务,逐词解析数据 关闭自动提交
+				$dbhWBW->beginTransaction();
+				$query = "INSERT INTO "._TABLE_USER_WBW_." ( 
+															uid , 
+															block_uid , 
+															book_id , 
+															paragraph , 
+															wid , 
+															word , 
+															data , 
+															modify_time , 
+															create_time , 
+															status , 
+															creator_uid) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+				$stmtWbwData = $dbhWBW->prepare($query);
+				foreach ($arrNewBlockData as $oneParam) {
+					$stmtWbwData->execute($oneParam);
+				}
+				// 提交更改
+				$dbhWBW->commit();
+				if (!$stmtWbwData || ($stmtWbwData && $stmtWbwData->errorCode() != 0)) {
+					$error = $dbhWBW->errorInfo();
+					echo "error - $error[2] <br>";
+					exit;
+				} else {
+					//逐词解析 数据 复刻成功
+					$count = count($arrNewBlockData);
+					echo "new wbw $count recorders.";
+				}
+			}
 
+			
+			//成功
+			echo "doc list updata 1 recorders.";
+			echo "</div>";
+			echo "<h3>复刻成功</h3>";
+			echo "正在<a href='../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$_GET["dest_channel"]}'>打开</a>文档";
+			echo "<script>";
+			echo "window.location.assign(\"../studio/editor.php?op=openchannal&book={$_GET["book"]}&para={$_para[0]}&channal={$_GET["dest_channel"]}\");";
+			echo "</script>";
+			
             }
         }
-    }
 }
 
 echo "</div>";

+ 6 - 6
public/app/doc/load_channal_para.php

@@ -39,13 +39,13 @@ echo "\n<dict></dict>\n";
 echo "<message></message>\n";
 echo "<body>\n";
 
-$dh_wbw = new PDO("" . _FILE_DB_USER_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dh_wbw = new PDO(_FILE_DB_USER_WBW_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
 foreach ($paralist as $para) {
 
     $albumId = UUID::v4();
-    $query = "SELECT * FROM "._TABLE_USER_WBW_BLOCK_." WHERE channal=? AND book = ? AND paragraph = ?  ";
+    $query = "SELECT uid,creator_uid,lang FROM "._TABLE_USER_WBW_BLOCK_." WHERE channel_uid=? AND book_id = ? AND paragraph = ?  ";
     $stmt = $dh_wbw->prepare($query);
     $stmt->execute(array($channal, $book, $para));
     $FetchBlock = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -60,16 +60,16 @@ foreach ($paralist as $para) {
         echo "<title></title>";
         echo "<album_id></album_id>";
         echo "<album_guid></album_guid>";
-        echo "<author>{$FetchBlock["owner"]}</author>";
+        echo "<author>{$FetchBlock["creator_uid"]}</author>";
         echo "<language>{$FetchBlock["lang"]}</language>";
         echo "<version>1</version>";
         echo "<edition>1</edition>";
-        echo "<id>{$FetchBlock["id"]}</id>";
+        echo "<id>{$FetchBlock["uid"]}</id>";
         echo "</info>\n";
 
         echo "<data>\n";
-        $block_id = $FetchBlock["id"];
-        $query = "SELECT * from "._TABLE_USER_WBW_." where block_id= ? order by wid ASC";
+        $block_id = $FetchBlock["uid"];
+        $query = "SELECT data from "._TABLE_USER_WBW_." where block_uid= ? order by wid ASC";
         $stmt = $dh_wbw->prepare($query);
         $stmt->execute(array($block_id));
         $wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);

+ 29 - 33
public/app/doc/pcs2db.php

@@ -40,15 +40,15 @@ if (isset($_GET["channel"]) == false) {
     echo "<h2>选择一个空白的版风存储新的文档</h2>";
     echo "<form action='pcs2db.php' method='get'>";
     echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
-    PDO_Connect("" . _FILE_DB_CHANNAL_);
-    $query = "SELECT * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
-    $Fetch = PDO_FetchAll($query);
+    PDO_Connect( _FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid,name,lang,status,create_time from "._TABLE_CHANNEL_." where owner_uid = ?   limit 100";
+    $Fetch = PDO_FetchAll($query,$_COOKIE["user_uid"]);
     $i = 0;
     foreach ($Fetch as $row) {
         echo '<div class="file_list_row" style="padding:5px;display:flex;">';
 
         echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-        echo '<input name="channel" value="' . $row["id"] . '" ';
+        echo '<input name="channel" value="' . $row["uid"] . '" ';
         if ($i == 0) {
             echo "checked";
         }
@@ -58,7 +58,7 @@ if (isset($_GET["channel"]) == false) {
         echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
         PDO_Connect("" . _FILE_DB_USER_WBW_);
-        $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+        $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channel_uid = '{$row["uid"]}' and book_id='{$mbook}' and paragraph in ({$paragraph})  limit 100";
         $FetchWBW = PDO_FetchOne($query);
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
@@ -66,14 +66,14 @@ if (isset($_GET["channel"]) == false) {
             echo $_local->gui->blank;
         } else {
             echo $FetchWBW . $_local->gui->para;
-            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+            echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["uid"]}'>open</a>";
         }
         echo '</div>';
 
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-        PDO_Connect("" . _FILE_DB_SENTENCE_);
-        $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
-        $FetchWBW = PDO_FetchOne($query);
+        PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
+        $query = "SELECT count(*) from "._TABLE_SENTENCE_." where channel_uid = ? and book_id= ?  and paragraph in ({$paragraph})  limit 100";
+        $FetchWBW = PDO_FetchOne($query,array($row["uid"],$mbook));
         echo '</div>';
         echo '<div class="title" style="flex:2;padding-bottom:5px;">';
         if ($FetchWBW == 0) {
@@ -141,13 +141,13 @@ $dataBlock = $xml->xpath('//block');
 
     //复制数据
     //打开逐词解析数据库
-    $dns = "" . _FILE_DB_USER_WBW_;
-    $dbhWBW = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dns = _FILE_DB_USER_WBW_;
+    $dbhWBW = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbhWBW->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     //打开译文数据库
-    $dns = "" . _FILE_DB_SENTENCE_;
-    $dbhSent = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dns = _FILE_DB_SENTENCE_;
+    $dbhSent = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbhSent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     //逐词解析新数据数组
@@ -221,7 +221,6 @@ $dataBlock = $xml->xpath('//block');
                                 $block->info->paragraph,
                                 $sent_begin,
                                 $sent_end,
-                                "",
                                 $block->info->author,
                                 $_COOKIE["userid"],
                                 $paraText,
@@ -231,7 +230,6 @@ $dataBlock = $xml->xpath('//block');
                                 "7",
                                 $file_modify_time,
                                 mTime(),
-                                mTime(),
                                 $_GET["channel"],
                             ));
                     }
@@ -252,8 +250,7 @@ $dataBlock = $xml->xpath('//block');
                             "",
                             $block->info->language,
                             "",
-                            $file_modify_time,
-                            mTime(),
+                            $file_modify_time
                         ));
                 }
 
@@ -326,7 +323,6 @@ $dataBlock = $xml->xpath('//block');
                         $word->real,
                         $sWordData,
                         $file_modify_time,
-                        mTime(),
                         $word->status,
                         $_COOKIE["userid"],
                     ));
@@ -344,19 +340,19 @@ $dataBlock = $xml->xpath('//block');
     if (count($arrNewBlock) > 0) {
         $dbhWBW->beginTransaction();
         $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." (
-										'id',
-										'parent_id',
-										'channal',
-										'owner',
-										'book',
-										'paragraph',
-										'style',
-										'lang',
-										'status',
-										'modify_time',
-										'receive_time'
+										 uid ,
+										 parent_id ,
+										 channel_uid ,
+										 creator_uid ,
+										 book_id ,
+										 paragraph ,
+										 style ,
+										 lang ,
+										 status ,
+										 modify_time ,
+										updated_at
 										)
-										VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+										VALUES (?,?,?,?,?,?,?,?,?,?,now())";
         $stmtNewBlock = $dbhWBW->prepare($query);
         foreach ($arrNewBlock as $oneParam) {
             $stmtNewBlock->execute($oneParam);
@@ -376,7 +372,7 @@ $dataBlock = $xml->xpath('//block');
     if (count($arrNewBlockData) > 0) {
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhWBW->beginTransaction();
-        $query = "INSERT INTO "._TABLE_USER_WBW_." ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+        $query = "INSERT INTO "._TABLE_USER_WBW_." ( uid , block_uid , book_id , paragraph , wid , word , data , modify_time , status , creator_uid ,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,now())";
         $stmtWbwData = $dbhWBW->prepare($query);
         foreach ($arrNewBlockData as $oneParam) {
             $stmtWbwData->execute($oneParam);
@@ -397,7 +393,7 @@ $dataBlock = $xml->xpath('//block');
 
     if (count($arrSentNewBlock) > 0) {
         $dbhSent->beginTransaction();
-        $query = "INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
+        $query = "INSERT INTO "._TABLE_SENTENCE_BLOCK_." (uid , parent_uid , book_id , paragraph , owner_uid , lang , author , editor_uid  , status , modify_time , create_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
         $stmtSentNewBlock = $dbhSent->prepare($query);
         foreach ($arrSentNewBlock as $oneParam) {
             //print_r($oneParam);
@@ -418,7 +414,7 @@ $dataBlock = $xml->xpath('//block');
     if (count($arrSentNewBlockData) > 0) {
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhSent->beginTransaction();
-        $query = "INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','strlen','language','ver','status','modify_time','receive_time','create_time','channal') VALUES (? , ? , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
+        $query = "INSERT INTO "._TABLE_SENTENCE_." ( uid , block_uid , book_id , paragraph , word_start , word_end , author , editor_uid , content , strlen , language , version , status , modify_time , create_time , channel_uid') VALUES (?  , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
         $stmtSentData = $dbhSent->prepare($query);
         foreach ($arrSentNewBlockData as $oneParam) {
             $stmtSentData->execute($oneParam);

+ 2 - 2
public/app/pali_sent/get_sim.php

@@ -1,12 +1,12 @@
 <?php
 /*
-get user sentence from db
+获取相似句子列表
  */
 require_once "../config.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-//获取相似句子列表
+//
 
 if (isset($_POST["sent_id"])) {
     $dns = _FILE_DB_PALI_SENTENCE_SIM_;

+ 3 - 1
public/app/pali_sent/pali_sent_list.php

@@ -1,6 +1,8 @@
 <?php
 /*
-get user sentence from db
+获取巴利句子列表
+输入参数
+para: json
  */
 require_once "../config.php";
 require_once "../public/_pdo.php";

+ 2 - 2
public/app/pcdl/reader1.php

@@ -743,8 +743,8 @@ if ($currParaLevel == 1 || $currParaParentLevel == 1) {
     //查询编辑者数量
 
     //查询句子译文内容
-    PDO_Connect(_FILE_DB_SENTENCE_);
-    $dbh = new PDO(_FILE_DB_PALI_SENTENCE_, "", "");
+    PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
+    $dbh = new PDO(_FILE_DB_PALI_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_);
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
     //查询channal数量
     switch ($_view) {

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

@@ -0,0 +1,15 @@
+<?php
+require_once __DIR__.'/../../vendor/autoload.php';
+require_once __DIR__."/../config.php";
+require_once __DIR__."/../setting.php";
+
+class SnowFlakeId{
+	protected $snowflake;
+	function __construct() {
+		$this->snowflake = new \Godruoyi\Snowflake\Snowflake(SnowFlake["DatacenterId"], SnowFlake["WorkerId"]);
+		$this->snowflake->setStartTimeStamp(strtotime(_SnowFlakeDate_)*1000);
+	}
+	public function id(){
+		return $this->snowflake->id();
+	}
+}

+ 6 - 0
public/app/setting.php

@@ -0,0 +1,6 @@
+<?php
+#此配置文件中的内容为各个服务器通用内容。服务器的维护者无需修改。
+
+
+# 雪花算法id 起始日期2021-12-22 绝对不可修改!!!
+define("_SnowFlakeDate_","2021-12-22");

+ 1 - 1
public/app/share/function.php

@@ -80,7 +80,7 @@ function share_res_list_get($userid,$res_type=-1){
 				$channelInfo = $channel->getChannal($res["res_id"]);
 				if($channelInfo){
 					$resList[$key]["res_title"]=$channelInfo["name"];
-					$resList[$key]["res_owner_id"]=$channelInfo["owner"];
+					$resList[$key]["res_owner_id"]=$channelInfo["owner_uid"];
 					$resList[$key]["status"]=$channelInfo["status"];
 					$resList[$key]["lang"]=$channelInfo["lang"];
 				}

+ 65 - 83
public/app/studio/dict_updata_wbw.php

@@ -3,27 +3,21 @@ require_once 'checklogin.inc';
 require_once "../public/_pdo.php";
 require_once "../config.php";
 require_once "../redis/function.php";
-
-$redis = redis_connect();
-$input = file_get_contents("php://input");
+require_once "../public/function.php";
 
 $return = "";
 $serverMsg = "";
 
+$redis = redis_connect();
+$input = file_get_contents("php://input");
 $xml = simplexml_load_string($input);
-
-PDO_Connect(_FILE_DB_WBW_);
-PDO_Execute("PRAGMA synchronous = OFF");
-PDO_Execute("PRAGMA journal_mode = WAL");
-PDO_Execute("PRAGMA foreign_keys = ON");
-PDO_Execute("PRAGMA busy_timeout = 5000");
-
 $wordsList = $xml->xpath('//word');
-//$serverMsg+= "word count:".count($wordsList)."<br>";
+
+PDO_Connect(_FILE_DB_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 
 //remove the same word
 foreach ($wordsList as $ws) {
-    $combine = $ws->pali . $ws->guid . $ws->type . $ws->gramma . $ws->parent . $ws->parent_id . $ws->mean . $ws->factors . $ws->fm . $ws->part_id;
+    $combine = $ws->pali  . $ws->type . $ws->gramma . $ws->parent .  $ws->mean . $ws->factors . $ws->fm;
     $word[$combine] = $ws;
 }
 
@@ -34,80 +28,97 @@ $updateWord = array();
 
 foreach ($word as $x => $ws) {
 	
-    $query = "SELECT id,ref_counter  FROM dict WHERE
-				\"guid\"= ? AND
-				\"pali\"= ? AND
-				\"type\"= ? AND
-				\"gramma\"= ? AND
-				\"mean\"= ? AND
-				\"parent\"= ? AND
-				\"parent_id\"= ? AND
-				\"factors\"= ? AND
-				\"factormean\"= ? AND
-				\"part_id\"= ?" ;
-    $Fetch = PDO_FetchAll($query,array($ws->guid,$ws->pali,$ws->type,$ws->gramma,$ws->mean,$ws->parent,$ws->parent_id,$ws->factors,$ws->fm,$ws->part_id));
+    $query = "SELECT id,ref_counter  FROM "._TABLE_DICT_USER_." WHERE
+				 word = ? AND
+				 type = ? AND
+				 gramma = ? AND
+				 mean = ? AND
+				 base = ? AND
+				 factors = ? AND
+				 factormean = ? AND source = '_USER_DATA_'" ;
+    $Fetch = PDO_FetchAll($query,array($ws->pali,$ws->type,$ws->gramma,$ws->mean,$ws->parent,$ws->factors,$ws->fm));
     $FetchNum = count($Fetch);
 
     if ($FetchNum == 0) {
 		$updateWord["{$ws->pali}"] = 1;
 		//没有找到,新建数据
         //new recorder
-        $params = array($ws->guid,
+        $params = array(
             $ws->pali,
             $ws->type,
             $ws->gramma,
             $ws->parent,
-            $ws->parent_id,
             $ws->mean,
             $ws->note,
             $ws->factors,
             $ws->fm,
-            $ws->part_id,
             $ws->status,
             $ws->language,
-            $UID,
-            time());
+			'_USER_DATA_',
+            mTime());
         array_push($arrInserString, $params);
 
     } else {
+		#查询本人是否有此记录
+		$query = "SELECT id,ref_counter  FROM "._TABLE_DICT_USER_." WHERE
+		word = ? AND
+		type = ? AND
+		gramma = ? AND
+		mean = ? AND
+		base = ? AND
+		factors = ? AND
+		factormean = ? AND user_id = ? " ;
+		$FetchMy = PDO_FetchAll($query,array($ws->pali,$ws->type,$ws->gramma,$ws->mean,$ws->parent,$ws->factors,$ws->fm,$UID));
+		$FetchNumMy = count($FetchMy);
+		if($FetchNumMy==0){
+			$wordId = $Fetch[0]["id"];
+			$ref = $Fetch[0]["ref_counter"] + 1;
+			//更新引用计数
+			$query = "UPDATE dict SET ref_counter= ?  where id = ? ";
+			$stmt = PDO_Execute($query,array($ref,$wordId));
+			if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+				$error = PDO_ErrorInfo();
+				echo "error" . $error[2] . "<br>";
+			}
+
+			#增加我的记录
+			$params = array(
+				$ws->pali,
+				$ws->type,
+				$ws->gramma,
+				$ws->parent,
+				$ws->mean,
+				$ws->note,
+				$ws->factors,
+				$ws->fm,
+				$ws->status,
+				$ws->language,
+				'_WBW_',
+				mTime());
+			array_push($arrInserString, $params);
+		}
         // "have a same recorder";
-        $wordId = $Fetch[0]["id"];
-        $ref = $Fetch[0]["ref_counter"] + 1;
-        //更新引用计数
-        $query = "UPDATE dict SET ref_counter='$ref' where id=" . $PDO->quote($wordId);
-        $stmt = @PDO_Execute($query);
-        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-            $error = PDO_ErrorInfo();
-            echo "error" . $error[2] . "<br>";
-        }
-        //去掉已经有的索引
-        $query = "select count(*)  from user_index where word_index={$wordId} and user_id={$UID}";
-        $num = PDO_FetchOne($query);
-        if ($num == 0) {
-            array_push($arrExistWords, $Fetch[0]["id"]);
-        }
+
+
     }
 }
 /* 开始一个事务,关闭自动提交 */
 $PDO->beginTransaction();
-$query = "INSERT INTO dict ('id',
-						  'guid',
-						  'pali',
+$query = "INSERT INTO "._TABLE_DICT_USER_." (
+						  'word',
 						  'type',
 						  'gramma',
 						  'parent',
-						  'parent_id',
 						  'mean',
 						  'note',
 						  'factors',
 						  'factormean',
-						  'part_id',
 						  'status',
-						  'dict_name',
+						  'source',
 						  'language',
-						  'creator',
-						  'time')
-				   VALUES (null,?,?,?,?,?,?,?,?,?,?,?,?,'user',?,?,?)";
+						  'creator_id',
+						  'create_time')
+				   VALUES (?,?,?,?,?,?,?,?,?,'user',?,?,?)";
 $stmt = $PDO->prepare($query);
 foreach ($arrInserString as $oneParam) {
     $stmt->execute($oneParam);
@@ -121,40 +132,11 @@ if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
     echo "error - $error[2] <br>";
 } else {
 	//成功
-    $count = count($arrInserString);
-    echo "updata $count recorders.";
-    //更新索引表
-
-    $iFirst = $lastid - $count + 1;
-    for ($i = 0; $i < $count; $i++) {
-        array_push($arrExistWords, $iFirst + $i);
-    }
-    if (count($arrExistWords) > 0) {
-        /* 开始一个事务,关闭自动提交 */
-        $PDO->beginTransaction();
-        $query = "INSERT INTO user_index ('id','word_index','user_id','create_time')
-								VALUES (null,?,{$UID},?)";
-        $stmt = $PDO->prepare($query);
-        foreach ($arrExistWords as $oneId) {
-            $stmt->execute(array($oneId, time()));
-        }
-        /* 提交更改 */
-        $PDO->commit();
-        if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-            $error = PDO_ErrorInfo();
-            echo "error - $error[2] <br>";
-        } else {
-            echo "updata index " . count($arrExistWords) . " recorders.";
-        }
-    } else {
-        echo "updata index 0";
-	}
-	
 	#更新 redis
 	if ($redis != false) {
 		foreach ($updateWord as $key => $value) {
 			# code...
-			$query = "SELECT * from dict where pali = ? ";
+			$query = "SELECT * from "._TABLE_DICT_USER_." where word = ? ";
 			$stmt = $PDO->prepare($query);
 			$stmt->execute(array($key));
 			if ($stmt) {

+ 1 - 1
public/app/studio/index_head.php

@@ -5,7 +5,7 @@ require_once '../public/config.php';
 require_once '../public/load_lang.php';
 ?>
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html>
 <html>
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

+ 70 - 3
public/app/studio/js/editor.js

@@ -2148,6 +2148,8 @@ function editor_updataInlineDict(iword, newWord) {
 上传到我的字典
 */
 function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
+	let words = new Array();
+
 	let queryString = "<wordlist>";
 	let x = gXmlBookDataBody.getElementsByTagName("word");
 	let iCount = 0;
@@ -2293,6 +2295,18 @@ function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
 			queryString += "<enable>" + d_enable + "</enable>";
 			queryString += "<language>" + d_language + "</language>";
 			queryString += "</word>";
+			words.push(
+				{
+					word:d_pali,
+					type:d_type,
+					grammar:d_gramma,
+					parent:d_parent,
+					mean:d_mean,
+					factors:d_factors,
+					factormean:d_fm,
+					language:d_language,
+				}
+			)
 			iCount++;
 
 			//formula
@@ -2315,6 +2329,18 @@ function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
 				queryString += "<language>" + d_language + "</language>";
 				queryString += "</word>";
 				iCount++;
+				words.push(
+					{
+						word:"_formula_",
+						type:d_type,
+						grammar:d_gramma,
+						parent:"",
+						mean:formula,
+						factors:"",
+						factormean:"",
+						language:d_language,
+					}
+				);
 			}
 
 			//parent recorder
@@ -2343,6 +2369,18 @@ function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
 				queryString += "<language>" + d_language + "</language>";
 				queryString += "</word>";
 				iCount++;
+				words.push(
+					{
+						word:d_parent,
+						type:d_parentType,
+						grammar:d_parentGramma,
+						parent:"",
+						mean:d_parentmean,
+						factors:fc.join("+"),
+						factormean:fm.join("+"),
+						language:d_language,
+					}
+				);
 			}
 
 			//part recorder
@@ -2372,6 +2410,18 @@ function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
 						queryString += "<language>" + d_language + "</language>";
 						queryString += "</word>";
 						iCount++;
+						words.push(
+							{
+								word:arrPart[iPart],
+								type:".part.",
+								grammar:"",
+								parent:"",
+								mean:arrPartMean[iPart],
+								factors:"",
+								factormean:"",
+								language:d_language,
+							}
+						);
 					}
 				}
 			}
@@ -2382,9 +2432,26 @@ function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
 	if (iCount == 0) {
 		ntf_show("no word update");
 	} else {
-		$.post("./dict_updata_wbw.php", queryString, function (data, status) {
-			ntf_show("Data: " + data + "\nStatus: " + status);
-		});
+		/*
+		$.post(
+			"./dict_updata_wbw.php", 
+			queryString, 
+			function (data, status) {
+				ntf_show("Data: " + data + "\nStatus: " + status);
+			}
+		);
+		*/
+		$.post(
+			"../api/user_dicts.php", 
+			{
+				op:'create',
+				view:'wbw',
+				data: JSON.stringify(words),
+			}, 
+			function (data, status) {
+				ntf_show("Data: " + data + "\nStatus: " + status);
+			}
+		);
 	}
 }
 

+ 3 - 3
public/app/studio/js/wizard.js

@@ -435,9 +435,9 @@ function loadUserWBWList(){
 		let html ="";
 		for (const it of data) {
 			html += "<div class='file_list_row'>";
-			link = "<a href='./editor.php?op=openchannel&book="+it.book+"&par="+it.paragraph+"&channel="+it.channal+"' target='_blank'>";
-			html += "<div style='flex:5;'>"+link+it.book+"-"+it.paragraph+"</a></div>";
-			html += "<div style='flex:2;'>"+getDataTime(it.modify_time)+"</div>";
+			link = "<a href='./editor.php?op=openchannel&book="+it.book+"&par="+it.paragraph+"&channel="+it.channel_uid+"' target='_blank'>";
+			html += "<div style='flex:5;'>"+link+it.book_id+"-"+it.paragraph+"</a></div>";
+			html += "<div style='flex:2;'>"+it.updated_at+"</div>";
 			html += "</div>"
 		}
 		$("#file_list").html(html);

+ 9 - 10
public/app/studio/pc_get_word_num.php

@@ -13,18 +13,17 @@ PDO_Connect(_FILE_DB_PALICANON_TEMPLET_);
 if ($get_par_end == -1 || ($get_par_end - $get_par_begin) > 50000) {
     echo "0,0,0,0";
     exit;
-} else 
-{
-    $query1 = "SELECT count(*) FROM "._TABLE_PALICANON_TEMPLET_." WHERE book = $get_book and  paragraph BETWEEN $get_par_begin AND $get_par_end";
-    $query2 = "SELECT count(*) FROM (SELECT count(*),real FROM "._TABLE_PALICANON_TEMPLET_." WHERE book = $get_book and (paragraph BETWEEN $get_par_begin AND $get_par_end ) group by real ) T";
+} else {
+    $query1 = "SELECT count(*) FROM "._TABLE_PALICANON_TEMPLET_." WHERE book = ? and (paragraph BETWEEN $get_par_begin AND $get_par_end)";
+    $query2 = "SELECT count(*) FROM (SELECT count(*) FROM "._TABLE_PALICANON_TEMPLET_." WHERE book=? and (paragraph BETWEEN $get_par_begin AND $get_par_end ) group by real ) T";
 
-    $query3 = "SELECT sum(length(real)) FROM "._TABLE_PALICANON_TEMPLET_." WHERE book = $get_book and paragraph BETWEEN $get_par_begin AND $get_par_end";
-    $query4 = "SELECT sum(length(real)) FROM (SELECT count(*),real FROM "._TABLE_PALICANON_TEMPLET_." WHERE book = $get_book and (paragraph BETWEEN $get_par_begin AND $get_par_end ) group by real ) T";
+    $query3 = "SELECT sum(length(real)) FROM "._TABLE_PALICANON_TEMPLET_." WHERE book=? and  (paragraph BETWEEN $get_par_begin AND $get_par_end)";
+    $query4 = "SELECT sum(length(real)) FROM (SELECT count(*),real FROM "._TABLE_PALICANON_TEMPLET_." WHERE book=? and (paragraph BETWEEN $get_par_begin AND $get_par_end ) group by real ) T";
 
-    $allword = PDO_FetchOne($query1);
-    $allword_token = PDO_FetchOne($query2);
-    $allwordLen = PDO_FetchOne($query3);
-    $allword_tokenLen = PDO_FetchOne($query4);
+    $allword = PDO_FetchOne($query1,array($get_book));
+    $allword_token = PDO_FetchOne($query2,array($get_book));
+    $allwordLen = PDO_FetchOne($query3,array($get_book));
+    $allword_tokenLen = PDO_FetchOne($query4,array($get_book));
 
     echo $allword . "," . $allword_token . "," . $allwordLen . "," . $allword_tokenLen;
 }

+ 19 - 17
public/app/studio/project.php

@@ -149,7 +149,7 @@ switch ($op) {
                                     }
                                     $block_id = UUID::v4();
                                     $trans_block_id = UUID::v4();
-                                    $block_data[] = array($block_id, "", $_POST["channal"], $USER_ID, $book, $iPar, "_none_", $_POST["lang"], 1);
+                                    $block_data[] = array($block_id, "", $_POST["channal"], $USER_ID, $book, $iPar, "_none_", $_POST["lang"], 10,mTime());
                                     $block_list[] = array("channal" => $_POST["channal"],
                                         "type" => 6, //word by word
                                         "book" => $res_book,
@@ -185,7 +185,7 @@ switch ($op) {
                                         $strXml .= "<style>{$result["style"]}</style>";
                                         $strXml .= "<status>0</status>";
                                         $strXml .= "</word>";
-                                        $wbw_data[] = array(UUID::v4(), $block_id, $book, $iPar, $result["wid"], $result["real"], $strXml, mTime(), mTime(), 1, $USER_NAME);
+                                        $wbw_data[] = array(UUID::v4(), $block_id, $book, $iPar, $result["wid"], $result["real"], $strXml, mTime(), 10, $USER_NAME);
                                     }
                                 }
                             }
@@ -193,9 +193,10 @@ switch ($op) {
                             //写入数据库
                             // 开始一个事务,关闭自动提交
 
-                            PDO_Connect(_FILE_DB_USER_WBW_);
+                            PDO_Connect(_FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
                             $PDO->beginTransaction();
-                            $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+
+                            $query = "INSERT INTO "._TABLE_USER_WBW_BLOCK_." ( uid , parent_id , channel_uid , creator_uid , book_id , paragraph , style , lang , status , modify_time ,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,now())";
                             $stmt = $PDO->prepare($query);
                             foreach ($block_data as $oneParam) {
                                 $stmt->execute($oneParam);
@@ -213,7 +214,7 @@ switch ($op) {
                             // 开始一个事务,关闭自动提交
 
                             $PDO->beginTransaction();
-                            $query = "INSERT INTO "._TABLE_USER_WBW_." ('id','block_id','book','paragraph','wid','word','data','modify_time','receive_time','status','owner') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+                            $query = "INSERT INTO "._TABLE_USER_WBW_." ( uid , block_uid , book_id , paragraph , wid , word , data , modify_time , status , creator_uid ,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,now())";
                             $stmt = $PDO->prepare($query);
                             foreach ($wbw_data as $oneParam) {
                                 $stmt->execute($oneParam);
@@ -330,15 +331,15 @@ switch ($op) {
                 echo "<fieldset>";
                 echo "<legend>{$_local->gui->channel} ({$_local->gui->required})</legend>";
                 echo "<div>";
-                PDO_Connect(_FILE_DB_CHANNAL_);
-                $query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
-                $Fetch = PDO_FetchAll($query);
+                PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+                $query = "SELECT uid,name,lang,status,create_time from "._TABLE_CHANNEL_." where owner_uid = ?  limit 100";
+                $Fetch = PDO_FetchAll($query,array($_COOKIE["userid"]));
                 $i = 0;
                 foreach ($Fetch as $row) {
                     echo '<div class="file_list_row" style="padding:5px;">';
 
                     echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
-                    echo '<input name="channal" value="' . $row["id"] . '" ';
+                    echo '<input name="channal" value="' . $row["uid"] . '" ';
                     if ($i == 0) {
                         echo "checked";
                     }
@@ -347,24 +348,25 @@ switch ($op) {
                     echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["name"] . '</div>';
                     echo '<div class="title" style="flex:3;padding-bottom:5px;">' . $row["lang"] . '</div>';
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-                    PDO_Connect( _FILE_DB_USER_WBW_);
-                    $query = "select count(*) from "._TABLE_USER_WBW_BLOCK_." where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
-                    $FetchWBW = PDO_FetchOne($query);
+                    PDO_Connect( _FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
+                    $query = "SELECT count(*) from "._TABLE_USER_WBW_BLOCK_." where channel_uid = ? and book_id= ? and paragraph in {$strQueryParaList}  limit 100";
+                    $FetchWBW = PDO_FetchOne($query,array($row["uid"],$book));
                     echo '</div>';
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
                     if ($FetchWBW == 0) {
                         echo $_local->gui->blank;
-                        echo "&nbsp;<a></a>";//快捷编辑?
+                        echo "&nbsp;<a></a>";//??
                     } else {
+						#打开编辑窗口
                         echo $FetchWBW . $_local->gui->para;
-                        echo "&nbsp;<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>{$_local->gui->open}</a>";
+                        echo "&nbsp;<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["uid"]}'>{$_local->gui->open}</a>";
                     }
                     echo '</div>';
 
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
-                    PDO_Connect( _FILE_DB_SENTENCE_);
-                    $query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
-                    $FetchWBW = PDO_FetchOne($query);
+                    PDO_Connect( _FILE_DB_SENTENCE_,_DB_USERNAME_,_DB_PASSWORD_);
+                    $query = "SELECT count(*) from "._TABLE_SENTENCE_." where channel_uid = ? and book_id = ? and paragraph in {$strQueryParaList}  limit 100";
+                    $FetchWBW = PDO_FetchOne($query,array($row["uid"],$book));
                     echo '</div>';
                     echo '<div class="title" style="flex:2;padding-bottom:5px;">';
                     if ($FetchWBW == 0) {

+ 21 - 18
public/app/studio/project_load_article.php

@@ -1,6 +1,7 @@
 <?php
 /*
-get xml doc from db
+get xml doc from article
+尚未完成
  */
 require_once "../config.php";
 require_once "../public/_pdo.php";
@@ -8,9 +9,9 @@ require_once "../public/function.php";
 
 $id = $_GET["id"];
 
-PDO_Connect( _FILE_DB_USER_ARTICLE_);
-$query = "select * from article where id=" . $PDO->quote($id);
-$Fetch = PDO_FetchAll($query);
+PDO_Connect( _FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT * from article where id= ? ";
+$Fetch = PDO_FetchAll($query,array($id));
 if (count($Fetch) > 0) {
     echo "<set>\n";
     echo $Fetch[0]["doc_info"];
@@ -18,10 +19,10 @@ if (count($Fetch) > 0) {
     echo "<message></message>\n";
     echo "<body>\n";
 
-    $dh_wbw = new PDO("" . _FILE_DB_USER_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dh_wbw = new PDO( _FILE_DB_USER_WBW_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-    $dh_sent = new PDO("" . _FILE_DB_SENTENCE_, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dh_sent = new PDO( _FILE_DB_SENTENCE_, _DB_PASSWORD_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     $blockList = explode("\n", $Fetch[0]["content"]);
@@ -32,28 +33,30 @@ if (count($Fetch) > 0) {
             case "6":
                 {
                     $albumId = UUID::v4();
-                    $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id='" . $block->block_id . "'";
-                    $stmt = $dh_wbw->query($query);
+                    $query = "SELECT book_id,paragraph,creator_uid,lang from "._TABLE_USER_WBW_BLOCK_." where uid = ? ";
+                    $stmt = $dh_wbw->prepare($query);
+                    $stmt->execute(array($block->block_id));
                     $FetchBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
                     echo "\n<block>";
                     echo "<info>\n";
 
                     echo "<type>wbw</type>";
-                    echo "<book>{$FetchBlock[0]["book"]}</book>";
+                    echo "<book>{$FetchBlock[0]["book_id"]}</book>";
                     echo "<paragraph>{$FetchBlock[0]["paragraph"]}</paragraph>";
                     echo "<level>100</level>";
                     echo "<title>title</title>";
                     echo "<album_id>{$block->channal}</album_id>";
                     echo "<album_guid>{$block->channal}</album_guid>";
-                    echo "<author>{$FetchBlock[0]["owner"]}</author>";
+                    echo "<author>{$FetchBlock[0]["creator_uid"]}</author>";
                     echo "<language>{$FetchBlock[0]["lang"]}</language>";
                     echo "<version>1</version>";
                     echo "<edition>1</edition>";
                     echo "<id>{$block->block_id}</id>";
                     echo "</info>\n";
                     echo "<data>\n";
-                    $query = "select * from "._TABLE_USER_WBW_." where block_id='" . $block->block_id . "'";
-                    $stmt = $dh_wbw->query($query);
+                    $query = "SELECT data from "._TABLE_USER_WBW_." where block_uid=?";
+                    $stmt = $dh_wbw->prepare($query);
+                    $stmt->execute(array($block->block_id));
                     $wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
                     foreach ($wbw_data as $word) {
                         echo $word["data"];
@@ -89,15 +92,15 @@ if (count($Fetch) > 0) {
                         echo "<parent>{$FetchBlock[0]["parent_id"]}</parent>";
                         echo "</info>\n";
                         echo "<data>\n";
-                        $query = "select * from sentence where block_id='" . $block->block_id . "'";
-                        $stmt = $dh_sent->query($query);
+                        $query = "SELECT uid,word_start,word_end,content,status from "._TABLE_SENTENCE_." where block_uid=?";
+                        $stmt = $dh_sent->query($query,array($block->block_id));
                         $sent_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
                         foreach ($sent_data as $sent) {
                             echo "<sen>";
-                            echo "<id>{$sent["id"]}</id>";
-                            echo "<begin>{$sent["begin"]}</begin>";
-                            echo "<end>{$sent["end"]}</end>";
-                            echo "<text>{$sent["text"]}</text>";
+                            echo "<id>{$sent["uid"]}</id>";
+                            echo "<begin>{$sent["word_start"]}</begin>";
+                            echo "<end>{$sent["word_end"]}</end>";
+                            echo "<text>{$sent["content"]}</text>";
                             echo "<status>{$sent["status"]}</status>";
                             echo "</sen>";
                         }

+ 29 - 25
public/app/studio/project_load_db.php

@@ -18,10 +18,10 @@ if (count($Fetch) > 0) {
     echo "<message></message>\n";
     echo "<body>\n";
 
-    $dh_wbw = new PDO("" . _FILE_DB_USER_WBW_, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dh_wbw = new PDO(_FILE_DB_USER_WBW_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-    $dh_sent = new PDO("" . _FILE_DB_SENTENCE_, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dh_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
     $blockList = json_decode($Fetch[0]["doc_block"]);
@@ -31,29 +31,33 @@ if (count($Fetch) > 0) {
             case "6":
                 {
                     $albumId = UUID::v4();
-                    $query = "select * from "._TABLE_USER_WBW_BLOCK_." where id='" . $block->block_id . "'";
-                    $stmt = $dh_wbw->query($query);
+                    $query = "SELECT uid, book_id,paragraph,channel_uid , creator_uid,lang from "._TABLE_USER_WBW_BLOCK_." where uid = ? ";
+                    $stmt = $dh_wbw->prepare($query);
+                    $stmt->execute(array($block->block_id));
                     $FetchBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
+					#TODO 处理没找到数据的问题
                     echo "\n<block>";
                     echo "<info>\n";
-
                     echo "<type>wbw</type>";
-                    echo "<book>{$FetchBlock[0]["book"]}</book>";
+                    echo "<book>{$FetchBlock[0]["book_id"]}</book>";
                     echo "<paragraph>{$FetchBlock[0]["paragraph"]}</paragraph>";
                     echo "<level>100</level>";
                     echo "<title>title</title>";
-                    echo "<album_id>{$block->channal}</album_id>";
-                    echo "<album_guid>{$block->channal}</album_guid>";
-                    echo "<author>{$FetchBlock[0]["owner"]}</author>";
+                    echo "<album_id>{$FetchBlock[0]["channel_uid"]}</album_id>";
+                    echo "<album_guid>{$FetchBlock[0]["channel_uid"]}</album_guid>";
+                    echo "<author>{$FetchBlock[0]["creator_uid"]}</author>";
                     echo "<language>{$FetchBlock[0]["lang"]}</language>";
                     echo "<version>1</version>";
                     echo "<edition>1</edition>";
-                    echo "<id>{$block->block_id}</id>";
+                    echo "<id>{$FetchBlock[0]["uid"]}</id>";
                     echo "</info>\n";
                     echo "<data>\n";
-                    $query = "SELECT * FROM "._TABLE_USER_WBW_." WHERE block_id='" . $block->block_id . "' order by wid ASC";
-                    $stmt = $dh_wbw->query($query);
+                    $query = "SELECT data FROM "._TABLE_USER_WBW_." WHERE block_uid=? order by wid ASC";
+                    $stmt = $dh_wbw->prepare($query);
+                    $stmt->execute(array($block->block_id));
                     $wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+
                     foreach ($wbw_data as $word) {
                         echo $word["data"];
                         echo "\r\n";
@@ -65,38 +69,38 @@ if (count($Fetch) > 0) {
             case 2:
                 {
                     $albumId = UUID::v4();
-                    $query = "select * from sent_block where id='" . $block->block_id . "'";
-                    $stmt = $dh_sent->query($query);
+                    $query = "SELECT book_id,paragraph,author,editor_uid,lang,parent_uid from "._TABLE_SENTENCE_BLOCK_." where uid=?";
+                    $stmt = $dh_sent->query($query,array($block->block_id));
                     $FetchBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
                     if (count($FetchBlock) > 0) {
                         echo "\n<block>\n";
                         echo "<info>\n";
 
                         echo "<type>translate</type>";
-                        echo "<book>{$FetchBlock[0]["book"]}</book>";
+                        echo "<book>{$FetchBlock[0]["book_id"]}</book>";
                         echo "<paragraph>{$FetchBlock[0]["paragraph"]}</paragraph>";
                         echo "<level>100</level>";
                         echo "<title>title</title>";
-                        echo "<album_id>{$block->channal}</album_id>";
-                        echo "<album_guid>{$block->channal}</album_guid>";
+                        echo "<album_id></album_id>";
+                        echo "<album_guid>channel</album_guid>";
                         echo "<author>{$FetchBlock[0]["author"]}</author>";
-                        echo "<editor>{$FetchBlock[0]["editor"]}</editor>";
+                        echo "<editor>{$FetchBlock[0]["editor_uid"]}</editor>";
                         echo "<language>{$FetchBlock[0]["lang"]}</language>";
                         echo "<version>1</version>";
                         echo "<edition>1</edition>";
                         echo "<id>{$block->block_id}</id>";
-                        echo "<parent>{$FetchBlock[0]["parent_id"]}</parent>";
+                        echo "<parent>{$FetchBlock[0]["parent_uid"]}</parent>";
                         echo "</info>\n";
                         echo "<data>\n";
-                        $query = "select * from sentence where block_id='" . $block->block_id . "'";
-                        $stmt = $dh_sent->query($query);
+                        $query = "SELECT uid,word_start,word_end,content,status from "._TABLE_SENTENCE_." where block_uid=?";
+                        $stmt = $dh_sent->query($query,array($block->block_id));
                         $sent_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
                         foreach ($sent_data as $sent) {
                             echo "<sen>";
-                            echo "<id>{$sent["id"]}</id>";
-                            echo "<begin>{$sent["begin"]}</begin>";
-                            echo "<end>{$sent["end"]}</end>";
-                            echo "<text>{$sent["text"]}</text>";
+                            echo "<id>{$sent["uid"]}</id>";
+                            echo "<begin>{$sent["word_start"]}</begin>";
+                            echo "<end>{$sent["word_end"]}</end>";
+                            echo "<text>{$sent["content"]}</text>";
                             echo "<status>{$sent["status"]}</status>";
                             echo "</sen>";
                         }

+ 2 - 2
public/app/studio/sent/sent.php

@@ -63,7 +63,7 @@ if (isset($_POST["block_id"])) {
 
 global $PDO;
 
-PDO_Connect(_FILE_DB_SENTENCE_);
+PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
 
 switch ($op) {
     case "save":
@@ -92,7 +92,7 @@ switch ($op) {
         //echo $response->getBody();
          */
         if ($_id == 0) {
-            $query = "select * from sentence where
+            $query = "SELECT * from "._TABLE_SENTENCE_." where
 						book='{$_book}' and
 						paragraph='{$_para}' and
 						begin='{$_begin}' and

+ 17 - 13
public/app/term/channal_list.php

@@ -43,20 +43,20 @@ $channal_list = array();
 $channel_power=array();
 if (isset($_COOKIE["userid"])) {
 	//找自己的
-    PDO_Connect(_FILE_DB_CHANNAL_);
-    $query = "SELECT id from channal where owner = ? and status >0   limit 100";
-    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["userid"]));
+    PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid from "._TABLE_CHANNEL_." where owner_uid = ? and status >0   limit 100";
+    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["user_uid"]));
     foreach ($Fetch_my as $key => $value) {
         # code...
-		$channal_list[] = $value["id"];
-		$channel_power[$value["id"]]=30;
+		$channal_list[] = $value["uid"];
+		$channel_power[$value["uid"]]=30;
     }
 	$time = microtime(true);
 	$log .= $time-$timeStart ." - 找自己的结束". PHP_EOL;
 	$timeStart = $time;
 
 	# 找协作的
-	$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
+	$coop_channal =  share_res_list_get($_COOKIE["user_uid"],2);
 	foreach ($coop_channal as $key => $value) {
 		# return res_id,res_type,power res_title  res_owner_id
 		$channal_list[] = $value["res_id"];
@@ -73,7 +73,7 @@ if (isset($_COOKIE["userid"])) {
 if (count($channal_list) > 0) {
 	#  创建一个填充了和params相同数量占位符的字符串 
     $channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
-    $channel_query = " OR channal IN ($channel_place_holders)";
+    $channel_query = " OR channel_uid IN ($channel_place_holders)";
 } else {
     $channel_query = "";
 }
@@ -122,7 +122,7 @@ foreach ($_data as $key => $value) {
 
 
         #公开 或 channel有权限的
-        $query = "SELECT channal FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0 and (status = 30 {$channel_query} ) group by channal  limit 20 ";
+        $query = "SELECT channel_uid FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND strlen >0 and (status = 30 {$channel_query} ) group by channel_uid  limit 20 ";
         $stmt = $db_trans_sent->prepare($query);
         $parm = array($bookId, $para, $begin, $end);
         $parm = array_merge_recursive($parm, $channal_list);
@@ -130,11 +130,11 @@ foreach ($_data as $key => $value) {
         $Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
         foreach ($Fetch as $key => $value) {
             # code...
-            $pali_letter[$value["channal"]] = 1;
-            if (isset($channal[$value["channal"]])) {
-                $channal[$value["channal"]]++;
+            $pali_letter[$value["channel_uid"]] = 1;
+            if (isset($channal[$value["channel_uid"]])) {
+                $channal[$value["channel_uid"]]++;
             } else {
-                $channal[$value["channal"]] = 1;
+                $channal[$value["channel_uid"]] = 1;
             }
         }
 
@@ -166,13 +166,17 @@ foreach ($channal as $key => $value) {
         $arr_sent_final[] = $sent_final;
     }
     $channalInfo = $_channal->getChannal($key);
-    $name = $_userinfo->getName($channalInfo["owner"]);
+	
+    $name = $_userinfo->getName($channalInfo["owner_uid"]);
     $channalInfo["username"] = $name["username"];
     $channalInfo["nickname"] = $name["nickname"];
     $channalInfo["count"] = $value;
     $channalInfo["all"] = count($_data);
     $channalInfo["final"] = $arr_sent_final;
 	$channalInfo["article_len"] = $article_len;
+	$channalInfo["id"] = $key;
+	$channalInfo["owner"] = $channalInfo["owner_uid"];
+
 	if(isset($channel_power[$key])){
 		$channalInfo["power"] =$channel_power[$key];
 	}

+ 6 - 6
public/app/term/note.js

@@ -347,7 +347,7 @@ function note_channal_list() {
 						for (const iterator of _my_channal) {
 							let found = false;
 							for (const one of active) {
-								if (iterator.id == one.id) {
+								if (iterator.uid == one.uid) {
 									found = true;
 									break;
 								}
@@ -460,7 +460,7 @@ function render_channal_list(channalinfo) {
 	let output = "";
 	let checked = "";
 	let selected = "noselect";
-	if (_channal.indexOf(channalinfo.id) >= 0) {
+	if (_channal.indexOf(channalinfo.uid) >= 0) {
 		checked = "checked";
 		selected = "selected";
 	}
@@ -469,14 +469,14 @@ function render_channal_list(channalinfo) {
 	output += '<div class="tool_bar">';
 	output += '<div class="right">';
 	output += '<div class="pop_menu">';
-	output += render_icon_button("copy", "commit_init({src:'" + channalinfo.id + "'})", gLocal.gui.copy_to);
+	output += render_icon_button("copy", "commit_init({src:'" + channalinfo.uid + "'})", gLocal.gui.copy_to);
 	output += render_icon_button("ic_mode_edit", "", gLocal.gui.modify);
 	output += "</div>";
 	output += "</div>";
 	output += "</div>";
 
 	output +=
-		'<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
+		'<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.uid + "'></div>";
 	output += "<div class='head'>";
 	output += "<span class='head_img'>";
 	if (parseInt(channalinfo.power) == 30) {
@@ -493,7 +493,7 @@ function render_channal_list(channalinfo) {
 	output += "<div class='channal_list' >";
 
 	//  output += "<a href='../wiki/wiki.php?word=" + _word;
-	//  output += "&channal=" + channalinfo.id + "' >";
+	//  output += "&channal=" + channalinfo.uid + "' >";
 	switch (parseInt(channalinfo.status)) {
 		case 10:
 			output += "🔐";
@@ -514,7 +514,7 @@ function render_channal_list(channalinfo) {
 		}
 	}
 	//✋
-	output += "<a onclick=\"set_channal('" + channalinfo.id + "')\">";
+	output += "<a onclick=\"set_channal('" + channalinfo.uid + "')\">";
 
 	output += channalinfo["name"];
 

+ 34 - 36
public/app/term/note.php

@@ -61,30 +61,27 @@ $output = array();
 #查询有阅读权限的channel
 $channal_list = array();
 if (isset($_COOKIE["userid"])) {
-    PDO_Connect( _FILE_DB_CHANNAL_);
-    $query = "SELECT id from channal where owner = ?   limit 100";
-    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["userid"]));
+    PDO_Connect( _FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid from "._TABLE_CHANNEL_." where owner_uid = ?   limit 100";
+    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["user_uid"]));
     foreach ($Fetch_my as $key => $value) {
         # code...
-        $channal_list[] = $value["id"];
+        $channal_list[] = $value["uid"];
     }
 
     # 找协作的
-    $Fetch_coop = array();
-    $query = "SELECT channal_id FROM cooperation WHERE  user_id = ? ";
-    $coop_channal = PDO_FetchAll($query, array($_COOKIE["userid"]));
-    if (count($coop_channal) > 0) {
-        foreach ($coop_channal as $key => $value) {
-            # code...
-            $channal_list[] = $value["channal_id"];
-        }
-    }
+	$coop_channal = share_res_list_get($_COOKIE["user_uid"],2);
+	foreach ($coop_channal as $key => $value) {
+		# code...
+		$channal_list[] = $value["res_id"];
+	}
+	
     /*  创建一个填充了和params相同数量占位符的字符串 */
 
 }
 if (count($channal_list) > 0) {
     $channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
-    $channel_query = " OR channal IN ($channel_place_holders)";
+    $channel_query = " OR channel_uid IN ($channel_place_holders)";
 } else {
     $channel_query = "";
 }
@@ -155,15 +152,16 @@ foreach ($_data as $key => $value) {
     $translation = array();
     $tran_channal = array();
     try {
+		$query_col = "uid,channel_uid,content,language,status,editor_uid,modify_time";
         if (empty($_setting["channal"])) {
             if ($sentChannal == "") {
-                $query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0 and (status = 30 {$channel_query} )   order by modify_time DESC limit 1 ";
+                $query = "SELECT {$query_col} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND strlen >0 and (status = 30 {$channel_query} )   order by modify_time DESC limit 1 ";
                 $channal = "";
             } else {
-                $query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  AND channal = ?  limit 1 ";
+                $query = "SELECT {$query_col} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND strlen >0  AND channel_uid = ?  limit 1 ";
             }
         } else {
-            $query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  AND channal = ?  limit 1 ";
+            $query = "SELECT {$query_col} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND strlen >0  AND channel_uid = ?  limit 1 ";
             $channal = $_setting["channal"];
         }
 
@@ -177,22 +175,22 @@ foreach ($_data as $key => $value) {
                 $stmt->execute($parm);
                 $Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
                 if ($Fetch) {
-                    $tran = $Fetch["text"];
-                    $translation[] = array("id" => $Fetch["id"], 
+                    $tran = $Fetch["content"];
+                    $translation[] = array("id" => $Fetch["uid"], 
 										   "book"=>$bookId,
 										   "para"=>$para,
 										   "begin"=>$begin,
 										   "end"=>$end,
-										   "text" => $Fetch["text"], 
+										   "text" => $Fetch["content"], 
 										   "lang" => $Fetch["language"], 
-										   "channal" => $Fetch["channal"], 
+										   "channal" => $Fetch["channel_uid"], 
 										   "status" => $Fetch["status"], 
-										   "editor" => $Fetch["editor"],
-										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
+										   "editor" => $Fetch["editor_uid"],
+										   "editor_name"=>$_userinfo->getName($Fetch["editor_uid"]),
 										   "update_time"=>$Fetch["modify_time"]
 										);
-                    if (!empty($Fetch["channal"])) {
-                        $tran_channal[$Fetch["channal"]] = $Fetch["channal"];
+                    if (!empty($Fetch["channel_uid"])) {
+                        $tran_channal[$Fetch["channel_uid"]] = $Fetch["channel_uid"];
                     }
                 }
             } else {
@@ -201,21 +199,21 @@ foreach ($_data as $key => $value) {
                 $stmt->execute(array($bookId, $para, $begin, $end, $sentChannal));
                 $Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
                 if ($Fetch) {
-                    $tran = $Fetch["text"];
-                    $translation[] = array("id" => $Fetch["id"], 
+                    $tran = $Fetch["content"];
+                    $translation[] = array("id" => $Fetch["uid"], 
 											"book"=>$bookId,
 											"para"=>$para,
 											"begin"=>$begin,
 											"end"=>$end,
-										   "text" => $Fetch["text"], 
+										   "text" => $Fetch["content"], 
 										   "lang" => $Fetch["language"], 
-										   "channal" => $Fetch["channal"], 
+										   "channal" => $Fetch["channel_uid"], 
 										   "status" => $Fetch["status"], 
-										   "editor" => $Fetch["editor"],
-										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
+										   "editor" => $Fetch["editor_uid"],
+										   "editor_name"=>$_userinfo->getName($Fetch["editor_uid"]),
 										   "update_time"=>$Fetch["modify_time"]
 										);
-                    $tran_channal[$Fetch["channal"]] = $Fetch["channal"];
+                    $tran_channal[$Fetch["channel_uid"]] = $Fetch["channel_uid"];
                 }
             }
         } else {
@@ -226,17 +224,17 @@ foreach ($_data as $key => $value) {
                 $stmt->execute(array($bookId, $para, $begin, $end, $value));
                 $Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
                 if ($Fetch) {
-                    $translation[] = array("id" => $Fetch["id"],
+                    $translation[] = array("id" => $Fetch["uid"],
 										   "book"=>$bookId,
 										   "para"=>$para,
 										   "begin"=>$begin,
 										   "end"=>$end,
-										   "text" => $Fetch["text"], 
+										   "text" => $Fetch["content"], 
 										   "lang" => $Fetch["language"], 
 										   "channal" => $value, 
 										   "status" => $Fetch["status"], 
-										   "editor" => $Fetch["editor"],
-										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
+										   "editor" => $Fetch["editor_uid"],
+										   "editor_name"=>$_userinfo->getName($Fetch["editor_uid"]),
 										   "update_time"=>$Fetch["modify_time"]
 										);
 

+ 1 - 1
public/app/term/term_get.php

@@ -23,7 +23,7 @@ if (isset($_POST["words"])) {
             # code...
             $info = $channal_info->getChannal($value);
             if ($info) {
-                $channal_owner[$info["owner"]] = 1;
+                $channal_owner[$info["owner_uid"]] = 1;
             }
         }
         /*  创建一个填充了和params相同数量占位符的字符串 */

+ 35 - 19
public/app/ucenter/active.php

@@ -6,27 +6,43 @@ require_once "../public/php/define.php";
 
 function add_edit_event($type = 0, $data = null)
 {
+	$active_type[10] = "channel_update";
+$active_type[11] = "channel_create";
+$active_type[20] = "article_update";
+$active_type[21] = "article_create";
+$active_type[30] = "dict_lookup";
+$active_type[40] = "term_update";
+$active_type[42] = "term_create";
+$active_type[41] = "term_lookup";
+$active_type[60] = "wbw_update";
+$active_type[61] = "wbw_create";
+$active_type[70] = "sent_update";
+$active_type[71] = "sent_create";
+$active_type[80] = "collection_update";
+$active_type[81] = "collection_create";
+$active_type[90] = "nissaya_open";
+
     date_default_timezone_set("UTC");
     define("MAX_INTERVAL", 600000);
     define("MIN_INTERVAL", 60000);
 
-    if (isset($_COOKIE["userid"])) {
-        $dns = "" . _FILE_DB_USER_ACTIVE_;
-        $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    if (isset($_COOKIE["user_id"])) {
+        $dns = _FILE_DB_USER_ACTIVE_;
+        $dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, 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";
+        $query = "SELECT id, op_start,op_end, hit  FROM "._TABLE_USER_OPERATION_FRAME_." WHERE user_id = ? order by op_end DESC";
         $stmt = $dbh->prepare($query);
-        $stmt->execute(array($_COOKIE["userid"]));
+        $stmt->execute(array($_COOKIE["user_id"]));
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $new_record = false;
         $currTime = mTime();
         if ($row) {
             //找到,判断是否超时,超时新建,未超时修改
             $id = (int) $row["id"];
-            $start_time = (int) $row["start"];
-            $endtime = (int) $row["end"];
+            $start_time = (int) $row["op_start"];
+            $endtime = (int) $row["op_end"];
             $hit = (int) $row["hit"];
             if ($currTime - $endtime > MAX_INTERVAL) {
                 //超时新建
@@ -50,10 +66,10 @@ function add_edit_event($type = 0, $data = null)
         $this_active_time = 0; //时间增量
         if ($new_record) {
             #新建
-            $query = "INSERT INTO edit ( user_id, start , end  , duration , hit , timezone )  VALUES  ( ? , ? , ? , ? , ? ,?) ";
+            $query = "INSERT INTO "._TABLE_USER_OPERATION_FRAME_." ( user_id, op_start , op_end  , duration , hit , timezone,created_at )  VALUES  ( ? , ? , ? , ? , ? ,?,to_timestamp(?)) ";
             $sth = $dbh->prepare($query);
             #最小思考时间
-            $sth->execute(array($_COOKIE["userid"], ($currTime - MIN_INTERVAL), $currTime, MIN_INTERVAL, 1, $client_timezone));
+            $sth->execute(array($_COOKIE["user_id"], ($currTime - MIN_INTERVAL), $currTime, MIN_INTERVAL, 1, $client_timezone,($currTime - MIN_INTERVAL)/1000));
             if (!$sth || ($sth && $sth->errorCode() != 0)) {
                 $error = $dbh->errorInfo();
             }
@@ -61,7 +77,7 @@ function add_edit_event($type = 0, $data = null)
         } else {
             #修改
             $this_active_time = $currTime - $endtime;
-            $query = "UPDATE edit SET end = ? , duration = ? , hit = ? WHERE id = ? ";
+            $query = "UPDATE "._TABLE_USER_OPERATION_FRAME_." SET op_end = ? , duration = ? , hit = ? , updated_at=now() WHERE id = ? ";
             $sth = $dbh->prepare($query);
             $sth->execute(array($currTime, ($currTime - $start_time), ($hit + 1), $id));
             if (!$sth || ($sth && $sth->errorCode() != 0)) {
@@ -76,9 +92,9 @@ function add_edit_event($type = 0, $data = null)
         $client_date = strtotime(gmdate("Y-m-d", $client_currtime / 1000)) * 1000;
 
         #查询是否存在
-        $query = "SELECT id,duration,hit  FROM active_index WHERE user_id = ? and date = ?";
+        $query = "SELECT id,duration,hit  FROM "._TABLE_USER_OPERATION_DAILY_." WHERE user_id = ? and date_int = ?";
         $sth = $dbh->prepare($query);
-        $sth->execute(array($_COOKIE["userid"], $client_date));
+        $sth->execute(array($_COOKIE["user_id"], $client_date));
         $row = $sth->fetch(PDO::FETCH_ASSOC);
         if ($row) {
             #更新
@@ -86,7 +102,7 @@ function add_edit_event($type = 0, $data = null)
             $duration = (int) $row["duration"];
             $hit = (int) $row["hit"];
             #修改
-            $query = "UPDATE active_index SET duration = ? , hit = ? WHERE id = ? ";
+            $query = "UPDATE "._TABLE_USER_OPERATION_DAILY_." SET duration = ? , hit = ? , updated_at = now() WHERE id = ? ";
             $sth = $dbh->prepare($query);
             $sth->execute(array(($duration + $this_active_time), ($hit + 1), $id));
             if (!$sth || ($sth && $sth->errorCode() != 0)) {
@@ -94,10 +110,10 @@ function add_edit_event($type = 0, $data = null)
             }
         } else {
             #新建
-            $query = "INSERT INTO active_index ( user_id, date , duration , hit )  VALUES  ( ? , ? , ? , ?  ) ";
+            $query = "INSERT INTO "._TABLE_USER_OPERATION_DAILY_." ( user_id, date_int , date_at, duration , hit )  VALUES  ( ? , ? ,to_timestamp(?), ? , ?  ) ";
             $sth = $dbh->prepare($query);
             #最小思考时间
-            $sth->execute(array($_COOKIE["userid"], $client_date, MIN_INTERVAL, 1));
+            $sth->execute(array($_COOKIE["user_id"], $client_date, $client_date/1000, MIN_INTERVAL, 1));
             if (!$sth || ($sth && $sth->errorCode() != 0)) {
                 $error = $dbh->errorInfo();
             }
@@ -106,13 +122,13 @@ function add_edit_event($type = 0, $data = null)
 
         #更新log
         if ($type > 0) {
-            $dns = "" . _FILE_DB_USER_ACTIVE_LOG_;
-            $dbh_log = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+            $dns = _FILE_DB_USER_ACTIVE_LOG_;
+            $dbh_log = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, 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 "._TABLE_USER_OPERATION_LOG_." ( user_id, op_type_id ,op_type , content , create_time , timezone )  VALUES  ( ? , ? , ? , ? , ? ,? ) ";
             $sth = $dbh_log->prepare($query);
-            $sth->execute(array($_COOKIE["uid"], $type, $data, $currTime, $client_timezone));
+            $sth->execute(array($_COOKIE["user_id"], $type,$active_type[$type], $data, $currTime, $client_timezone));
             if (!$sth || ($sth && $sth->errorCode() != 0)) {
                 $error = $dbh->errorInfo();
             }

+ 9 - 8
public/app/ucenter/active_get.php

@@ -6,25 +6,26 @@ require_once "../public/function.php";
 $output = array();
 if (isset($_GET["userid"])) {
     $userid = $_GET["userid"];
-} else if (isset($_COOKIE["userid"])) {
-    $userid = $_COOKIE["userid"];
+} else if (isset($_COOKIE["user_id"])) {
+    $userid = $_COOKIE["user_id"];
 } else {
     exit;
 }
-if (isset($userid)) {
-    $dns = "" . _FILE_DB_USER_ACTIVE_;
-    $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+
+
+    $dns = _FILE_DB_USER_ACTIVE_;
+    $dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-    $query = "SELECT date,duration,hit  FROM active_index WHERE user_id = ? ";
+    $query = "SELECT date_int,duration,hit  FROM "._TABLE_USER_OPERATION_DAILY_." 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, ".", ""), $row["hit"]);
+        $output[] = array($row["date_int"], number_format($last, 3, ".", ""), number_format($curr, 3, ".", ""), number_format($last, 3, ".", ""), number_format($curr, 3, ".", ""), $row["hit"]);
         $last = $curr;
     }
 
     $json = json_encode($output);
     echo str_replace('"', '', $json);
-}
+

+ 5 - 6
public/app/ucenter/active_log_get.php

@@ -2,14 +2,13 @@
 //显示log
 require_once '../config.php';
 
-if (isset($_COOKIE["uid"]) && isset($_GET["start"]) && isset($_GET["end"])) {
-
-    $dns = "" . _FILE_DB_USER_ACTIVE_LOG_;
-    $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+if (isset($_COOKIE["user_id"]) && isset($_GET["start"]) && isset($_GET["end"])) {
+    $dns = _FILE_DB_USER_ACTIVE_LOG_;
+    $dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-    $query = "SELECT time , active,content,timezone  FROM log WHERE user_id = ? AND (time BETWEEN ? AND ?) ";
+    $query = "SELECT create_time , op_type_id,content,timezone  FROM "._TABLE_USER_OPERATION_LOG_." WHERE user_id = ? AND (create_time BETWEEN ? AND ?) ";
     $stmt = $dbh->prepare($query);
-    $stmt->execute(array($_COOKIE["uid"], $_GET["start"], $_GET["end"]));
+    $stmt->execute(array($_COOKIE["user_id"], $_GET["start"], $_GET["end"]));
     $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
     echo json_encode($row, JSON_UNESCAPED_UNICODE);
 } else {

+ 5 - 5
public/app/ucenter/active_log_list.php

@@ -6,7 +6,7 @@ require_once '../config.php';
 require_once "../public/function.php";
 require_once "../public/php/define.php";
 
-if (isset($_COOKIE["uid"])) {
+if (isset($_COOKIE["user_id"])) {
 
     $active_type[10] = "_CHANNEL_EDIT_";
     $active_type[11] = "_CHANNEL_NEW_";
@@ -22,12 +22,12 @@ if (isset($_COOKIE["uid"])) {
     $active_type[81] = "_COLLECTION_NEW_";
     $active_type[90] = "_NISSAYA_FIND_";
 
-    $dns = "" . _FILE_DB_USER_ACTIVE_LOG_;
-    $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+    $dns = _FILE_DB_USER_ACTIVE_LOG_;
+    $dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-    $query = "SELECT time,active,content,timezone  FROM log WHERE user_id = ? ";
+    $query = "SELECT create_time,op_type_id,content,timezone  FROM "._TABLE_USER_OPERATION_LOG_." WHERE user_id = ? ";
     $stmt = $dbh->prepare($query);
-    $stmt->execute(array($_COOKIE["uid"]));
+    $stmt->execute(array($_COOKIE["user_id"]));
     echo "<table>";
 
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

+ 148 - 0
public/app/ucenter/setting-test.html

@@ -0,0 +1,148 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<script>
+var setting = [
+	{
+		"id":"edit",
+		"type":"parent",
+		"children":[
+			{
+				"id":"font",
+				"type":"parent",
+				"children":[
+					{
+						"id":"size",
+						"type":"number",
+						"defualt":14,
+						"max":100,
+						"min":9
+					},
+					{
+						"id":"family",
+						"type":"input",
+						"defualt":"mono"
+					},
+					{
+						"id":"weight",
+						"type":"select",
+						"options":[300,400,500],
+						"defualt":500
+					}
+				]
+			}
+		]
+	},
+	{
+		"id":"channel",
+		"type":"parent",
+		"children":[
+			{
+				"id":"showname",
+				"type":"checkbox",
+				"defualt":true
+			},
+			{
+				"id":"list",
+				"type":"channel.list",
+				"defualt":[1,2]
+			}
+		]
+	}
+]
+var user = {
+	"edit.font.size":15,
+	"edit.font.weight":400,
+	"channel.showname":false,
+}
+
+			function render_setting(param){
+				let _path=new Array();
+				let html ="";
+				for (const iterator of param.data) {
+					html += render_setting_node(iterator,param.userdata,_path);
+				}
+				param.div.innerHTML = html;
+			}
+			function render_setting_node(node,userdata,path){
+				let html = "";
+				path.push(node);
+				let fullpath = new Array();
+				for (const it of path) {
+					fullpath.push(it.id);
+				}
+				let srtFullPath = fullpath.join(".");
+				html += "<div class='setting_cell'>";
+				html += "<h3>";
+				html += node.id;
+				html += "</h3>";
+				html += "<div class='subtitle'>"+srtFullPath+"</div>";
+				html += "<div>";
+
+				let nodeValue = null;
+				if (userdata.hasOwnProperty.call(userdata, srtFullPath)) {
+					nodeValue = userdata[srtFullPath];
+				}else{
+					nodeValue = node.defualt;
+				}
+				
+				
+				switch(node.type){
+					case "input":
+						html += "<input type='input' value='"+nodeValue+"' />";
+						break;
+					case "number":
+						html += "<input type='input' value='"+nodeValue+"' />";
+						html += "默认值:"+ node.defualt;
+						break;
+					case "checkbox":
+					html += "<div>";
+						let checked = "";
+						if(nodeValue){
+							checked = "checked"
+						}							
+						html += "<input type='checkbox' "+checked+" />";
+						break;
+					case "select":
+						html += "<select>";
+						for (const op of node.options) {
+							html += "<option value='"+op+"' ";
+							if(op==nodeValue){
+								html += " selected ";
+							}
+							html +=">";
+							html += op;
+							if(op==node.defualt){
+								html += "默认";
+							}
+							html += "</option>";							
+						}
+						html += "</select>";
+
+						break;
+					case "parent":
+						for (const iterator of node.children) {
+							html += render_setting_node(iterator,userdata,path);
+						}
+						break;
+				}
+				html += "</div>";
+				html += "</div>";				
+				path.pop();
+				return html;
+			}
+		</script>
+	</head>
+	<body>
+<div id="setting"></div>
+<script>
+	render_setting(
+		{
+		"div":document.querySelector("#setting"),
+		"data":setting,		
+		"userdata":user	
+		}
+	)
+</script>
+	</body>
+	</html>

+ 118 - 0
public/app/udict/my_dict_list.js

@@ -0,0 +1,118 @@
+import { Grid, h } from "../../node_modules/gridjs/dist/gridjs.module.js";
+export var _rowSelected =   new Array();
+const grid = new gridjs.Grid({
+	sort: {
+		multiColumn: false,
+		server: {
+		  url: (prev, columns) => {
+		   if (!columns.length) return prev;
+		   
+		   const col = columns[0];
+		   const dir = col.direction === 1 ? 'asc' : 'desc';
+		   let colName = ['id', 'word','type','grammar','mean','factors','confidence','updated_at'][col.index];
+		   
+		   return `${prev}&order=${colName}&dir=${dir}`;
+		 }
+		}
+	  },
+	columns: [
+		{ 
+			name: 'Sel',
+			hidden: false,
+			sort: false,
+			formatter: (cell, row) => {
+			return h('input', {
+				type:'checkbox',
+				className: 'py-2 mb-4 px-4 border',
+				id:"cb-"+row.cells[1].data,
+				onClick: () =>{
+					let id = row.cells[1].data;
+					if(document.querySelector("#cb-"+id).checked){
+						_rowSelected.push(id);
+						console.log("checked",_rowSelected);
+					}else{
+						_rowSelected.splice(_rowSelected.findIndex(item => item ===id),1);
+						console.log("remove",_rowSelected);
+					}
+				} 
+			}, '');
+			}
+      	},
+		{
+			name: 'id',
+			hidden: true
+		},
+		'word',
+		{
+			name:'type',
+			sort: false,
+		},
+		{
+			name:'grammar',
+			sort: false,
+		},
+		{
+			name:'mean',
+			sort: false,
+		},
+		{
+			name:'factors',
+			sort: false,
+		},
+		'confidence','created_at',
+		{ 
+			name: 'Actions',
+			sort: false,
+			hidden:true,
+			formatter: (cell, row) => {
+			return h('button', {
+				className: 'py-2 mb-4 px-4 border rounded-md text-white bg-blue-600',
+				onClick: () =>{
+					
+					
+				} 
+			}, 'Edit');
+			}
+      	}
+	],
+	server: {
+		url: '../api/user_dicts.php?op=index&view=user',
+		then: data => data.data.rows.map(card => [null,card.id,card.word, card.type, card.grammar, card.mean, card.factors, card.confidence, card.updated_at,null]),
+		total: data => data.data.count
+	  },
+	pagination: {
+		enabled: true,
+		limit:30,
+		server: {
+			url: (prev, page, limit) => `${prev}&limit=${limit}&offset=${page * limit}`
+		  }
+	},
+	search: {
+		server: {
+		  url: (prev, keyword) => `${prev}&search=${keyword}`
+		}
+	  },
+	resizable: true,
+  }).render(document.getElementById("userfilelist"));
+
+//grid.on('rowClick', (...args) => console.log('row: ' + JSON.stringify(args), args));
+//grid.on('cellClick', (...args) => console.log(cell,args));
+
+document.querySelector("#to_recycle").onclick = function(){
+	if(_rowSelected.length>0){
+		if(confirm(`删除${_rowSelected.length}个单词,此操作不能恢复。`)){
+			$.getJSON("../api/user_dicts.php",
+			{
+				op:'delete',
+				id:JSON.stringify(_rowSelected)
+			},
+			function(data){
+				if(data.ok){
+					grid.forceRender();
+					alert(`delete ok `);
+				}
+			});			
+		}
+
+	}
+}

+ 11 - 104
public/app/udict/my_dict_list.php

@@ -1,7 +1,7 @@
 <?php
 require_once '../studio/index_head.php';
 ?>
-<body id="file_list_body" onLoad="course_list()">
+<body id="file_list_body" >
 
 	<script >
 	var gCurrPage="udict";
@@ -28,7 +28,7 @@ require_once '../studio/index_head.php';
 	}
 	</style>
 
-	<?php
+<?php
 require_once '../studio/index_tool_bar.php';
 ?>
 
@@ -54,7 +54,7 @@ require_once '../studio/index_tool_bar.php';
 
 		<span class="icon_btn_div">
 			<span class="icon_btn_tip"><?php echo $_local->gui->recycle_bin; ?></span>
-			<button id="to_recycle" type="button" class="icon_btn" onclick="file_del()" title=" ">
+			<button id="to_recycle" type="button" class="icon_btn" title="delete">
 				<svg class="icon">
 					<use xlink:href="../studio/svg/icon.svg#ic_delete"></use>
 				</svg>
@@ -63,107 +63,14 @@ require_once '../studio/index_tool_bar.php';
 	</div>
 
 </div>
-
-<div id="userfilelist">
-<?php
-//
-
-require_once "../config.php";
-require_once "../public/_pdo.php";
-require_once '../public/load_lang.php';
-require_once '../ucenter/function.php';
-
-if (isset($_GET["page"])) {
-    $iCurrPage = $_GET["page"];
-} else {
-    $iCurrPage = 0;
-}
-$iOnePage = 300;
-
-PDO_Connect(_FILE_DB_WBW_);
-$query = "select count(word_index) as co  from user_index where user_id={$UID}";
-$allWord = PDO_FetchOne($query);
-$iCountWords = $allWord;
-
-if ($iCountWords == 0) {
-    echo "<div id='setting_user_dict_count'>您的用户字典中没有单词。</div>";
-} else {
-    echo "<div>{$_local->gui->search}<span style='display:inline-block;width:20em;'><input type='input'  /></span></div>";
-    $iPages = ceil($iCountWords / $iOnePage);
-    if ($iCurrPage > $iPages) {
-        $iCurrPage = $iPages;
-    }
-    $begin = $iCurrPage * $iOnePage;
-    $query = "select word_index  from user_index where user_id={$UID} order by id DESC limit {$begin},{$iOnePage} ";
-
-    $allWord = PDO_FetchAll($query);
-    $strQuery = "('";
-    foreach ($allWord as $one) {
-        $strQuery .= $one["word_index"] . "','";
-    }
-    $strQuery = substr($strQuery, 0, strlen($strQuery) - 2);
-    $strQuery .= ")";
-    $query = "select *  from dict where id in {$strQuery} order by time DESC";
-    $allWords = PDO_FetchAll($query);
-    ?>
-    <div id="setting_user_dict_nav">
-    <?php
-if ($iCurrPage == 0) {
-        echo "<span>{$_local->gui->first_page}</span>";
-        echo "<span>{$_local->gui->previous_page}</span>";
-    } else {
-        echo "<span><a href=\"../udict/my_dict_list.php?page=0\">{$_local->gui->first_page}</a></span>";
-        $prevPage = $iCurrPage - 1;
-        echo "<span><a href=\"../udict/my_dict_list.php?page={$prevPage}\">{$_local->gui->previous_page}</a></span>";
-    }
-
-    echo "<span style='display:inline-block;white-space: nowrap;'>{$_local->gui->page_num}<input type=\"input\" value=\"" . ($iCurrPage + 1) . "\" style='width:3em;height:1em;'/>/{$iPages}</span>";
-
-    if ($iCurrPage < $iPages - 1) {
-        echo "<span><a href=\"../udict/my_dict_list.php?page=" . ($iCurrPage + 1) . "\">{$_local->gui->next_page}</a></span>";
-        echo "<span><a href=\"../udict/my_dict_list.php?page=" . ($iPages - 1) . "\">{$_local->gui->last_page}</a></span>";
-
-    } else {
-        echo "<span>{$_local->gui->next_page}</span><span>{$_local->gui->last_page}</span>";
-    }
-    echo "<span id='setting_user_dict_count'>{$_local->gui->vocabulary}:{$iCountWords}</span>";
-    ?>
-    </div>
-    <table style="width:95%;">
-        <tr style="padding:5px;font-weight: bold;">
-            <td style=''><input type="checkbox" /></td>
-            <td style=''><?php echo $_local->gui->spell; //拼写?></td>
-            <td style=''><?php echo $_local->gui->wordtype; //单词类型?></td>
-            <td style=''><?php echo $_local->gui->gramma; //语法?></td>
-            <td style=''><?php echo $_local->gui->g_mean; //意思?></td>
-            <td style=''><?php echo $_local->gui->parent; //语基?></td>
-            <td style=''><?php echo $_local->gui->dictsouce; //词条来源?></td>
-            <td style=''><?php echo $_local->gui->citations; //引用数?></td>
-            <td style=''></td>
-        </tr>
-    <?php
-foreach ($allWords as $word) {
-        echo '<tr class="file_list_row" style="padding:5px;display: table-row;">';
-        echo "<td style=''><input type=\"checkbox\" /></td>";
-        echo "<td style='max-width:12vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;'>{$word["pali"]}</td>";
-        echo "<td style=''>".$word["type"]."</td>";
-        echo "<td style=''>{$word["gramma"]}</td>";
-        echo "<td style='max-width:12vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;'>{$word["mean"]}</td>";
-        echo "<td style='max-width:12vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;'>{$word["parent"]}</td>";
-        if ($word["creator"] == $UID) {
-            echo "<td style=''>{$_local->gui->original}</td>";
-        } else {
-            echo "<td style=''>{$_local->gui->reference}</td>";
-        }
-        echo "<td style=''>{$word["ref_counter"]}</td>";
-        echo "<td style=''><button>删除</button></td>";
-        echo "</tr>";
-    }
-}
-?>
-    </table>
-
-
+<script src="../../node_modules/gridjs/dist/gridjs.umd.js"></script>
+<link
+      href="../../node_modules/gridjs/dist/theme/mermaid.min.css"
+      rel="stylesheet"
+    />
+
+<div id="userfilelist"></div>
+<script  type="module" src="my_dict_list.js"></script>
 <?php
 require_once '../studio/index_foot.php';
 ?>

+ 6 - 6
public/app/uhome/foot_step_data.php

@@ -45,19 +45,19 @@ if (isset($_GET['timeZone'])) {
 }
 
 // Read and parse our events JSON file into an array of event data arrays.
-$dns = "" . _FILE_DB_USER_ACTIVE_;
-$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns = _FILE_DB_USER_ACTIVE_;
+$dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
-$query = "SELECT id , start, end,duration, hit  FROM edit WHERE user_id = ?";
+$query = "SELECT id , op_start, op_end , duration, hit  FROM "._TABLE_USER_OPERATION_FRAME_." WHERE user_id = ?";
 $stmt = $dbh->prepare($query);
-$stmt->execute(array($_GET["userid"]));
+$stmt->execute(array($_COOKIE["user_id"]));
 $allData = $stmt->fetchAll(PDO::FETCH_ASSOC);
 $input_arrays = array();
 foreach ($allData as $key => $value) {
     # code...
     $strDuration = covertTimeToString($value["duration"] / 1000) . "-" . $value["hit"] . "次操作";
-    $start = date("Y-m-d\TH:i:s+00:00", $value["start"] / 1000);
-    $end = date("Y-m-d\TH:i:s+00:00", $value["end"] / 1000);
+    $start = date("Y-m-d\TH:i:s+00:00", $value["op_start"] / 1000);
+    $end = date("Y-m-d\TH:i:s+00:00", $value["op_end"] / 1000);
     $input_arrays[] = array("id" => $value["id"],
         "title" => $strDuration,
         "start" => $start,

+ 5 - 5
public/app/upgrade/upgrade_pali_toc.php

@@ -24,14 +24,14 @@ $dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 $valid_book = array();
 
 #第一步 查询有多少书有译文
-$query = "SELECT book from sentence where strlen>0 and begin<>''  and language<>'' and book <1000  group by book";
+$query = "SELECT book_id as book from "._TABLE_SENTENCE_." where strlen>0 and word_start is not null  and language<>'' and book_id <1000  group by book_id";
 $stmt = $dbh_sent->prepare($query);
 $stmt->execute();
 $valid_book = $stmt->fetchAll(PDO::FETCH_ASSOC);
 echo "book:" . count($valid_book) . "<br>\n";
 
 #第一步 查询语言
-$query = "SELECT language from sentence where strlen>0 and begin<>''  and language<>'' and book <1000   group by language";
+$query = "SELECT language from "._TABLE_SENTENCE_." where strlen>0 and word_start is not null  and language<>'' and book_id <1000   group by language";
 $stmt = $dbh_sent->prepare($query);
 $stmt->execute();
 $result_lang = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -52,14 +52,14 @@ foreach ($result_lang as $lang) {
     # 第二步 生成para progress 1,2,15,zh-tw
 
     #查询该语言有多少段
-    $query = "SELECT book,paragraph from sentence where strlen>0 and language= ? and book<1000 group by book,paragraph";
+    $query = "SELECT book_id as book,paragraph from "._TABLE_SENTENCE_." where strlen>0 and language= ? and book<1000 group by book,paragraph";
     $stmt = $dbh_sent->prepare($query);
     $stmt->execute(array($lang["language"]));
     $result_para = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($result_para as $para) {
 
         # 查询每个段落的等效巴利语字符数
-        $query = "SELECT begin from sentence where strlen>0 and language= ? and book = ? and paragraph = ? and begin<>'' group by begin,end";
+        $query = "SELECT word_start from "._TABLE_SENTENCE_." where strlen>0 and language= ? and book_id = ? and paragraph = ? and word_start is not null group by word_start,word_end";
         $stmt = $dbh_sent->prepare($query);
         $stmt->execute(array($lang["language"], $para["book"], $para["paragraph"]));
         $result_sent = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -74,7 +74,7 @@ foreach ($result_lang as $lang) {
             $param[] = $para["paragraph"];
             foreach ($result_sent as $sent) {
                 # code...
-                $param[] = (int) $sent["begin"];
+                $param[] = (int) $sent["word_start"];
             }
             $sth->execute($param);
             $result_strlen = $sth->fetch(PDO::FETCH_ASSOC);

+ 37 - 43
public/app/usent/function.php

@@ -8,7 +8,7 @@ function update_historay($sent_id, $user_id, $text, $landmark)
 {
     # 更新historay
     PDO_Connect("" . _FILE_DB_USER_SENTENCE_HISTORAY_);
-    $query = "INSERT INTO sent_historay (sent_id,  user_id,  text,  date, landmark) VALUES (? , ? , ? , ? , ? )";
+    $query = "INSERT INTO "._TABLE_SENTENCE_HISTORAY_." (sent_uid,  user_uid,  content,  date, landmark) VALUES (? , ? , ? , ? , ? )";
     $stmt = PDO_Execute($query,
         array($sent_id,
             $user_id,
@@ -30,13 +30,13 @@ class SentPr{
 	private $dbh_sent;
 	private $redis;
 	public function __construct($redis=false) {
-        $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
 		$this->dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 		$this->redis=$redis;
 	}
 	public function getNewPrNumber($book,$para,$begin,$end,$channel){
 		if ($this->dbh_sent) {
-            $query = "SELECT count(*) as ct FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 ";
+            $query = "SELECT count(*) as ct FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=? and status=1 ";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($book,$para,$begin,$end,$channel));
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -53,7 +53,7 @@ class SentPr{
 	}
 	public function getAllPrNumber($book,$para,$begin,$end,$channel){
 		if ($this->dbh_sent) {
-            $query = "SELECT count(*) as ct FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=?  ";
+            $query = "SELECT count(*) as ct FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=?  ";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($book,$para,$begin,$end,$channel));
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -71,7 +71,7 @@ class SentPr{
 
 	public function getPrData($book,$para,$begin,$end,$channel){
 		if ($this->dbh_sent) {
-            $query = "SELECT id,book,paragraph,begin,end,channel,text,editor,modify_time FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 limit 0,100";
+            $query = "SELECT id,book_id as book,paragraph,word_start as begin,word_end as end,channel_uid as channel,content as text,editor_uid as editor,modify_time FROM "._TABLE_SENTENCE_PR_." WHERE book_id = ? and paragraph= ? and word_start=? and word_end=? and channel_uid=? and status=1 limit 100";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($book,$para,$begin,$end,$channel));
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -88,7 +88,7 @@ class SentPr{
 	}
 	public function getPrDataById($id){
 		if ($this->dbh_sent) {
-            $query = "SELECT id,book,paragraph,begin,end,channel,text,editor,modify_time FROM sent_pr WHERE id = ? ";
+            $query = "SELECT id,book_id as book,paragraph,word_start as begin,word_end as end,channel_uid as channel,content as text,editor_uid as editor,modify_time FROM "._TABLE_SENTENCE_PR_." WHERE id = ? ";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($id));
             $result = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -106,7 +106,7 @@ class SentPr{
 
 	public function setPrData($id,$text){
 		if ($this->dbh_sent) {
-            $query = "UPDATE sent_pr set text=? ,modify_time=?  WHERE id = ? and editor= ? ";
+            $query = "UPDATE "._TABLE_SENTENCE_PR_." set content=? ,modify_time=? , updated_at = now() WHERE id = ? and editor_uid= ? ";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($text,mTime(),$id,$_COOKIE["userid"]));
             
@@ -137,11 +137,13 @@ class Sent_DB
     private $dbh_sent;
 	private $dbh_his;
 	private $errorMsg="";
+	private $selectCol="uid,parent_uid,block_uid,channel_uid,book_id,paragraph,word_start,word_end,author,editor_uid,content,language,version,status,strlen,modify_time,create_time";
+	private $updateCol="";
     public function __construct($redis=false) {
-        $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, "", "",array(PDO::ATTR_PERSISTENT=>true));
+        $this->dbh_sent = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
 		$this->dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 		
-		$this->dbh_his = new PDO(_FILE_DB_USER_SENTENCE_HISTORAY_, "", "",array(PDO::ATTR_PERSISTENT=>true));
+		$this->dbh_his = new PDO(_FILE_DB_USER_SENTENCE_HISTORAY_, _DB_USERNAME_, _DB_PASSWORD_,array(PDO::ATTR_PERSISTENT=>true));
         $this->dbh_his->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 	}
 	public function getError(){
@@ -150,7 +152,7 @@ class Sent_DB
 
 	#获取单个句子数据
 	public function getSent($book,$para,$begin,$end,$channel){
-		$query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND channal = ?  ";
+		$query = "SELECT {$this->selectCol} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND channel_uid = ?  ";
 		$stmt = $this->dbh_sent->prepare($query);
 		if($stmt){
 			$stmt->execute(array($book,$para,$begin,$end,$channel));
@@ -162,10 +164,10 @@ class Sent_DB
 		}
 	}
 	public function getSentDefaultByLan($book,$para,$begin,$end,$lang){
-		$query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND channal = ?  ";
+		$query = "SELECT {$this->selectCol} FROM "._TABLE_SENTENCE_." WHERE book_id= ? AND paragraph= ? AND word_start= ? AND word_end= ?  AND language = ? ";
 		$stmt = $this->dbh_sent->prepare($query);
 		if($stmt){
-			$stmt->execute(array($book,$para,$begin,$end,$channel));
+			$stmt->execute(array($book,$para,$begin,$end,$lang));
 			$fetchDest = $stmt->fetch(PDO::FETCH_ASSOC);
 			return $fetchDest;
 		}
@@ -183,23 +185,23 @@ class Sent_DB
 			$this->dbh_sent->beginTransaction();
 
 			if(isset($arrData[0]["book"]) && isset($arrData[0]["paragraph"]) && isset($arrData[0]["begin"]) && isset($arrData[0]["end"]) && isset($arrData[0]["channal"])){
-				$query = "UPDATE sentence SET text = ? , strlen = ? , editor=?, modify_time= ? , receive_time = ?  where  book = ? and paragraph=? and [begin]=? and [end]=? and channal=?  ";
+				$query = "UPDATE "._TABLE_SENTENCE_." SET content = ? , strlen = ? , editor_uid=?, modify_time= ? ,updated_at=now()  where  book_id = ? and paragraph=? and word_start=? and word_end=? and channel_uid=?  ";
 				$sth = $this->dbh_sent->prepare($query);
 				foreach ($arrData as $data) {
 					if(!isset($data["modify_time"])){
 						$data["modify_time"] = mTime();
 					}
-					$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"]));
+					$sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],mTime(),$data["book"],$data["paragraph"],$data["begin"],$data["end"],$data["channal"]));
 				}
 			}
 			else if(isset($arrData[0]["id"])){
-				$query = "UPDATE sentence SET text = ? , strlen = ? , editor=?, modify_time= ? ,receive_time = ?   where  id= ?  ";
+				$query = "UPDATE "._TABLE_SENTENCE_." SET content = ? , strlen = ? , editor_uid=?, modify_time= ? ,updated_at = now()   where  uid= ?  ";
 				$sth = $this->dbh_sent->prepare($query);
 				foreach ($arrData as $data) {
 					if(!isset($data["modify_time"])){
 						$data["modify_time"]=mTime();
 					}
-					$sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],$data["modify_time"],mTime(),$data["id"]));
+					$sth->execute(array($data["text"],mb_strlen($data["text"],"UTF-8"),$data["editor"],mTime(),$data["id"]));
 				}				
 			}
 
@@ -230,26 +232,24 @@ class Sent_DB
 		if (count($arrData) > 0) {
 			//add_edit_event(_SENT_NEW_, "{$newList[0]["book"]}-{$newList[0]["paragraph"]}-{$newList[0]["begin"]}-{$newList[0]["end"]}@{$newList[0]["channal"]}");
 			$this->dbh_sent->beginTransaction();
-			$query = "INSERT INTO sentence (id,
-											parent,
-											book,
+			$query = "INSERT INTO "._TABLE_SENTENCE_." (uid,
+											parent_uid,
+											book_id,
 											paragraph,
-											begin,
-											end,
-											channal,
-											tag,
+											word_start,
+											word_end,
+											channel_uid,
 											author,
-											editor,
-											text,
+											editor_uid,
+											content,
 											language,
-											ver,
+											version,
 											status,
 											strlen,
 											modify_time,
-											receive_time,
 											create_time
 											)
-								VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+								VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 			$sth = $this->dbh_sent->prepare($query);
 
 			#查询channel语言
@@ -282,7 +282,6 @@ class Sent_DB
 					$data["begin"],
 					$data["end"],
 					$data["channal"],
-					isset($data["tag"]) ? $data["tag"] : "",
 					$data["author"],
 					$data["editor"],
 					$data["text"],
@@ -291,7 +290,6 @@ class Sent_DB
 					$status,
 					mb_strlen($data["text"], "UTF-8"),
 					$data["modify_time"],
-					$data["receive_time"],
 					$data["create_time"]
 				));
 			}
@@ -320,24 +318,22 @@ class Sent_DB
 			return true;
 		}
 		$this->dbh_sent->beginTransaction();
-		$query = "INSERT INTO sent_pr (id,
-							book,
+		$query = "INSERT INTO "._TABLE_SENTENCE_PR_." (
+							book_id,
 							paragraph,
-							begin,
-							end,
-							channel,
-							tag,
+							word_start,
+							word_end,
+							channel_uid,
 							author,
-							editor,
-							text,
+							editor_uid,
+							content,
 							language,
 							status,
 							strlen,
 							modify_time,
-							receive_time,
 							create_time
 							)
-							VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+							VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 		$stmt = $this->dbh_sent->prepare($query);
 
 		foreach ($arrData as $data) {
@@ -349,7 +345,6 @@ class Sent_DB
 							$data["end"],
 							$data["channal"],
 							"",
-							"[]",
 							$data["editor"],
 							$data["text"],
 							$data["language"],
@@ -357,7 +352,6 @@ class Sent_DB
 							mb_strlen($data["text"], "UTF-8"),
 							mTime(),
 							mTime(),
-							mTime(),
 							));
 		}
 		$this->dbh_sent->commit();
@@ -381,7 +375,7 @@ class Sent_DB
 		}
 		$this->dbh_his->beginTransaction();
 		# 更新historay
-		$query = "INSERT INTO sent_historay (sent_id,  user_id,  text,  date, landmark) VALUES (? , ? , ? , ? , ? )";
+		$query = "INSERT INTO "._TABLE_SENTENCE_HISTORAY_." (sent_uid,  user_uid,  content,  date, landmark) VALUES (? , ? , ? , ? , ? )";
 		$stmt = $this->dbh_his->prepare($query);
 
 		foreach ($arrData as $data) {

+ 25 - 9
public/app/usent/get.php

@@ -15,12 +15,12 @@ $redis = redis_connect();
 #查询有阅读权限的channel
 $channal_list = array();
 if (isset($_COOKIE["userid"])) {
-    PDO_Connect(_FILE_DB_CHANNAL_);
-    $query = "SELECT id from channal where owner = ?   limit 0,100";
-    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["userid"]));
+    PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT uid from "._TABLE_CHANNEL_." where owner_uid = ?   limit 100";
+    $Fetch_my = PDO_FetchAll($query, array($_COOKIE["user_uid"]));
     foreach ($Fetch_my as $key => $value) {
         # code...
-        $channal_list[] = $value["id"];
+        $channal_list[] = $value["uid"];
     }
 
     # 找协作的
@@ -32,14 +32,14 @@ if (isset($_COOKIE["userid"])) {
 }
 if (count($channal_list) > 0) {
     $channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
-    $channel_query = " OR channal IN ($channel_place_holders)";
+    $channel_query = " OR channel_uid IN ($channel_place_holders)";
 } else {
     $channel_query = "";
 }
 
 # 查询有阅读权限的channel 结束
 
-$dbh = new PDO(_FILE_DB_SENTENCE_, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh = new PDO(_FILE_DB_SENTENCE_, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 /* 开始一个事务,关闭自动提交 */
 
@@ -48,7 +48,7 @@ if (isset($_GET["sentences"])) {
     $arrSent = explode(",", $_GET["sentences"]);
     /*  创建一个填充了和params相同数量占位符的字符串 */
     $place_holders = implode(',', array_fill(0, count($arrSent), '?'));
-    $query = "SELECT * FROM sentence WHERE id IN ($place_holders) and (status = 30 {$channel_query} )";
+    $query = "SELECT * FROM "._TABLE_SENTENCE_." WHERE uid IN ($place_holders) and (status = 30 {$channel_query} )";
     $stmt = $dbh->prepare($query);
     $stmt->execute($arrSent);
 } else {
@@ -56,7 +56,23 @@ if (isset($_GET["sentences"])) {
     $para = $_GET["para"];
     $begin = $_GET["begin"];
     $end = $_GET["end"];
-    $query = "SELECT * FROM sentence WHERE (book = ?  AND paragraph = ? AND begin = ? AND end = ? and strlen >0 and (status = 30 {$channel_query} ) ) order by modify_time DESC  ";
+    $query = "SELECT uid as id,
+					parent_uid as parent,
+					block_uid as block_id,
+					channel_uid as channal,
+					book_id as book,
+					paragraph,
+					word_start as begin,
+					word_end as end,
+					author,
+					editor_uid as editor,
+					content as text,
+					language,
+					version as ver,
+					status,
+					strlen,
+					modify_time
+					FROM "._TABLE_SENTENCE_." WHERE (book_id = ?  AND paragraph = ? AND word_start = ? AND word_end = ? and strlen >0 and (status = 30 {$channel_query} ) ) order by modify_time DESC  ";
     $stmt = $dbh->prepare($query);
     $parm = array($book, $para, $begin, $end);
     $parm = array_merge_recursive($parm, $channal_list);
@@ -75,7 +91,7 @@ foreach ($Fetch as $key => $value) {
     if ($channel) {
 		$Fetch[$key]["mypower"] = $channel_info->getPower($value["channal"]);
         $Fetch[$key]["c_name"] = $channel["name"];
-        $Fetch[$key]["c_owner"] = $user_info->getName($channel["owner"]);
+        $Fetch[$key]["c_owner"] = $user_info->getName($channel["owner_uid"]);
         $Fetch[$key]["channalinfo"] = $channel;
     }
 	else{

+ 1 - 1
public/app/usent/historay_get.php

@@ -10,7 +10,7 @@ $respond['status'] = 0;
 $respond['error'] = "";
 $respond['data'] = array();
 PDO_Connect("" . _FILE_DB_USER_SENTENCE_HISTORAY_);
-$query = "SELECT sent_id,  user_id,  text,  date, landmark FROM  sent_historay  WHERE sent_id = ? LIMIT 0,200";
+$query = "SELECT sent_uid as sent_id,  user_uid as user_id, content as  text,  date, landmark , created_at FROM  "._TABLE_SENTENCE_HISTORAY_."  WHERE sent_uid = ? LIMIT 200";
 $fetch = PDO_FetchAll($query, array($_GET["id"]));
 
 $_userinfo = new UserInfo();

+ 3 - 7
public/app/usent/new.php

@@ -8,11 +8,11 @@ require_once "../public/function.php";
 
 $aData = json_decode($_POST["data"]);
 
-PDO_Connect("" . _FILE_DB_SENTENCE_);
+PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_,_DB_PASSWORD_);
 
 /* 开始一个事务,关闭自动提交 */
 $PDO->beginTransaction();
-$query = "INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+$query = "INSERT INTO "._TABLE_SENTENCE_." ( uid , block_uid , book_id , paragraph , word_start , word_end ,  author , editor_uid , content , language ,  modify_time ,  updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,now())";
 
 $sth = $PDO->prepare($query);
 
@@ -24,15 +24,11 @@ foreach ($aData as $data) {
             $data->paragraph,
             $data->begin,
             $data->end,
-            $data->tag,
             $data->author,
             $data->editor,
             $data->text,
             $data->lang,
-            1,
-            1,
-            mTime(),
-            mTime(),
+            mTime()
         ));
 }
 $PDO->commit();

+ 2 - 2
public/app/usent/new_block.php

@@ -1,6 +1,6 @@
 <?php
 /*
-get xml doc from db
+新建译文段落块,已经废弃
  */
 require_once "../config.php";
 require_once "../public/_pdo.php";
@@ -8,7 +8,7 @@ require_once "../public/function.php";
 
 $aData = json_decode($_POST["data"]);
 
-PDO_Connect("" . _FILE_DB_SENTENCE_);
+PDO_Connect( _FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
 
 /* 开始一个事务,关闭自动提交 */
 $PDO->beginTransaction();

+ 40 - 55
public/app/usent/sent_post.php

@@ -39,8 +39,8 @@ $cooperation = 0;
 $text_lang = "en";
 $channel_status = 0;
 if (isset($_POST["channal"])) {
-    PDO_Connect( _FILE_DB_CHANNAL_);
-    $query = "SELECT owner, lang , status FROM channal WHERE id=?";
+    PDO_Connect( _FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+    $query = "SELECT owner_uid, lang , status FROM "._TABLE_CHANNEL_." WHERE uid=?";
     $fetch = PDO_FetchRow($query, array($_POST["channal"]));
 
     if ($fetch) {
@@ -48,11 +48,11 @@ if (isset($_POST["channal"])) {
 		$channel_status = $fetch["status"];
     }
     $respond['lang'] = $text_lang;
-    if ($fetch && $fetch["owner"] == $_COOKIE["userid"]) {
+    if ($fetch && $fetch["owner_uid"] == $_COOKIE["user_uid"]) {
         #自己的channal
         $cooperation = 30;
     } else {
-		$sharePower = share_get_res_power($_COOKIE["userid"],$_POST["channal"]);
+		$sharePower = share_get_res_power($_COOKIE["user_uid"],$_POST["channal"]);
 		$cooperation = $sharePower;
 		if($channel_status>=30 && $cooperation<10){
 			#全网公开的 可以提交pr
@@ -73,13 +73,13 @@ if($cooperation==0){
     exit;
 }
 
-PDO_Connect(_FILE_DB_SENTENCE_);
+PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_,_DB_PASSWORD_);
 
 $_id = false;
 if ((isset($_POST["id"]) && empty($_POST["id"])) || !isset($_POST["id"])) {
 
     # 判断是否已经有了
-    $query = "SELECT id FROM sentence WHERE book = ? AND paragraph = ? AND begin = ? AND end = ? AND channal = ? ";
+    $query = "SELECT uid FROM "._TABLE_SENTENCE_." WHERE book_id = ? AND paragraph = ? AND word_start = ? AND word_end = ? AND channel_uid = ? ";
     $_id = PDO_FetchOne($query, array($_POST["book"], $_POST["para"], $_POST["begin"], $_POST["end"], $_POST["channal"]));
 } else {
     $_id = $_POST["id"];
@@ -89,26 +89,23 @@ if ($_id == false) {
     # 没有id新建
     if ($cooperation >=20) {
         #有写入权限
-        $query = "INSERT INTO sentence (id,
-                                        parent,
-                                        book,
+        $query = "INSERT INTO "._TABLE_SENTENCE_." (uid,
+		parent_uid,
+		book_id,
                                         paragraph,
-                                        begin,
-                                        end,
-                                        channal,
-                                        tag,
+                                        word_start,
+                                        word_end,
+                                        channel_uid,
                                         author,
-                                        editor,
-                                        text,
+                                        editor_uid,
+                                        content,
                                         language,
-                                        ver,
                                         status,
                                         strlen,
                                         modify_time,
-                                        receive_time,
                                         create_time
                                         )
-										VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+										VALUES (?, ?, ?, ?,  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
         $stmt = $PDO->prepare($query);
         $newId = UUID::v4();
         $stmt->execute(array($newId,
@@ -119,16 +116,13 @@ if ($_id == false) {
             $_POST["end"],
             $_POST["channal"],
             "",
-            "[]",
             $_COOKIE["userid"],
             $_POST["text"],
             $text_lang,
-            1,
             $channel_status,
             mb_strlen($_POST["text"], "UTF-8"),
             mTime(),
             mTime(),
-            mTime(),
         ));
         if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
             /*  识别错误  */
@@ -151,24 +145,22 @@ if ($_id == false) {
         }
     } else {
 		#没写入权限 插入pr数据
-		$query = "INSERT INTO sent_pr (id,
-										book,
+		$query = "INSERT INTO "._TABLE_SENTENCE_PR_." (
+										book_id,
 										paragraph,
-										begin,
-										end,
-										channel,
-										tag,
+										word_start,
+										word_end,
+										channel_uid,
 										author,
-										editor,
-										text,
+										editor_uid,
+										content,
 										language,
 										status,
 										strlen,
 										modify_time,
-										receive_time,
 										create_time
 										)
-										VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+										VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 		$stmt = $PDO->prepare($query);
 		# 初始状态 1 未处理
 		$stmt->execute(array(
@@ -178,14 +170,12 @@ if ($_id == false) {
 							$_POST["end"],
 							$_POST["channal"],
 							"",
-							"[]",
 							$_COOKIE["userid"],
 							$_POST["text"],
 							$text_lang,
 							1,
 							mb_strlen($_POST["text"], "UTF-8"),
 							mTime(),
-							mTime(),
 							mTime()
 							));
 		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
@@ -207,13 +197,12 @@ if ($_id == false) {
     #判断是否有修改权限
     if ($cooperation >=20) {
         #有写入权限
-        $query = "UPDATE sentence SET text= ?  , strlen = ? , editor = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
+        $query = "UPDATE "._TABLE_SENTENCE_." SET content= ?  , strlen = ? , editor_uid = ? ,  modify_time= ?   where  uid= ?  ";
         $stmt = PDO_Execute($query,
             array($_POST["text"],
                 mb_strlen($_POST["text"], "UTF-8"),
                 $_COOKIE["userid"],
                 mTime(),
-                mTime(),
                 $_id));
         if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
             /*  识别错误  */
@@ -235,24 +224,22 @@ if ($_id == false) {
     } else {
         #TO DO没权限 插入pr数据
 		#没写入权限 插入pr数据
-		$query = "INSERT INTO sent_pr (id,
-										book,
-										paragraph,
-										begin,
-										end,
-										channel,
-										tag,
-										author,
-										editor,
-										text,
-										language,
-										status,
-										strlen,
-										modify_time,
-										receive_time,
-										create_time
-										)
-										VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+		$query = "INSERT INTO "._TABLE_SENTENCE_PR_." (
+			book_id,
+			paragraph,
+			word_start,
+			word_end,
+			channel_uid,
+			author,
+			editor_uid,
+			content,
+			language,
+			status,
+			strlen,
+			modify_time,
+			create_time
+			)
+			VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
 		$stmt = $PDO->prepare($query);
 		# 初始状态 1 未处理
 		$stmt->execute(array(
@@ -262,14 +249,12 @@ if ($_id == false) {
 							$_POST["end"],
 							$_POST["channal"],
 							"",
-							"[]",
 							$_COOKIE["userid"],
 							$_POST["text"],
 							$text_lang,
 							1,
 							mb_strlen($_POST["text"], "UTF-8"),
 							mTime(),
-							mTime(),
 							mTime()
 							));
 		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {

+ 1 - 1
public/app/usent/sent_pr_merge.php

@@ -26,7 +26,7 @@ if($prData){
 		$newData = $prData;
 		if($dest){
 			#更新
-			$newData["id"]=$dest["id"];
+			$newData["id"]=$dest["uid"];
 			$newData["modify_time"]=mTime();
 			$newData["landmark"]="";
 			$updateDate[] = $newData;

+ 18 - 3
public/app/usent/sent_query.php

@@ -13,12 +13,27 @@ $filter = $_POST["filter"];
 $sentList = json_decode($sent);
 $output = array();
 
-$dns = "" . _FILE_DB_SENTENCE_;
-$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dns =  _FILE_DB_SENTENCE_;
+$dbh = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 /* 开始一个事务,关闭自动提交 */
 
-$query = "SELECT * FROM sentence WHERE (book = ?  AND paragraph = ? AND begin = ? AND end = ? AND strlen > 0  ) order by modify_time DESC limit 0,10";
+$query = "SELECT uid as id,
+                 parent_uid as parent,
+				 block_uid as block_id,
+				 channel_uid as channal,
+				 book_id as book,
+				 paragraph,
+				 word_start as begin,
+				 word_end as end,
+				 author,
+				 editor_uid as editor,
+				 content as text,
+				 language,
+				 version as ver,
+				 status,
+				 strlen,
+				 modify_time FROM "._TABLE_SENTENCE_." WHERE (book_id = ?  AND paragraph = ? AND word_start = ? AND word_end = ? AND strlen > 0  ) order by modify_time DESC limit 10";
 $stmt = $dbh->prepare($query);
 foreach ($sentList as $key => $value) {
     # code...

+ 14 - 18
public/app/usent/update.php

@@ -25,13 +25,13 @@ if (isset($_POST["landmark"])) {
 
 $aData = json_decode($_POST["data"], true);
 
-PDO_Connect("" . _FILE_DB_SENTENCE_);
+PDO_Connect(_FILE_DB_SENTENCE_,_DB_USERNAME_, _DB_PASSWORD_);
 
 //查询没有id的哪些是数据库里已经存在的,防止多次提交同一条记录造成一个句子 多个channal
 $newList = array();
 $new_id = array();
 $oldList = array();
-$query = "SELECT id FROM sentence WHERE book = ? and paragraph = ? and  begin = ? and end = ? and channal = ? limit 0 , 1 ";
+$query = "SELECT uid FROM "._TABLE_SENTENCE_." WHERE book_id = ? and paragraph = ? and  word_start = ? and word_end = ? and channel_uid = ? limit  1 ";
 foreach ($aData as $data) {
     if (!isset($data["id"]) || empty($data["id"])) {
         $id = PDO_FetchOne($query, array($data["book"],
@@ -57,7 +57,7 @@ if (count($oldList) > 0) {
     add_edit_event(_SENT_EDIT_, "{$oldList[0]["book"]}-{$oldList[0]["paragraph"]}-{$oldList[0]["begin"]}-{$oldList[0]["end"]}@{$oldList[0]["channal"]}");
 
     $PDO->beginTransaction();
-    $query = "UPDATE sentence SET text= ?  , status = ? , strlen = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
+    $query = "UPDATE "._TABLE_SENTENCE_." SET content= ?  , status = ? , strlen = ? , modify_time= ? , updated_at=now()   where  uid= ?  ";
     $sth = $PDO->prepare($query);
 
     foreach ($oldList as $data) {
@@ -67,7 +67,7 @@ if (count($oldList) > 0) {
             } else {
                 $modify_time = mTime();
             }
-            $sth->execute(array($data["text"], $data["status"], mb_strlen($data["text"], "UTF-8"), mTime(), $modify_time, $data["id"]));
+            $sth->execute(array($data["text"], $data["status"], mb_strlen($data["text"], "UTF-8"), mTime(),  $data["id"]));
         }
     }
 
@@ -106,26 +106,24 @@ if (count($oldList) > 0) {
 if (count($newList) > 0) {
     add_edit_event(_SENT_NEW_, "{$newList[0]["book"]}-{$newList[0]["paragraph"]}-{$newList[0]["begin"]}-{$newList[0]["end"]}@{$newList[0]["channal"]}");
     $PDO->beginTransaction();
-    $query = "INSERT INTO sentence (id,
-									parent,
-									book,
+    $query = "INSERT INTO "._TABLE_SENTENCE_." (uid,
+									parent_uid,
+									book_id,
 									paragraph,
-									begin,
-									end,
-									channal,
-									tag,
+									word_start,
+									word_end,
+									channel_uid,
 									author,
-									editor,
-									text,
+									editor_uid,
+									content,
 									language,
-									ver,
+									version,
 									status,
 									strlen,
 									modify_time,
-									receive_time,
 									create_time
 									)
-						VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+						VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
     $sth = $PDO->prepare($query);
 
     $channel_info = new Channal();
@@ -153,7 +151,6 @@ if (count($newList) > 0) {
             $data["begin"],
             $data["end"],
             $data["channal"],
-            isset($data["tag"]) ? $data["tag"] : "",
             $data["author"],
             $_COOKIE["userid"],
             $data["text"],
@@ -163,7 +160,6 @@ if (count($newList) > 0) {
             mb_strlen($data["text"], "UTF-8"),
             mTime(),
             mTime(),
-            mTime(),
         ));
         $new_id[] = array($uuid, $data["book"], $data["paragraph"], $data["begin"], $data["end"], $data["channal"], $data["text"]);
     }

+ 28 - 88
public/app/uwbw/create_wbw.php

@@ -83,8 +83,7 @@ $channelInfo = $channelClass->getChannal($_channel);
 
 foreach ($_para as $key => $para) {
     # code...
-    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE channal = ? AND book= ? and paragraph = ? ";
-    //$FetchWBW = PDO_FetchOne($query,array($_channel,$_book,$para));
+    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE channel_uid = ? AND book_id= ? and paragraph = ? ";
 	$stmt = $dbh_wbw->prepare($query);
 	$stmt->execute(array($_channel,$_book,$para));
 	$row = $stmt->fetch(PDO::FETCH_NUM);
@@ -109,7 +108,6 @@ foreach ($_para as $key => $para) {
                                          "",
                                          $channelInfo["lang"],
                                          $channelInfo["status"],
-                                         mTime(),
                                          mTime()
                                         );
         $block_list[] = array("channal"=>$_channel,
@@ -120,18 +118,18 @@ foreach ($_para as $key => $para) {
                                         "readonly"=>false
                                     );
         $dbh_wbw->beginTransaction();
-        $query="INSERT INTO "._TABLE_USER_WBW_BLOCK_." ('id',
-                                                                 'parent_id',
-                                                                 'channal',
-                                                                 'owner',
-                                                                 'book',
-                                                                 'paragraph',
-                                                                 'style',
-                                                                 'lang',
-                                                                 'status',
-                                                                 'modify_time',
-                                                                 'receive_time')
-                                                  VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
+        $query="INSERT INTO "._TABLE_USER_WBW_BLOCK_." ( uid ,
+                                                        parent_id ,
+                                                        channel_uid ,
+                                                        creator_uid ,
+                                                        book_id ,
+                                                        paragraph ,
+                                                        style ,
+                                                        lang ,
+                                                        status ,
+                                                        modify_time ,
+                                                        updated_at )
+                                                  VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , now() )";
         $stmt_wbw = $dbh_wbw->prepare($query);
         $stmt_wbw->execute($block_data);
         // 提交更改 
@@ -141,7 +139,7 @@ foreach ($_para as $key => $para) {
             $output["status"]=1;
             $output["error"]=$error[2];
             echo json_encode($output, JSON_UNESCAPED_UNICODE);
-            eixt;
+            exit;
         }
 
         #逐词解析库
@@ -184,8 +182,7 @@ foreach ($_para as $key => $para) {
                                               $result["real"],
                                               $strXml,
                                               mTime(),
-                                              mTime(),
-                                              1,
+                                              10,
                                               $_COOKIE["userid"]
                                             );
         }
@@ -193,19 +190,19 @@ foreach ($_para as $key => $para) {
             // 开始一个事务,关闭自动提交
 
             $dbh_wbw->beginTransaction();
-            $query="INSERT INTO "._TABLE_USER_WBW_." ('id',
-                                                           'block_id',
-                                                           'book',
-                                                           'paragraph',
-                                                           'wid',
-                                                           'word',
-                                                           'data',
-                                                           'modify_time',
-                                                           'receive_time',
-                                                           'status',
-                                                           'owner'
+            $query="INSERT INTO "._TABLE_USER_WBW_." ( uid ,
+                                                       block_uid ,
+                                                       book_id ,
+                                                       paragraph ,
+                                                       wid ,
+                                                       word ,
+                                                       data ,
+                                                       modify_time ,
+                                                       status ,
+                                                       creator_uid ,
+                                                       updated_at
                                                            ) 
-                                           VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
+                                           VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ?  ,now())";
             $stmt_wbw = $dbh_wbw->prepare($query);
             foreach($wbw_data as $oneParam){
                 $stmt_wbw->execute($oneParam);
@@ -217,69 +214,12 @@ foreach ($_para as $key => $para) {
                 $output["status"]=1;
                 $output["error"]=$error[2];
                 echo json_encode($output, JSON_UNESCAPED_UNICODE);
-                eixt;
+                exit;
             }
 
     }
 }
 
-/*TO DO 
-            //更新服务器端文件列表
-            $db_file = _FILE_DB_FILEINDEX_;
-            PDO_Connect("$db_file");
-            $query="INSERT INTO fileindex ('id',
-                                        'parent_id',
-                                        'channal',
-                                        'user_id',
-                                        'book',
-                                        'paragraph',
-                                        'file_name',
-                                        'title',
-                                        'tag',
-                                        'status',
-                                        'create_time',
-                                        'modify_time',
-                                        'accese_time',
-                                        'file_size',
-                                        'share',
-                                        'doc_info',
-                                        'doc_block',
-                                        'receive_time'
-                                        ) 
-                            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
-            $stmt = $PDO->prepare($query);
-            $doc_id=UUID::v4();
-            $file_name = $book . '_' . $create_para . '_' . time();
-            $newData=array(
-                           $doc_id,
-                           "",
-                           $_POST["channal"],
-                           $uid,
-                           $book,
-                           $create_para,
-                           $file_name,
-                           $user_title,
-                           $tag,
-                           1,
-                           mTime(),
-                           mTime(),
-                           mTime(),
-                           $filesize,
-                           0,
-                           $doc_head,
-                           json_encode($block_list, JSON_UNESCAPED_UNICODE),
-                           mTime()
-                           );
-            $stmt->execute($newData);
-            if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
-                $error = PDO_ErrorInfo();
-                echo "error - $error[2] <br>";
-            }
-            else{
-                echo "成功新建一个文件.";
-            }
-
-*/
 echo json_encode($output, JSON_UNESCAPED_UNICODE);
 PrefLog();
 ?>

+ 2 - 2
public/app/uwbw/get_index.php

@@ -8,9 +8,9 @@ require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect(_FILE_DB_USER_WBW_);
+PDO_Connect(_FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 
-$query = "SELECT * from "._TABLE_USER_WBW_BLOCK_." where  owner = ? order by modify_time DESC";
+$query = "SELECT uid , channel_uid,book_id,paragraph,lang,status,updated_at from "._TABLE_USER_WBW_BLOCK_." where  creator_uid = ? order by updated_at DESC";
 
 $result = PDO_FetchAll($query,array($_COOKIE["userid"]));
 

+ 3 - 3
public/app/uwbw/update.php

@@ -30,7 +30,7 @@ if (isset($_POST["data"])) {
 if (count($aData) > 0) {
     add_edit_event(_WBW_EDIT_, "{$aData[0]->book}-{$aData[0]->para}-{$aData[0]->word_id}");
 
-    PDO_Connect(_FILE_DB_USER_WBW_);
+    PDO_Connect(_FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 
 	#确定block id 的写入权限
 	$listBlockId=array();
@@ -48,12 +48,12 @@ if (count($aData) > 0) {
 
     /* 开始一个事务,关闭自动提交 */
     $PDO->beginTransaction();
-    $query = "UPDATE "._TABLE_USER_WBW_." SET data= ?  , receive_time= ?  , modify_time= ?   where block_id= ?  and wid= ?  ";
+    $query = "UPDATE "._TABLE_USER_WBW_." SET data= ?  ,  modify_time= ? , updated_at = now()  where block_uid= ?  and wid= ?  ";
     $sth = $PDO->prepare($query);
 
     foreach ($aData as $data) {
 		if($listBlockId[$data->block_id]>=20){
-			$sth->execute(array($data->data, mTime(), $data->time, $data->block_id, $data->word_id));
+			$sth->execute(array($data->data, mTime(), $data->block_id, $data->word_id));
 		}
     }
     $PDO->commit();

+ 3 - 3
public/app/uwbw/update_analytics.php

@@ -8,15 +8,15 @@ require_once '../public/load_lang.php';
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect(_FILE_DB_USER_WBW_);
+PDO_Connect(_FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 
 echo "Day Index,创建,更新\n";
 $end = strtotime("now") * 1000;
 $begin = strtotime("-1 day") * 1000;
 for ($i = 0; $i < 30; $i++) {
     $create = 0; 
-    $query = "SELECT count(*) from "._TABLE_USER_WBW_." where  \"modify_time\" > " . $PDO->quote($begin) . " AND \"modify_time\" < " . $PDO->quote($end) . " AND owner = " . $PDO->quote($_COOKIE["username"]);
-    $modify = PDO_FetchOne($query);
+    $query = "SELECT count(*) from "._TABLE_USER_WBW_." where  modify_time > ? AND  modify_time  < ? AND owner = ?" ;
+    $modify = PDO_FetchOne($query,array($begin,$end,$_COOKIE["username"]));
     echo date("m/d/Y", $begin / 1000) . ',' . $create . "," . $modify . "\n";
     $end = $begin;
     $begin = strtotime("-1 day", $end / 1000) * 1000;

+ 4 - 4
public/app/uwbw/wbw_analyse.php

@@ -8,9 +8,9 @@ require_once '../public/load_lang.php';
 require_once '../public/function.php';
 
 global $PDO;
-PDO_Connect("" . _FILE_DB_USER_WBW_);
+PDO_Connect("" . _FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
 
-$query = "SELECT * from "._TABLE_USER_WBW_." where  1";
+$query = "SELECT book_id,paragraph,wid,data,modify_time, creator_uid from "._TABLE_USER_WBW_." where  true";
 
 $sth = $PDO->prepare($query);
 $sth->execute();
@@ -69,8 +69,8 @@ while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
                             break;
                     }
                     if ($iType > 0) {
-                        $wordData = array($result["owner"],
-                            $pali, $result["book"],
+                        $wordData = array($result["creator_uid"],
+                            $pali, $result["book_id"],
                             $result["paragraph"],
                             $result["wid"],
                             $iType,

+ 10 - 10
public/app/uwbw/wbw_channel_list.php

@@ -32,17 +32,17 @@ $params[] = $_book;
 #查重复
 $channelList = array();
 #先查自己的
-PDO_Connect(_FILE_DB_CHANNAL_);
-$query = "SELECT id FROM channal WHERE owner = ? and status>0 LIMIT 0,100";
-$FetchChannal = PDO_FetchAll($query, array($_COOKIE["userid"]));
+PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT uid FROM "._TABLE_CHANNEL_." WHERE owner_uid = ? and status>0 LIMIT 100";
+$FetchChannal = PDO_FetchAll($query, array($_COOKIE["user_uid"]));
 
 foreach ($FetchChannal as $key => $value) {
 	# code...
-	$channelList[$value["id"]]=array("power"=>30,"type"=>"my");
+	$channelList[$value["uid"]]=array("power"=>30,"type"=>"my");
 }
 
 # 找协作的
-$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
+$coop_channal =  share_res_list_get($_COOKIE["user_uid"],2);
 foreach ($coop_channal as $key => $value) {
 	# return res_id,res_type,power res_title  res_owner_id
 	if(isset($channelList[$value["res_id"]])){
@@ -56,13 +56,13 @@ foreach ($coop_channal as $key => $value) {
 }
 
 # 查询全网公开 的
-PDO_Connect( _FILE_DB_USER_WBW_);
-$query = "SELECT  channal FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book = ? AND channal IS NOT NULL AND status = 30 group by channal ";
+PDO_Connect( _FILE_DB_USER_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
+$query = "SELECT  channel_uid FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book_id = ? AND channel_uid IS NOT NULL AND status = 30 group by channel_uid ";
 $publicChannel = PDO_FetchAll($query, $params);
 foreach ($publicChannel as $key => $channel) {
 	# code...
-	if(!isset($channelList[$channel["channal"]])){
-		$channelList[$channel["channal"]]=array("power"=>10,"type"=>"public");
+	if(!isset($channelList[$channel["channel_uid"]])){
+		$channelList[$channel["channel_uid"]]=array("power"=>10,"type"=>"public");
 	}
 }
 
@@ -75,7 +75,7 @@ $outputData = array();
 foreach ($channelList as $key => $row) {
     $queryParam = $params;
     $queryParam[] = $key;
-    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book = ? AND channal = ? ";
+    $query = "SELECT count(*) FROM "._TABLE_USER_WBW_BLOCK_." WHERE  paragraph IN ($place_holders)  AND book_id = ? AND channel_uid = ? ";
     $wbwCount = PDO_FetchOne($query, $queryParam);
     $channelList[$key]["wbw_para"] = $wbwCount;
     $channelList[$key]["count"] = count($_para);

+ 3 - 0
public/package.json

@@ -7,12 +7,15 @@
 		"diff": "^5.0.0",
 		"editor.md": "^1.5.0",
 		"fullcalendar": "^5.9.0",
+		"gridjs": "^5.0.2",
 		"highcharts": "^9.2.2",
 		"jquery": "^3.6.0",
 		"jquery-ui": "^1.12.1",
 		"jquery.fancytree": "^2.38.0",
 		"marked": "^2.1.3",
 		"mermaid": "^8.12.0",
+		"pqgridf": "^3.5.1",
+		"moment": "^2.29.1",
 		"tributejs": "^5.1.3",
 		"vue": "^3.2.8"
 	}