feat: 实现管理员权限系统并本地化sweetalert资源

- 添加管理员权限系统,支持all/say/review三种权限类型
- 为各管理页面添加权限检查逻辑
- 将sweetalert从CDN改为本地资源
- 添加统一的登出确认弹窗和logout.php处理
- 更新config.php中的数据库和SMTP配置
This commit is contained in:
2025-07-15 21:30:51 +08:00
parent 3ca83c8662
commit d4dc9e1edc
20 changed files with 263 additions and 46 deletions

View File

@@ -15,7 +15,8 @@ if (!isset($_SESSION['admin'])) {
if ($username === $account['username'] && $password === $account['password']) {
$_SESSION['admin'] = [
'id' => $account['id'],
'username' => $account['username']
'username' => $account['username'],
'permission' => $account['permission']
];
$adminFound = true;
@@ -35,7 +36,14 @@ if (!isset($_SESSION['admin'])) {
ini_set('session.gc_maxlifetime', $cookie_lifetime);
}
header('Location: index.php');
// 根据权限设置重定向页面
$redirectPage = 'index.php';
if ($_SESSION['admin']['permission'] == 'say') {
$redirectPage = 'announcements.php';
} elseif ($_SESSION['admin']['permission'] == 'review') {
$redirectPage = 'review_apps.php';
}
header("Location: $redirectPage");
exit();
}
}
@@ -77,7 +85,7 @@ if (!isset($_SESSION['admin'])) {
}
}
</style>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="/js/sweetalert.js"></script>
</head>
<body class="page-transition">
<!-- 导航栏 -->