gui->user . " " . $_COOKIE["nickname"] . " " . $_local->gui->loged_out;
}
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) {
echo "网站正处于开发阶段。目前不支持注册。";
exit;
}
break;
}
}
$post_nickname = "";
$post_username = "";
$post_password = "";
$post_email = "";
if (isset($_POST["op"]) && $_POST["op"] == "new") {
$op = "new";
$post_username = $_POST["username"];
$post_password = $_POST["password"];
$post_nickname = $_POST["nickname"];
$post_email = $_POST["email"];
if (empty($post_username)) {
$error_username = $_local->gui->account . $_local->gui->cannot_empty;
}
if (empty($post_password)) {
$error_password = $_local->gui->password . $_local->gui->cannot_empty;
}
if (empty($post_nickname)) {
$error_nickname = $_local->gui->nick_name . $_local->gui->cannot_empty;
}
if (!empty($post_username) && !empty($post_password) && !empty($post_nickname)) {
$md5_password = md5($post_password);
$new_userid = UUID::v4();
PDO_Connect("" . _FILE_DB_USERINFO_);
$query = "select * from user where \"username\"=" . $PDO->quote($post_username);
$Fetch = PDO_FetchAll($query);
$iFetch = count($Fetch);
if ($iFetch > 0) { //username is existed
$error_username = $_local->gui->account_existed;
} else {
$query = "INSERT INTO user ('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 {
//created user recorder
$newUserPath = _DIR_USER_DOC_ . '/' . $new_userid;
$userDirMyDocument = $newUserPath . _DIR_MYDOCUMENT_;
if (!file_exists($newUserPath)) {
if (mkdir($newUserPath)) {
mkdir($userDirMyDocument);
} else {
$error_comm = "建立用户目录失败,请联络网站管理员。";
}
}
$message_comm = "新账户建立成功";
$op = "login";
unset($_POST["username"]);
}
}
} else {
}
} 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 user 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) { //username is exite
$uid = $Fetch[0]["id"];
$username = $Fetch[0]["username"];
$userid = $Fetch[0]["userid"];
$nickname = $Fetch[0]["nickname"];
$email = $Fetch[0]["email"];
setcookie("uid", $uid, time() + 60 * 60 * 24 * 365, "/");
setcookie("username", $username, time() + 60 * 60 * 24 * 365, "/");
setcookie("userid", $userid, 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, "/");
}
$newUserPath = _DIR_USER_DOC_ . '/' . $userid . '/';
if (!file_exists($newUserPath)) {
echo "error:cannot find user dir:$newUserPath
";
}
?>
Auto Redirecting to Homepage! IF NOT WORKING, CLICK HERE
gui->incorrect_ID_PASS; } } } } ?>