49 lines
2.0 KiB
PHP
49 lines
2.0 KiB
PHP
<?php
|
|
require_once __DIR__ . "/includes/config.php";
|
|
require_once __DIR__ . "/includes/functions.php";
|
|
require_once __DIR__ . "/includes/auth.php";
|
|
if (is_login()) { header("Location: " . SITE_URL . "index.php"); exit; }
|
|
$err = "";
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
$username = trim($_POST["username"] ?? "");
|
|
$password = $_POST["password"] ?? "";
|
|
if ($username === "" || $password === "") {
|
|
$err = "请输入用户名和密码";
|
|
} elseif (attempt_login($username, $password)) {
|
|
header("Location: " . SITE_URL . "admin/index.php");
|
|
exit;
|
|
} else {
|
|
$err = "用户名或密码错误";
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN" data-theme="light">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - <?php echo e(SITE_NAME); ?></title>
|
|
<meta name="description" content="<?php echo e(SITE_DESC); ?>">
|
|
<link rel="stylesheet" href="<?php echo e(SITE_URL); ?>assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="bg"></div>
|
|
<button class="theme-toggle" id="themeBtn" style="position:fixed;top:20px;right:24px;">深色模式</button>
|
|
<div class="login-page">
|
|
<div class="login-box glass">
|
|
<div class="login-brand"><?php echo e(SITE_NAME); ?></div>
|
|
<h2 style="text-align:center;">登录</h2>
|
|
<div class="sub" style="text-align:center;">登录以管理你的博客</div>
|
|
<?php if ($err) { ?><div class="msg err"><?php echo e($err); ?></div><?php } ?>
|
|
<form method="post">
|
|
<div class="field"><label>用户名</label><input class="glass-input" name="username" value="<?php echo e($_POST["username"] ?? ""); ?>" required></div>
|
|
<div class="field"><label>密码</label><input class="glass-input" type="password" name="password" required></div>
|
|
<button class="glass-btn primary" style="width:100%;padding:12px;">登 录</button>
|
|
</form>
|
|
<div class="login-back"><a href="<?php echo e(SITE_URL); ?>index.php">返回首页</a></div>
|
|
</div>
|
|
</div>
|
|
<script src="<?php echo e(SITE_URL); ?>assets/js/main.js"></script>
|
|
</body>
|
|
</html>
|