ソースを参照

Merge pull request #764 from visuddhinanda/laravel

:ambulance: 注册时建立channel出错
visuddhinanda 4 年 前
コミット
3481cefb8b

+ 6 - 4
public/app/db/channel.php

@@ -37,15 +37,17 @@ class Channel extends Table
 			}
 			$json = file_get_contents('php://input');
 			$data = json_decode($json,true);
-			$data["owner"] = $_COOKIE["userid"];			
+			$data["owner_uid"] = $_COOKIE["user_uid"];
+			$data["editor_id"] = $_COOKIE["user_id"];
 		}
 
-		$isExist = $this->medoo->has($this->table,["owner"=>$data["owner"],"name"=>$data["name"]]);
+		$isExist = $this->medoo->has($this->table,["owner_uid"=>$data["owner_uid"],"name"=>$data["name"]]);
 		if(!$isExist){
-			$data["id"] = UUID::v4();
+			$data["id"] = $this->SnowFlake->id();
+			$data["uid"] = UUID::v4();
 			$data["create_time"] = mTime();
 			$data["modify_time"] = mTime();
-			$result =  $this->_create($data,["id","owner","lang","name","summary","status","create_time","modify_time"]);
+			$result =  $this->_create($data,["id","uid","owner_uid",'editor_id',"lang","name","summary","status","create_time","modify_time"]);
 		}
 		else{
 			$this->result["ok"]=false;

+ 1 - 1
public/app/db/table.php

@@ -60,7 +60,7 @@ class Table
 			$updateDate
 		);
 
-		$updateDate["id"] = $this->medoo->id();
+		//$updateDate["id"] = $newData;
 		$this->result["data"] = $updateDate;
 		return $this->result;
 	}

+ 12 - 3
public/app/db/user.php

