diff --git a/admin.php b/admin.php index 6b5a08f..a333969 100644 --- a/admin.php +++ b/admin.php @@ -1,7 +1,7 @@ @@ -16,8 +16,209 @@ 后台管理 + - admin +
+
+
+

+

退出登录

+
+ +
+
+ + \ No newline at end of file diff --git a/login.php b/common/login.php similarity index 61% rename from login.php rename to common/login.php index a866dc7..1007f43 100644 --- a/login.php +++ b/common/login.php @@ -19,16 +19,14 @@ // 密码盐 $salt = md5('shinn_lancelot'); - $res = json_decode(file_get_contents(__DIR__ . '/user.json'), true); + $res = json_decode(file_get_contents('./user.json'), true); $hasUser = false; foreach ($res as $key=>$value) { if ($value['user'] == $user) { $hasUser = true; if ($value['password'] == md5($password . $salt)) { - // 生成用户登录令牌 - $token = getNonceStr(); session_start(); - $_SESSION['token'] = $token; + $_SESSION['wop_admin_user'] = $user; $res['code'] = 1; $res['message'] = '登录成功!'; @@ -43,28 +41,4 @@ } echo json_encode($res); -} - -/** - * 获取随机字符串 - * @param int $length - * @return string - */ -function getNonceStr($length = 16) -{ - $str2 = time(); - $length2 = strlen($str2); - $length1 = $length - $length2; - if($length1 <= 0){ - $length1 = 6; - } - - $chars = "abcdefghijklmnopqrstuvwxyz"; - $str1 = ""; - for ( $i = 0; $i < $length1; $i++ ) { - $str1 .= substr($chars, mt_rand(0, strlen($chars)-1), 1); - } - $str = $str1.$str2; - - return $str; } \ No newline at end of file diff --git a/common/logout.php b/common/logout.php new file mode 100644 index 0000000..32c240e --- /dev/null +++ b/common/logout.php @@ -0,0 +1,18 @@ +$callBackUrl diff --git a/login.html b/login.html index 09c93aa..6a7ace9 100644 --- a/login.html +++ b/login.html @@ -253,7 +253,7 @@ return; } - xhr.open('post', './login.php', true); + xhr.open('post', './common/login.php', true); xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xhr.send('user=' + user + '&password=' + password); xhr.onreadystatechange = function() { diff --git a/verify.html b/verify.html index a10e3b4..c42f8e6 100644 --- a/verify.html +++ b/verify.html @@ -213,7 +213,7 @@ return; } - xhr.open('post', '/verify.php', true); + xhr.open('post', './common/verify.php', true); xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xhr.send('txt=' + txt); xhr.onreadystatechange = function() {