EasyImages2.0/admin/index.php

181 lines
7.8 KiB
PHP
Raw Normal View History

<?php
/*
* 登录页面
*/
2023-03-08 18:42:50 +00:00
require_once __DIR__ . '/../app/function.php';
require_once APP_ROOT . '/app/header.php';
2022-01-27 09:25:46 +00:00
require_once APP_ROOT . '/config/config.guest.php';
2021-11-17 03:48:11 +00:00
2022-01-27 09:25:46 +00:00
// 退出
if (isset($_GET['login'])) {
2022-04-29 08:47:23 +00:00
if ($_GET['login'] = 'logout') {
2022-01-27 09:25:46 +00:00
2022-04-29 08:47:23 +00:00
if (isset($_COOKIE['auth'])) {
setcookie('auth', null, time() - 1, '/');
header("Refresh:2;url=../index.php");
echo '
2022-01-27 09:25:46 +00:00
<script>
new $.zui.Messager("退出成功", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'../index.php\'",2000);
</script>
';
2022-04-29 08:47:23 +00:00
} else {
echo '
2022-01-27 09:25:46 +00:00
<script>
new $.zui.Messager("尚未登录", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'./index.php\'",2000);
</script>
';
2022-04-29 08:47:23 +00:00
}
}
2023-03-08 18:42:50 +00:00
exit(require_once APP_ROOT . '/app/footer.php');
2022-05-25 10:23:17 +00:00
}
2023-03-04 06:45:03 +00:00
// 提交登录
if (isset($_POST['password']) and isset($_POST['user'])) {
// 验证码
if ($config['captcha']) {
if (empty($_REQUEST['code'])) {
2022-05-25 10:23:17 +00:00
echo '
<script>
2023-03-04 06:45:03 +00:00
new $.zui.Messager("请填写验证码!", {type: "danger" // 定义颜色主题
2022-05-25 10:23:17 +00:00
}).show();
// 延时2s跳转
2023-03-04 06:45:03 +00:00
window.setTimeout("window.location=\'./index.php\'",2000);
2022-05-25 10:23:17 +00:00
</script>';
2023-03-08 18:42:50 +00:00
exit(require_once APP_ROOT . '/app/footer.php');
2023-03-04 06:45:03 +00:00
} else {
session_start();
if (strtolower($_REQUEST['code']) !== $_SESSION['code']) {
echo '
<script>
new $.zui.Messager("验证码错误!", {type: "danger" // 定义颜色主题
}).show();
// 延时2s跳转
window.setTimeout("window.location=\'./index.php\'",2000);
</script>';
2023-03-08 18:42:50 +00:00
exit(require_once APP_ROOT . '/app/footer.php');
2023-03-04 06:45:03 +00:00
}
2022-05-25 10:23:17 +00:00
}
}
$login = _login($_POST['user'], $_POST['password']);
$login = json_decode($login, true);
2022-05-25 10:23:17 +00:00
if ($login['code'] == 200) {
echo '
<script>
new $.zui.Messager("' . $login["messege"] . '" , {
type: "primary", // 定义颜色主题
icon: "check" // 定义消息图标
}).show();
</script>';
header("refresh:2;url=" . $config['domain'] . "");
2022-05-25 10:23:17 +00:00
} else {
echo '
<script>
new $.zui.Messager("' . $login["messege"] . '" , {
type: "danger", // 定义颜色主题
icon: "times" // 定义消息图标
2022-05-25 10:23:17 +00:00
}).show();
</script>';
header("refresh:2;");
2022-05-25 10:23:17 +00:00
}
2023-03-05 03:06:06 +00:00
// 登录日志
write_login_log($_POST['user'], $_POST['password'], $login["messege"]);
2022-01-27 09:25:46 +00:00
}
?>
2024-01-19 14:21:12 +00:00
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/login.css">
2022-04-16 05:23:49 +00:00
<!-- 忘记密码 -->
<div class="modal fade" id="fogot">
2022-04-29 08:47:23 +00:00
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">x</span><span class="sr-only">关闭</span></button>
<h4 class="modal-title">
忘记账号/密码?
</h4>
</div>
<div class="modal-body">
<p class="text-primary">忘记账号可以打开<code>/config/config.php</code>文件找到<code data-toggle="tooltip" title="'user'=><strong>admin</strong>'">user</code>对应的键值->填入</p>
2023-03-08 18:42:50 +00:00
<p class="text-success">忘记密码请将密码转换成SHA256(<a href="<?php echo $config['domain'] . '/app/reset_password.php'; ?>" target="_blank" class="text-purple">转换网址</a>)->打开<code>/config/config.php</code>文件->找到<code data-toggle="tooltip" title="'password'=>'<strong>e6e0612609</strong>'">password</code>对应的键值->填入</p>
2022-04-29 08:47:23 +00:00
<h4 class="text-danger">更改后会立即生效并重新登录,请务必牢记账号和密码! </h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
2022-04-16 05:23:49 +00:00
</div>
2022-04-29 08:47:23 +00:00
<section>
<div class="container">
<div class="user singinBx">
<div class="imgBx">
<img src="<?php echo $config['login_bg']; ?>" alt="简单图床登陆界面背景图" />
</div>
<div class="formBx">
<form class="form-horizontal" action="/admin/index.php" method="post" onsubmit="return md5_post()">
<h2>登录</h2>
<label for="account" class="col-sm-2"></label>
<input type="text" name="user" id="account" class="form-control" value="" placeholder="输入登录账号" autocomplete="off" required="required">
2024-01-19 14:21:12 +00:00
<input type="password" name="password" id="password" class="form-control" value="" placeholder="输入登录密码" autocomplete="off" required="required"><input type="hidden" name="password" id="md5_password">
2022-05-25 10:23:17 +00:00
<?php if ($config['captcha']) : ?>
2023-02-12 08:09:21 +00:00
<input class="form-control" type="text" name="code" value="" placeholder="请输入验证码" autocomplete="off" required="required" />
<div class="form-group">
<div class="col">
2023-03-08 18:42:50 +00:00
<label><img src="../app/captcha.php" width="185px" onClick="this.src='../app/captcha.php?nocache='+Math.random()" title="点击换一张" /></label>
</div>
2022-04-29 08:47:23 +00:00
</div>
2022-05-25 10:23:17 +00:00
<?php endif; ?>
2022-04-29 08:47:23 +00:00
<button type="submit" class="btn btn-block btn-primary"> </button>
<p class="signup">忘记账号或密码请查看<a href="#fogot" data-moveable="inside" data-remember-pos="false" data-toggle="modal" data-target="#fogot" data-position="center">帮助信息</a></p>
</form>
</div>
</div>
<div class="user singupBx">
<div class="formBx">
<form action="">
<h2>注册</h2>
<input type="text" name="telyzm" id="telyzm" placeholder="手机号">
<input type="email" name="" placeholder="邮箱地址">
<input type="password" name="" placeholder="设置密码">
<input type="password" name="" placeholder="再次输入密码">
<input type="submit" name="" value="注册">
<p class="signup">已有账号?<a href="#" onclick="topggleForm();">登录</a></p>
</form>
</div>
<div class="imgBx"><img src="<?php echo $config['login_bg']; ?>" alt="简单图床登陆界面背景图" />
</div>
</div>
</div>
</section>
2021-11-12 14:17:05 +00:00
</form>
2024-01-19 14:21:12 +00:00
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script>
<script>
2022-04-29 08:47:23 +00:00
function md5_post() {
var password = document.getElementById('password');
var md5pwd = document.getElementById('md5_password');
2023-03-04 05:52:50 +00:00
md5pwd.value = SHA256(password.value);
2024-01-19 14:21:12 +00:00
// fix https://github.com/icret/EasyImages2.0/pull/163
password.value = "Null";
// 可以校验判断表单内容true就是通过提交false阻止提交
2022-04-29 08:47:23 +00:00
return true;
}
function topggleForm() {
var container = document.querySelector('.container');
container.classList.toggle('active');
}
</script>
2023-03-08 18:42:50 +00:00
<?php require_once APP_ROOT . '/app/footer.php';