feat: 实现管理员权限系统并本地化sweetalert资源
- 添加管理员权限系统,支持all/say/review三种权限类型 - 为各管理页面添加权限检查逻辑 - 将sweetalert从CDN改为本地资源 - 添加统一的登出确认弹窗和logout.php处理 - 更新config.php中的数据库和SMTP配置
This commit is contained in:
@@ -2,10 +2,17 @@
|
||||
require_once '../config.php';
|
||||
|
||||
session_start();
|
||||
// 检查管理员登录状态
|
||||
// 检查是否已登录
|
||||
if (!isset($_SESSION['admin'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
exit();
|
||||
}
|
||||
|
||||
// 检查权限
|
||||
if ($_SESSION['admin']['permission'] != 'all') {
|
||||
$redirect = $_SESSION['admin']['permission'] == 'say' ? 'announcements.php' : 'review_apps.php';
|
||||
header("Location: $redirect");
|
||||
exit();
|
||||
}
|
||||
|
||||
// 验证App ID
|
||||
@@ -122,7 +129,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
|
||||
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- 自定义CSS -->
|
||||
<link rel="stylesheet" href="../styles.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="/js/sweetalert.js"></script>
|
||||
<script>
|
||||
function confirmLogout() {
|
||||
Swal.fire({
|
||||
title: '确定要登出吗?',
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = 'logout.php';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<!-- Fluent Design 模糊效果 -->
|
||||
<style>
|
||||
.blur-bg {
|
||||
@@ -151,7 +173,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
|
||||
<a class="nav-link active" aria-current="page" href="editapp.php?id=<?php echo $appId; ?>">编辑App</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="?logout=true">退出登录</a>
|
||||
<a class="nav-link" href="#" onclick="confirmLogout()">退出登录</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user