更改验证

This commit is contained in:
MasonLiu committed 2026-08-25 00:07:26 +08:00
1 parent 00617621f9
commit 9e85e64345
6 files changed
+260 -85

No files matched your search

+9 -47
View File
@@ -1,54 +1,16 @@
<?php
require_once __DIR__ . '/app/logger.php';
require_once __DIR__ . '/app/pass.php';
require_once __DIR__ . '/app/auth.php';
// 检查是否已登录(简单验证)
session_start();
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
// 如果没有登录,显示简单的密码验证
if (isset($_POST['password'])) {
// 使用pass.php中定义的API_PASS作为密码
if ($_POST['password'] === API_PASS) {
$_SESSION['admin_logged_in'] = true;
} else {
$error = '密码错误';
}
}
if (!isset($_SESSION['admin_logged_in'])) {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>VPSHUB - 日志查看</title>
<style>
body { font-family: Arial, sans-serif; margin: 50px; background: #f5f5f5; }
.login-box { max-width: 400px; margin: 100px auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
h2 { margin-top: 0; color: #333; }
input[type="password"] { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
button { width: 100%; padding: 10px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
button:hover { background: #0056b3; }
.error { color: red; margin-bottom: 10px; }
</style>
</head>
<body>
<div class="login-box">
<h2>🔐 日志查看权限验证</h2>
<?php if (isset($error)): ?>
<div class="error"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<form method="POST">
<input type="password" name="password" placeholder="请输入管理员密码" required>
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
<?php
exit;
}
// 加载API_PASS(未设置则跳转到配置页)
if (!file_exists(__DIR__ . '/app/pass.php')) {
header('Location: config_add.php');
exit;
}
include __DIR__ . '/app/pass.php';
// 统一会话认证:前端输入密码验证后建立会话,30分钟滑动过期
requireAuth();
// 处理操作
$action = $_GET['action'] ?? '';