73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT setting_value FROM settings WHERE setting_key = 'site_logo'");
|
|
$site_logo = $stmt->fetchColumn() ?: 'assets/pasted-20260207-134833-7329dc42.jpg';
|
|
|
|
$error = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = $_POST['username'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
if ($username === 'admin') {
|
|
$stmt = $pdo->prepare("SELECT password FROM users WHERE username = 'admin'");
|
|
$stmt->execute();
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user && password_verify($password, $user['password'])) {
|
|
$_SESSION['admin_logged_in'] = true;
|
|
header('Location: admin.php');
|
|
exit;
|
|
} else {
|
|
$error = '用户名或密码错误';
|
|
}
|
|
} else {
|
|
$error = '权限不足';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - 财神组聊天框架</title>
|
|
<link rel="icon" type="image/jpeg" href="<?php echo htmlspecialchars($site_logo); ?>">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
body { background-color: #f8f9fa; height: 100vh; display: flex; align-items: center; justify-content: center; }
|
|
.login-card { width: 100%; max-width: 400px; padding: 40px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); background: #fff; }
|
|
.btn-warning { background-color: #d4af37; border: none; color: #fff; }
|
|
.btn-warning:hover { background-color: #b8860b; color: #fff; }
|
|
.logo-img { max-height: 100px; margin-bottom: 20px; border-radius: 12px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-card text-center">
|
|
<?php if($site_logo): ?>
|
|
<img src="<?php echo htmlspecialchars($site_logo); ?>" alt="Logo" class="logo-img">
|
|
<?php endif; ?>
|
|
<h3 class="mb-4">管理登录</h3>
|
|
<?php if($error): ?>
|
|
<div class="alert alert-danger text-start"><?php echo $error; ?></div>
|
|
<?php endif; ?>
|
|
<form method="POST" class="text-start">
|
|
<div class="mb-3">
|
|
<label class="form-label">用户名</label>
|
|
<input type="text" name="username" class="form-control" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">密码</label>
|
|
<input type="password" name="password" class="form-control" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-warning w-100 py-2 mt-2">登录</button>
|
|
</form>
|
|
<div class="text-center mt-3">
|
|
<a href="index.php" class="text-muted text-decoration-none small">返回首页</a>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|