53 lines
2.0 KiB
PHP
53 lines
2.0 KiB
PHP
<?php
|
|
require_once __DIR__ . '/auth.php';
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$pwd = $_POST['password'] ?? '';
|
|
if ($pwd === AUTH_PASSWORD) {
|
|
$_SESSION['logged_in'] = true;
|
|
header('Location: index.php');
|
|
exit;
|
|
} else {
|
|
$error = '密码错误';
|
|
}
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="zh-CN" data-theme="light">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>登录 - 文档编辑器</title>
|
|
<link rel="stylesheet" href="assets/style.css" />
|
|
<style>
|
|
.login-wrap { height: 100vh; display:flex; align-items:center; justify-content:center; background: radial-gradient(800px 400px at 65% 10%, var(--bg-tint) 0%, var(--bg) 55%); }
|
|
.login-card { width: 360px; background: var(--panel); border: 1px solid var(--input-border); border-radius: 12px; box-shadow: var(--shadow); padding: 22px; }
|
|
.login-card h2 { margin:0 0 12px; font-size:18px; }
|
|
.login-card .field { display:flex; flex-direction:column; gap:8px; margin-top:10px; }
|
|
.login-card input[type=password] { padding:10px 12px; background: var(--input-bg); color: var(--text); border:1px solid var(--input-border); border-radius:8px; }
|
|
.login-card .actions { display:flex; gap:10px; margin-top:16px; justify-content:flex-end; }
|
|
.error { color:#d33; font-size:13px; margin-top:6px; }
|
|
.tips { color:var(--muted); font-size:12px; margin-top:10px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-wrap">
|
|
<form class="login-card" method="post" autocomplete="off">
|
|
<h2>请输入访问密码</h2>
|
|
<div class="field">
|
|
<label for="password">密码</label>
|
|
<input id="password" name="password" type="password" placeholder="输入密码" />
|
|
</div>
|
|
<?php if ($error): ?>
|
|
<div class="error"><?= htmlspecialchars($error) ?></div>
|
|
<?php endif; ?>
|
|
<div class="actions">
|
|
<button class="btn primary" type="submit">登录</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|