gui->user . " " . $_COOKIE["username"] . " " . $_local->gui->loged_out; } setcookie("user_uid", "", time() - 60, "/"); setcookie("user_id", "", time() - 60, "/"); setcookie("token", "", time() - 60, "/"); setcookie("uid", "", time() - 60, "/"); setcookie("username", "", time() - 60, "/"); setcookie("userid", "", time() - 60, "/"); setcookie("nickname", "", time() - 60, "/"); setcookie("email", "", time() - 60, "/"); break; case "new": $host = $_SERVER['HTTP_HOST']; //if (strpos($host, "wikipali.org") !== false) { if(isset($_REQUEST["invite"])){ $redis = redis_connect(); if ($redis == false) { echo "no redis connect\n"; exit; } $code = $redis->exists("invitecode://".$_REQUEST["invite"]); if(!$code){ echo "无效的邀请码,或邀请码已经过期。"; exit; } $invite_email = $redis->get("invitecode://".$_REQUEST["invite"]); }else{ echo "无邀请码"; exit; } } break; } $post_nickname = ""; $post_username = ""; $post_password = ""; $post_email = ""; if (isset($_POST["op"]) && $_POST["op"] == "new") { PDO_Connect( _FILE_DB_USERINFO_ , _DB_USERNAME_ , _DB_PASSWORD_); //建立账号 $op = "new"; $post_username = trim($_POST["username"]); $post_password = trim($_POST["password"]); $post_nickname = trim($_POST["nickname"]); $post_email = trim($_POST["email"]); $post_error = false; if (empty($post_username)) { $error_username = $_local->gui->account . $_local->gui->cannot_empty; $post_error = true; } else{ $query = "SELECT count(*) as co from "._TABLE_USER_INFO_." where username = ?" ; $iFetch = PDO_FetchOne($query,array($post_username)); if ($iFetch > 0) { //username is existed $error_username = $_local->gui->account_existed; $post_error = true; } } if (empty($post_email)) { $error_email = $_local->gui->email . $_local->gui->cannot_empty; $post_error = true; }else{ $query = "SELECT count(*) as co from "._TABLE_USER_INFO_." where email = ?" ; $iFetch = PDO_FetchOne($query,array($post_email)); if ($iFetch > 0) { //username is existed $error_email = $_local->gui->email . "已经存在"; $post_error = true; } } if (empty($post_password)) { $error_password = $_local->gui->password . $_local->gui->cannot_empty; $post_error = true; }else{ if(strlen($post_password)<6){ $error_password = $_local->gui->password . "过短"; $post_error = true; } } if (empty($post_nickname)) { $error_nickname = $_local->gui->nick_name . $_local->gui->cannot_empty; $post_error = true; } if (!$post_error) { $md5_password = md5($post_password); $new_userid = UUID::v4(); $query = "INSERT INTO "._TABLE_USER_INFO_." ('id','userid','username','password','nickname','email') VALUES (NULL," . $PDO->quote($new_userid) . "," . $PDO->quote($post_username) . "," . $PDO->quote($md5_password) . "," . $PDO->quote($post_nickname) . "," . $PDO->quote($post_email) . ")"; $stmt = @PDO_Execute($query); if (!$stmt || ($stmt && $stmt->errorCode() != 0)) { $error = PDO_ErrorInfo(); $error_comm = $error[2] . "系统错误,抱歉!请再试一次"; } else { $message_comm = "新账户建立成功"; $op = "login"; unset($_POST["username"]); //TODO create channel //TODO create studio } } } else { //登录 if (isset($_POST["username"])) { $_username_ok = true; if ($_POST["username"] == "") { $_username_ok = false; $_post_error = $_local->gui->account . $_local->gui->account_existed; } else if (isset($_POST["password"])) { $md5_password = md5($_POST["password"]); PDO_Connect(_FILE_DB_USERINFO_); $query = "SELECT * from "._TABLE_USER_INFO_." where (\"username\"=" . $PDO->quote($_POST["username"]) . " or \"email\"=" . $PDO->quote($_POST["username"]) . " ) and \"password\"=" . $PDO->quote($md5_password); $Fetch = PDO_FetchAll($query); $iFetch = count($Fetch); if ($iFetch > 0) { //验证成功 $uid = $Fetch[0]["id"]; $username = $Fetch[0]["username"]; $user_uuid = $Fetch[0]["userid"]; $nickname = $Fetch[0]["nickname"]; $email = $Fetch[0]["email"]; $ExpTime = time() + 60 * 60 * 24 * 365; //JWT $key = APP_KEY; $payload = [ 'nbf' => time(), 'exp' => $ExpTime, 'uid' => $user_uuid, 'id' => $uid ]; $jwt = JWT::encode($payload,$key,'HS512'); //End of JWT // set cookie if(empty($_SERVER["HTTPS"])){ //本地开发 setcookie("user_uid", $user_uuid,["expires"=>$ExpTime,"path"=>"/","secure"=>false,"httponly"=>true]); setcookie("user_id", $Fetch[0]["id"], ["expires"=>$ExpTime,"path"=>"/","secure"=>false,"httponly"=>true]); setcookie("token", $jwt, ["expires"=>$ExpTime,"path"=>"/","secure"=>false,"httponly"=>true]); }else{ //服务器运行 setcookie("user_uid", $user_uuid, ["expires"=>$ExpTime,"path"=>"/","secure"=>true,"httponly"=>true]); setcookie("user_id", $Fetch[0]["id"], ["expires"=>$ExpTime,"path"=>"/","secure"=>true,"httponly"=>true]); setcookie("token", $jwt, ["expires"=>$ExpTime,"path"=>"/","secure"=>true,"httponly"=>true]); } #给js用的 setcookie("uid", $uid, time()+60*60*24*365,"/"); setcookie("username", $username, time()+60*60*24*365,"/"); setcookie("userid", $user_uuid, time()+60*60*24*365,"/"); setcookie("nickname", $nickname, time()+60*60*24*365,"/"); setcookie("email", $email, time()+60*60*24*365,"/"); if (isset($_POST["url"])) { $goto_url = $_POST["url"]; } #设置新密码 if (isset($_COOKIE["url"])) { setcookie("pwd_set", "on", time() + 60, "/"); } ?> wikipali starting

Auto Redirecting to Homepage! IF NOT WORKING, CLICK HERE

gui->incorrect_ID_PASS; } } } } ?> wikipali login
gui->pali_literature_platform; ?>
  • gui->online_dict_db; ?>
  • gui->user_data_share; ?>
  • gui->cooperate_edit; ?>
'; echo $error_comm; echo '
'; } if (isset($message_comm)) { echo '
'; echo $message_comm; echo '
'; } if ($op == "new") { //新建账号 ?>
gui->join_wikipali; ?>
gui->login; } ?>
切换账户'; } else { echo '' . $_local->gui->new_to_wikipali . ' ?    ' . $_local->gui->create_account . ''; } ?> 忘记密码