更改验证

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

+11 -10
View File
@@ -5,6 +5,7 @@
*/
require_once __DIR__ . '/app/db_helper.php';
require_once __DIR__ . '/app/auth.php';
require_once __DIR__ . '/mofangidc.php';
// Token文件路径(存储API_PASS)
@@ -33,7 +34,10 @@ if ($needSetup && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['setup_p
if (file_put_contents($tokenFile, $content)) {
chmod($tokenFile, 0600);
header('Location: config_add.php?pass=' . urlencode($apiPass));
// 密码刚由本人设置,直接建立登录会话并跳转
include $tokenFile;
attemptLogin($apiPass);
header('Location: config_add.php');
exit;
} else {
$setupError = '保存失败,请检查目录权限!';
@@ -114,14 +118,8 @@ if (file_exists($tokenFile)) {
include $tokenFile;
}
// 验证pass参数
$pass = isset($_GET['pass']) ? $_GET['pass'] : '';
if (!defined('API_PASS') || $pass !== API_PASS) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['status' => 403, 'msg' => '访问密码错误'], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
// 会话认证:前端输入密码验证后建立会话,30分钟滑动过期
requireAuth();
// 处理添加配置
$message = '';
@@ -383,7 +381,10 @@ $configs = $db->query('SELECT * FROM configs ORDER BY id');
<div class="header">
<h1>⚙️ VPS配置管理</h1>
<p>添加和管理多平台VPS配置</p>
<a href="index.php?pass=<?php echo urlencode($pass); ?>" class="btn" style="float: right; margin-top: -60px;">返回首页</a>
<div style="float: right; margin-top: -60px; display: flex; gap: 10px; align-items: center;">
<a href="index.php" class="btn">返回首页</a>
<a href="index.php?logout=1" class="btn" style="background: #6c757d; color: white;" onclick="return confirm('确认退出登录?')">🚪 退出登录</a>
</div>
</div>
<div class="content">