diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..6b5a08f --- /dev/null +++ b/admin.php @@ -0,0 +1,23 @@ + + + + + + + + + 后台管理 + + + + + admin + + \ No newline at end of file diff --git a/asset/image/password.png b/asset/image/password.png new file mode 100644 index 0000000..99b8776 Binary files /dev/null and b/asset/image/password.png differ diff --git a/asset/image/password_selected.png b/asset/image/password_selected.png new file mode 100644 index 0000000..5b9b6ff Binary files /dev/null and b/asset/image/password_selected.png differ diff --git a/asset/image/user.png b/asset/image/user.png new file mode 100644 index 0000000..b653301 Binary files /dev/null and b/asset/image/user.png differ diff --git a/asset/image/user_selected.png b/asset/image/user_selected.png new file mode 100644 index 0000000..d1f5ed8 Binary files /dev/null and b/asset/image/user_selected.png differ diff --git a/demo/index.php b/demo/index.php index 295d94a..784153f 100644 --- a/demo/index.php +++ b/demo/index.php @@ -56,7 +56,7 @@ function http_request($url, $data = null) - + 微信授权登录代理案例页 diff --git a/login.html b/login.html new file mode 100644 index 0000000..09c93aa --- /dev/null +++ b/login.html @@ -0,0 +1,383 @@ + + + + + + + 后台管理登录 + + + + + +
+
+
+ +
+
+ + + +
+
+ + + +
+
+

登录

+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..a866dc7 --- /dev/null +++ b/login.php @@ -0,0 +1,70 @@ +$value) { + if ($value['user'] == $user) { + $hasUser = true; + if ($value['password'] == md5($password . $salt)) { + // 生成用户登录令牌 + $token = getNonceStr(); + session_start(); + $_SESSION['token'] = $token; + + $res['code'] = 1; + $res['message'] = '登录成功!'; + } else { + $res['message'] = '密码错误!'; + } + break; + } + } + if (!$hasUser) { + $res['message'] = '用户名不存在!'; + } + + 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/user.json b/user.json new file mode 100644 index 0000000..30fe75e --- /dev/null +++ b/user.json @@ -0,0 +1 @@ +[{"user":"admin","password":"8901e89b3dfb6cd406be8800b1e299ff"}] \ No newline at end of file diff --git a/verify.html b/verify.html index abae3a4..a10e3b4 100644 --- a/verify.html +++ b/verify.html @@ -1,9 +1,9 @@ - + + content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> 微信授权回调域名验证操作 @@ -188,6 +188,8 @@ txt = '', responseObj = '', submitState = 1, + submitBtnClass = '', + txtClass = '', clearIconObj = document.getElementsByClassName('icon-clear')[0], redirectUrl = window.location.host, formObj = document.getElementById('form'); @@ -228,8 +230,9 @@ var clearFunc = function (e) { txtObj.value = ''; - var txtClass = submitBtnObj.getAttribute('class'); - if (txtClass == 'field') { + txt = ''; + submitBtnClass = submitBtnObj.getAttribute('class'); + if (submitBtnClass == 'field') { submitBtnObj.setAttribute('class', 'field disable'); } clearIconObj.style.display = 'none'; @@ -239,15 +242,15 @@ txtObj.addEventListener('input', function (e) { submitBtnObj.removeEventListener('click', submitFunc); txt = txtObj.value; - var txtClass = submitBtnObj.getAttribute('class'); + submitBtnClass = submitBtnObj.getAttribute('class'); if (txt.length > 0) { - if (txtClass == 'field disable') { + if (submitBtnClass == 'field disable') { submitBtnObj.setAttribute('class', 'field'); } clearIconObj.style.display = 'block'; submitBtnObj.addEventListener('click', submitFunc); } else { - if (txtClass == 'field') { + if (submitBtnClass == 'field') { submitBtnObj.setAttribute('class', 'field disable'); } clearIconObj.style.display = 'none'; @@ -256,14 +259,14 @@ }); txtObj.addEventListener('focusin', function (e) { - var txtClass = txtObj.getAttribute('class'); + txtClass = txtObj.getAttribute('class'); if (txtClass == 'field') { txtObj.setAttribute('class', 'field line'); } }); txtObj.addEventListener('focusout', function (e) { - var txtClass = txtObj.getAttribute('class'); + txtClass = txtObj.getAttribute('class'); if (txtClass == 'field line') { txtObj.setAttribute('class', 'field'); }