@@ -129,15 +129,24 @@ class User extends Table
 				$data["setting"] = "{}";
 				$result = $this->_create($data,["userid","username","email","password","nickname","setting","create_time","modify_time"]);
 				if($result["ok"]){
+                    $newUserId = $this->medoo->get(
+                        $this->table,
+                        'id',
+                        ["userid"=>$data['userid']]
+                    );
 					$channel = new Channel($this->redis);
-					$newChannel1 = $channel->create(["owner"=>$data["userid"],
+					$newChannel1 = $channel->create([
+                                                    "owner_uid"=>$data["userid"],
+                                                    "editor_id"=>$newUserId,
 													"lang"=>$data["lang"],
 													"name"=>$data["username"],
 													"lang"=>$data["lang"],
 													"status"=>30,
 													"summary"=>""
 													]);
-					$newChannel2 = $channel->create(["owner"=>$data["userid"],
+					$newChannel2 = $channel->create([
+                                                    "owner_uid"=>$data["userid"],
+                                                    "editor_id"=>$newUserId,
 													"lang"=>$data["lang"],
 													"name"=>"draft",
 													"lang"=>$data["lang"],
@@ -312,7 +321,7 @@ class User extends Table
 			$this->result["message"]="::username_too_short";
 			return false;
 		}
-		if(preg_match("/@|\s|\//",$username)!==0){
+		if(preg_match("/@|\s|\/|[A-Z]/",$username)!==0){
 			$this->result["ok"]=false;
 			$this->result["message"]="::username_invaild_symbol";
 			return false;

+ 1 - 1
public/app/public/lang/default.json

@@ -368,7 +368,7 @@
 		"nick_name": "nickname",
 		"name_for_show": "name showed for others",
 		"email_address": "E-mail address",
-		"account_demond": "Username may only contain alphanumeric characters, and try to avoid using ? : ! ; , -  etc.",
+		"account_demond": "Username may only contain alphanumeric lower case characters, and try to avoid using ? : ! ; , -  etc.",
 		"password_demond": "Make sure it's at least 5 characters including both numbers and letters",
 		"login_with_google": "Log in with Google",
 		"login_with_facebook": "Log in with Facebook",

+ 1 - 1
public/app/public/lang/en.json

@@ -368,7 +368,7 @@
 		"nick_name": "nickname",
 		"name_for_show": "name showed for others",
 		"email_address": "E-mail address",
-		"account_demond": "Username may only contain alphanumeric characters, and try to avoid using ? : ! ; , -  etc.",
+		"account_demond": "Username may only contain alphanumeric lower case characters, and try to avoid using ? : ! ; , -  etc.",
 		"password_demond": "Make sure it's at least 5 characters including both numbers and letters",
 		"login_with_google": "Log in with Google",
 		"login_with_facebook": "Log in with Facebook",

+ 1 - 1
public/app/public/lang/my.json

@@ -368,7 +368,7 @@
 		"nick_name": "nickname",
 		"name_for_show": "name showed for others",
 		"email_address": "E-mail address",
-		"account_demond": "Username may only contain alphanumeric characters, and try to avoid using ? : ! ; , -  etc.",
+		"account_demond": "Username may only contain alphanumeric lower case characters, and try to avoid using ? : ! ; , -  etc.",
 		"password_demond": "Make sure it's at least 5 characters including both numbers and letters",
 		"login_with_google": "Log in with Google",
 		"login_with_facebook": "Log in with Facebook",

+ 1 - 1
public/app/public/lang/si.json

@@ -373,7 +373,7 @@
 		"nick_name": "nickname",
 		"name_for_show": "name showed for others",
 		"email_address": "E-mail address",
-		"account_demond": "Username may only contain alphanumeric characters, and try to avoid using ? : ! ; , -  etc.",
+		"account_demond": "Username may only contain alphanumeric lower case characters, and try to avoid using ? : ! ; , -  etc.",
 		"password_demond": "Make sure it's at least 5 characters including both numbers and letters",
 		"login_with_google": "Log in with Google",
 		"login_with_facebook": "Log in with Facebook",

+ 1 - 1
public/app/public/lang/zh-cn.json

@@ -369,7 +369,7 @@
 		"nick_name": "称呼(昵称)",
 		"name_for_show": "给他人看的名字",
 		"email_address": "电子邮箱地址",
-		"account_demond": "请在半角下使用英文本母、数字、标点符号。并避免使用这些符号?:!;,",
+		"account_demond": "请在半角下使用小写英文字母和数字。并避免使用这些符号?:!;,",
 		"password_demond": "请混合使用五个字符以上的字母和数字",
 		"login_with_google": "使用谷歌登录",
 		"login_with_facebook": "使用脸书登录",

+ 1 - 1
public/app/public/lang/zh-tw.json

@@ -369,7 +369,7 @@
 		"nick_name": "稱呼(暱稱)",
 		"name_for_show": "給他人看的名字",
 		"email_address": "電子信箱地址",
-		"account_demond": "請在半形下使用英文字母、數字、標點符號。並避免使用這些符號?:!;,",
+		"account_demond": "請在半形下使用小寫英文字母和數字。並避免使用這些符號?:!;,",
 		"password_demond": "請混合使用五個字元以上的字母和數字",
 		"login_with_google": "使用Google登入",
 		"login_with_facebook": "使用Facebook登入",

+ 2 - 2
public/app/ucenter/index.php

@@ -410,8 +410,8 @@ if ($op == "new") {
 
 					<div>
 						<span id='tip_password' class='form_field_name'><?php echo $_local->gui->password; ?></span>
-						<input type="password" name="password" placeholder="密码" value="<?php echo $post_password; ?>" />
-						<input type="password" name="repassword" placeholder="再次输入密码" value="<?php echo $post_password; ?>" />
+						<input type="password" name="password" placeholder="<?php echo $_local->gui->password; ?>" value="<?php echo $post_password; ?>" />
+						<input type="password" name="repassword" placeholder="<?php echo $_local->gui->password_again; ?>" value="<?php echo $post_password; ?>" />
 					</div>
 					<div class="form_help">
 					<?php echo $_local->gui->password_demond; ?>

+ 2 - 2
public/app/ucenter/reset.php

@@ -201,8 +201,8 @@ if (!isset($_GET["token"])) {
 					<div>
 						<div>
 							<span id='tip_password' class='form_field_name'><?php echo $_local->gui->password; ?></span>
-							<input type="password" id="password" maxlength="32" name="password" placeholder="密码" value="" />
-							<input type="password" id="repassword" maxlength="32" name="repassword" placeholder="再次输入密码" value="" />
+							<input type="password" id="password" maxlength="32" name="password" placeholder="<?php echo $_local->gui->password; ?>" value="" />
+							<input type="password" id="repassword" maxlength="32" name="repassword" placeholder="<?php echo $_local->gui->password_again; ?>" value="" />
 						</div>
 						<div class="form_help">至少6个字符</div>
 						<div id="error_password" class="form_error"></div>

+ 13 - 6
public/app/ucenter/sign.js

@@ -7,7 +7,7 @@ function isValidPassword(str){
 	}
 }
 function isValidUserName(str){
-	let patt=new RegExp(/@|\s|\//);
+	let patt=new RegExp(/@|\s|\/|[A-Z]/);
 	if(patt.test(str)){
 		return false;
 	}else{
@@ -17,16 +17,23 @@ function isValidUserName(str){
 function submit(){
 	let hasError = false;
 	if($("#password").val()!==$("#repassword").val()){
-		$("#error_password").text("两次密码输入不一致");
+		$("#error_password").text("password and repassword is not match");
 		hasError = true;
 	}
 	if(isValidPassword($("#password").val())==false){
-		$("#error_password").text("密码包含无效字符。  / 空格 ");
+		$("#error_password").text(gLocal.gui.password_invaild_symbol);
+		hasError = true;
+	}
+	if($("#password").val().length < 6){
+		$("#error_password").text('Password is too short');
+		hasError = true;
+	}
+    if($("#password").val().length > 31){
+		$("#error_password").text('Password is too long');
 		hasError = true;
 	}
-
 	if(isValidUserName($("#username").val())==false){
-		$("#error_password").text("用户名包含无效字符。@  / 空格 ");
+		$("#error_username").text(gLocal.gui.username_invaild_symbol);
 		hasError = true;
 	}
 
@@ -62,7 +69,7 @@ function submit(){
 			if(data.ok){
 				$("#form_div").hide();
 				$("#message").removeClass("form_error");
-				$("#message").html("注册成功。<a href='index.php?op=login'>"+gLocal.gui.login+"</a>");
+				$("#message").html(gLocal.gui.successful+" <a href='index.php?op=login'>"+gLocal.gui.login+"</a>");
 			}else{
 				$("#message").addClass("form_error");
 				$("#message").text(ConvertServerMsgToLocalString(data.message));

+ 7 - 7
public/app/ucenter/sign_up.php

@@ -170,7 +170,7 @@ require_once "../redis/function.php";
 		<div id = "login_form_div" class="fun_block" >
 
 			<div class="title">
-			注册wikipali账号
+			wikipali sign up
 			</div>
 			<div class="login_new">
 				<span class="form_help"><?php echo $_local->gui->have_account; ?> ?</span><a href="index.php?language=<?php echo $currLanguage; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $_local->gui->login; //登入账户 ?></a>
@@ -178,17 +178,17 @@ require_once "../redis/function.php";
 			<div class="form_error">
 			<?php
 			if (!isset($_GET["invite"])) {
-				echo "目前只支持邀请码注册。";
+				echo "Only for invited person";
 				exit;
 			}else{
 				$redis = redis_connect();
 				if ($redis == false) {
-					echo "服务器故障,请稍后重试。<br> 错误代码:no_redis_connect";
+					echo "Server Error,please try again.<br> no_redis_connect";
 					exit;
 				}
 				$code = $redis->exists("invitecode://".$_REQUEST["invite"]);
 				if(!$code){
-					echo "无效的邀请码,或邀请码已经过期。";
+					echo "Invalid invide code or code expired.";
 					exit;
 				}
 				$invite_email = $redis->get("invitecode://".$_REQUEST["invite"]);				
@@ -216,8 +216,8 @@ require_once "../redis/function.php";
 					<div>
 						<div>
 							<span id='tip_password' class='form_field_name'><?php echo $_local->gui->password; ?></span>
-							<input type="password" id="password"  maxlength="32"  name="password"  value="" />
-							<input type="password" id="repassword" maxlength="32"  name="repassword" placeholder="再次输入密码" value="" />
+							<input type="password" id="password"  maxlength="32"  name="password" placeholder="<?php echo $_local->gui->password; ?>" value="" />
+							<input type="password" id="repassword" maxlength="32"  name="repassword" placeholder="<?php echo $_local->gui->password_again; ?>" value="" />
 						</div>
 						<div class="form_help">
 						<?php echo $_local->gui->password_demond; ?>
@@ -226,7 +226,7 @@ require_once "../redis/function.php";
 					</div>
 
 						<div>
-							<span id='tip_language' class='viewswitch_on'><?php echo "惯常使用的语言"; ?></span>
+							<span id='tip_language' class='viewswitch_on'><?php echo "惯常使用的语言 Usual Language"; ?></span>
 							<select id="lang" name="language" style="width: 100%;">
 							<?php
 							$currLang = $_COOKIE["language"];