From d4dc9e1edcb51df122bf9c64a7e08ffd6b948732 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Tue, 15 Jul 2025 21:30:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9D=83=E9=99=90=E7=B3=BB=E7=BB=9F=E5=B9=B6=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8C=96sweetalert=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加管理员权限系统,支持all/say/review三种权限类型 - 为各管理页面添加权限检查逻辑 - 将sweetalert从CDN改为本地资源 - 添加统一的登出确认弹窗和logout.php处理 - 更新config.php中的数据库和SMTP配置 --- admin/addapp.php | 53 +++++++++++++++++++++++++---------- admin/announcements.php | 25 +++++++++++++++-- admin/editapp.php | 30 +++++++++++++++++--- admin/index.php | 30 +++++++++++++++++--- admin/login.php | 14 +++++++-- admin/logout.php | 28 ++++++++++++++++++ admin/manage_developers.php | 29 +++++++++++++++++-- admin/manage_tags.php | 26 +++++++++++++++++ admin/manage_versions.php | 11 ++++++-- admin/review_apps.php | 33 ++++++++++++++++++---- admin/system_info.php | 7 +++++ app.php | 4 +-- config.php | 1 + developer/dashboard.php | 2 +- developer/upload_app.php | 2 +- developer/version_control.php | 2 +- history_announcements.php | 2 +- index.php | 2 +- js/sweetalert.js | 6 ++++ thanks.php | 2 +- 20 files changed, 263 insertions(+), 46 deletions(-) create mode 100644 admin/logout.php create mode 100644 js/sweetalert.js diff --git a/admin/addapp.php b/admin/addapp.php index 6551185..d0574d0 100644 --- a/admin/addapp.php +++ b/admin/addapp.php @@ -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(); } $success = ''; @@ -96,19 +103,36 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) { } ?> - + - - - 添加App - <?php echo APP_STORE_NAME; ?> - - - + 添加应用 - - - - + diff --git a/admin/logout.php b/admin/logout.php new file mode 100644 index 0000000..1370452 --- /dev/null +++ b/admin/logout.php @@ -0,0 +1,28 @@ +'; +echo ''; +exit(); \ No newline at end of file diff --git a/admin/manage_developers.php b/admin/manage_developers.php index 149387e..8a35838 100644 --- a/admin/manage_developers.php +++ b/admin/manage_developers.php @@ -4,10 +4,17 @@ require_once '../config.php'; // 设置会话cookie路径为根目录以确保跨目录访问 session_set_cookie_params(0, '/'); 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(); } // 处理退出登录 @@ -41,7 +48,7 @@ if (isset($_GET['logout'])) { 管理开发者 @@ -206,6 +213,22 @@ if (!$stmt) { } + + diff --git a/admin/manage_tags.php b/admin/manage_tags.php index 365822b..56bd142 100644 --- a/admin/manage_tags.php +++ b/admin/manage_tags.php @@ -2,6 +2,13 @@ require_once '../config.php'; require_once 'login.php'; // 确保管理员已登录 +// 检查权限 +if ($_SESSION['admin']['permission'] != 'all') { + $redirect = $_SESSION['admin']['permission'] == 'say' ? 'announcements.php' : 'review_apps.php'; + header("Location: $redirect"); + exit(); +} + // 处理标签添加 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_tag'])) { $name = trim($_POST['tag_name']); @@ -61,6 +68,22 @@ $tagsResult = $conn->query("SELECT * FROM tags ORDER BY created_at DESC"); 标签管理 - 应用商店后台 + +
@@ -152,5 +175,8 @@ $tagsResult = $conn->query("SELECT * FROM tags ORDER BY created_at DESC");
+ \ No newline at end of file diff --git a/admin/manage_versions.php b/admin/manage_versions.php index 2b0f2c2..fc97cbd 100644 --- a/admin/manage_versions.php +++ b/admin/manage_versions.php @@ -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 diff --git a/admin/review_apps.php b/admin/review_apps.php index f231896..f58ec68 100644 --- a/admin/review_apps.php +++ b/admin/review_apps.php @@ -6,10 +6,17 @@ use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; session_start(); -// 检查管理员登录状态 +// 检查是否已登录 if (!isset($_SESSION['admin'])) { header('Location: login.php'); - exit; + exit(); +} + +// 检查权限 - 允许all和review权限 +if (!in_array($_SESSION['admin']['permission'], ['all', 'review'])) { + $redirect = $_SESSION['admin']['permission'] == 'say' ? 'announcements.php' : 'review_apps.php'; + header("Location: $redirect"); + exit(); } $success = ''; @@ -133,7 +140,7 @@ if (!($conn instanceof mysqli)) { - + @@ -171,7 +178,7 @@ if (!($conn instanceof mysqli)) { 应用审核 @@ -314,6 +321,22 @@ function showRejectReason(appId, appName) { - + + \ No newline at end of file diff --git a/admin/system_info.php b/admin/system_info.php index 4f9009d..dc85eb0 100644 --- a/admin/system_info.php +++ b/admin/system_info.php @@ -55,6 +55,13 @@ exit; } + // 检查权限 + if ($_SESSION['admin']['permission'] != 'all') { + $redirect = $_SESSION['admin']['permission'] == 'say' ? 'announcements.php' : 'review_apps.php'; + header("Location: $redirect"); + exit(); + } + // 获取上传文件和图片信息 function get_uploaded_files_info() { $uploaded_files = []; diff --git a/app.php b/app.php index 4fb3aa9..ba43fca 100644 --- a/app.php +++ b/app.php @@ -137,8 +137,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) { - - + + diff --git a/config.php b/config.php index 7ee3ed4..bea057a 100644 --- a/config.php +++ b/config.php @@ -23,6 +23,7 @@ define('SMTP_FROM_NAME', 'leonmm2@163.com'); // 管理员账号 - 支持多个账号 $admin_accounts = [ ['id' => 1, 'username' => 'Admin', 'password' => ''], + ['id' => 2, 'username' => 'Admin2', 'password' => ''], // 可添加更多管理员账号,格式: ['id' => 数字, 'username' => '用户名', 'password' => ''] ]; diff --git a/developer/dashboard.php b/developer/dashboard.php index d0deb50..e2be416 100644 --- a/developer/dashboard.php +++ b/developer/dashboard.php @@ -48,7 +48,7 @@ if (!($conn instanceof mysqli)) { - +