From 5b009b838b215936b3e173007a87266b67113bc7 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sat, 12 Jul 2025 13:50:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E6=9B=BF=E6=8D=A2alert=E4=B8=BA?= =?UTF-8?q?Swal=E5=BC=B9=E7=AA=97=E5=B9=B6=E4=BC=98=E5=8C=96=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 统一代码缩进和格式化 style: 优化CSS样式和代码可读性 --- admin/addapp.php | 4 +- admin/announcements.php | 6 +- admin/deleteapp.php | 6 +- admin/editapp.php | 21 +++-- admin/index.php | 32 ++++++- admin/login.php | 172 +++++++++++++++++----------------- admin/system_info.php | 144 ++++++++++++++-------------- docs/app_review_standards.php | 4 +- download.php | 88 ++++++++--------- error_pages/404.html | 28 +++++- error_pages/500.html | 28 +++++- router.php | 64 ++++++------- 12 files changed, 332 insertions(+), 265 deletions(-) diff --git a/admin/addapp.php b/admin/addapp.php index 4a0e719..e0e4799 100644 --- a/admin/addapp.php +++ b/admin/addapp.php @@ -87,10 +87,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) { } } - header('Location: index.php?success=App 添加成功'); + echo ''; exit; } else { - $error = 'App 添加失败: '. $conn->error; + echo ''; } } } diff --git a/admin/announcements.php b/admin/announcements.php index d394f30..477cce2 100644 --- a/admin/announcements.php +++ b/admin/announcements.php @@ -17,14 +17,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)'); $stmt->bind_param('ssi', $title, $content, $admin_id); if ($stmt->execute()) { - header('Location: announcements.php?success=公告发布成功'); + echo ''; exit; } else { - $error = '公告发布失败: ' . $conn->error; + echo ''; } $stmt->close(); } else { - $error = '标题和内容不能为空'; + echo ''; } } diff --git a/admin/deleteapp.php b/admin/deleteapp.php index 9d05f8b..c26594c 100644 --- a/admin/deleteapp.php +++ b/admin/deleteapp.php @@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) { // 验证App ID if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { - header('Location: index.php?error=无效的App ID'); + echo ''; exit; } $appId = $_GET['id']; @@ -33,9 +33,9 @@ if ($stmt->execute() === TRUE) { $verStmt->bind_param("i", $appId); $verStmt->execute(); - header('Location: index.php?success=App 删除成功'); + echo ''; } else { - header('Location: index.php?error=App 删除失败: '. $conn->error); + echo ''; } exit; ?> \ No newline at end of file diff --git a/admin/editapp.php b/admin/editapp.php index cced6d7..f85b817 100644 --- a/admin/editapp.php +++ b/admin/editapp.php @@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) { // 验证App ID if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { - header('Location: index.php?error=无效的App ID'); + echo ''; exit; } $appId = $_GET['id']; @@ -23,7 +23,7 @@ $stmt->bind_param("i", $appId); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 0) { - header('Location: index.php?error=App不存在'); + echo ''; exit; } $app = $result->fetch_assoc(); @@ -99,11 +99,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) { $stmt->close(); } - header('Location: index.php?success=App 更新成功'); - exit; - } else { - $error = 'App 更新失败: '. $conn->error; - } + $updateAppSql = "UPDATE apps SET name = ?, description = ?, age_rating = ?, platforms = ? WHERE id = ?"; + $updateStmt = $conn->prepare($updateAppSql); + $updateStmt->bind_param("ssssi", $name, $description, $ageRating, $newPlatforms, $appId); + if ($updateStmt->execute() === TRUE) { + echo ''; + exit; + } else { + echo ''; + } + $updateStmt->close(); + } } ?> @@ -391,5 +397,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) { $stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?"); $stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId); -// ... existing code ... ?> \ No newline at end of file diff --git a/admin/index.php b/admin/index.php index 12ac45a..285a487 100644 --- a/admin/index.php +++ b/admin/index.php @@ -30,7 +30,7 @@ $resultApps = $conn->query($sqlApps); if (!$resultApps) { error_log("Database query failed: " . $conn->error); - echo '
获取App列表失败,请联系管理员。
'; + echo ''; } else { ?> @@ -59,6 +59,7 @@ if (!$resultApps) { + '; - -// 导航栏 -echo ''; - -// 为内容添加顶部内边距 -echo '
'; if (!isset($_SESSION['admin'])) { + $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; @@ -50,62 +21,89 @@ if (!isset($_SESSION['admin'])) { $error = '用户名或密码错误'; } } - - // 显示登录表单 - echo ''; - echo ''; - echo ''; - echo ' '; - echo ' '; - echo ' 管理员登录 - '. APP_STORE_NAME . ''; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ''; - echo ''; - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo '
管理员登录
'; - echo '
'; - if (isset($error)) { - echo ''; - echo ''; - } - echo '
'; - echo '
'; - echo ' '; - echo ' '; - echo '
'; - echo '
'; - echo ' '; - echo ' '; - echo '
'; - echo ' '; - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo '
'; - echo ' '; - echo ' '; - echo ''; - echo ''; +?> + + + + + + 管理员登录 - <?php echo APP_STORE_NAME; ?> + + + + + + + + + + + + + +
+
+
+
+
+
管理员登录
+
+ + + +
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+
+ + + + + $file, + 'size' => $file_size, + 'type' => strpos($dir, 'images') !== false ? '图片' : '文件' + ]; } } } } } - header('Location: ' . $_SERVER['PHP_SELF']); - exit; - } - - // 单个删除 - if (isset($_POST['delete_files'])) { - foreach ($_POST['delete_files'] as $file_info) { - list($type, $filename) = explode('|', $file_info); - $dir = $type === '图片' ? '../uploads/images' : '../uploads/apps'; - $file_path = $dir . '/' . $filename; - delete_file($file_path); - } - header('Location: ' . $_SERVER['PHP_SELF']); - exit; - } -} -// 验证管理员权限 -if (!isset($_SESSION['admin'])) { - header('Location: login.php'); - exit; -} - -// 获取上传文件和图片信息 -function get_uploaded_files_info() { - $uploaded_files = []; - - // 上传目录配置 - $upload_dirs = [ - '../uploads/apps', - '../uploads/images' - ]; - - foreach ($upload_dirs as $dir) { - if (is_dir($dir)) { - $files = scandir($dir); - foreach ($files as $file) { - if ($file !== '.' && $file !== '..') { - $file_path = $dir . '/' . $file; - if (is_file($file_path)) { - $file_size = filesize($file_path); - $uploaded_files[] = [ - 'name' => $file, - 'size' => $file_size, - 'type' => strpos($dir, 'images') !== false ? '图片' : '文件' - ]; - } - } - } - } + return $uploaded_files; } - - return $uploaded_files; -} -$uploaded_files = get_uploaded_files_info(); + $uploaded_files = get_uploaded_files_info(); ?> @@ -105,7 +105,7 @@ $uploaded_files = get_uploaded_files_info(); '; -// 为内容添加顶部内边距 -echo '
'; -if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) { - include 'api.php'; - exit; -} + // 为内容添加顶部内边距 + echo '
'; + if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) { + include 'api.php'; + exit; + } -// 其他请求按正常方式处理 -return false; \ No newline at end of file + // 其他请求按正常方式处理 + return false; \ No newline at end of file