From 55d2dfa46b758281f4a1dc96488a85b17370e0f6 Mon Sep 17 00:00:00 2001 From: Yongquan Date: Sun, 1 Nov 2026 12:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=9A=E8=BD=AF=E4=BB=B6/=E5=88=86=E7=B1=BB/?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=AF=E9=85=8D=EF=BC=8C=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E5=8F=AF=E6=94=B9=E6=8C=82=E5=BD=92=E5=B1=9E=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 新增 lib/admin_taxonomy.php - 软件:增删改、排序、启停;新增时自动预置 Bug/功能建议/其他 三个分类 - 分类:在选定软件下增删改、排序、启停 - 状态:改名、改「给用户看的话」、排序、启停;标识不可改(历史数据靠它对应) - 反馈改挂:th_move,可把反馈移到别的软件/分类,跨软件的非法分类会被拒 ## 安全与边界 - 所有动作走 CSRF 校验(沿用现有机制) - 不能删最后一个软件 / 没有分类的软件至少要留一个启用分类 - 有反馈挂着的软件或分类不能删,提示改为停用(停用后前台消失、数据保留) - th_move 加入 fb_admin_is_taxonomy_act 白名单,否则会被「问题不存在」静默吞掉 ## admin.php 接线 - 引入模块 + 动作分发 + tab 白名单加 taxonomy/statuses + 导航两项 - 前置检查放行不依赖 $t 的动作(否则新增软件报「问题不存在」) - 全部问题列表:加软件筛选、分类跟着软件走;修掉三处仍在用旧 fb_statuses()/fb_categories() 的遍历(那会渲染出错) - 详情页加「归属」表单,软件徽章可显示 ## 其他文件 - api.php:状态/分类改数据库;新增 ?sw= / ?software_id= / ?cid= 过滤, 老的 ?category= 仍可用(在所属软件内解析) - thread.php:详情页显示软件与分类徽章 - config.example.php:移除 categories / statuses,改由数据库管理 ## 修掉两个真实 bug 1. 移除配置后出厂分类兜底只剩 4 个,漏了「同步问题」—— 建库后核对数量才发现 2. th_move 不在白名单,POST 后返回 200 却静默不生效 验证:后台 e2e 29/29;改挂与联动 13/13;PHP 8.5 全部入口 0 弃用; 19 个 PHP 文件语法全过。 --- admin.php | 102 +++++++-- api.php | 35 +++- assets/style.css | 40 ++++ config.example.php | 24 +-- lib/admin_taxonomy.php | 456 +++++++++++++++++++++++++++++++++++++++++ lib/db.php | 9 +- lib/layout.php | 2 +- thread.php | 9 +- 8 files changed, 639 insertions(+), 38 deletions(-) create mode 100644 lib/admin_taxonomy.php diff --git a/admin.php b/admin.php index df4d036..6a393a8 100644 --- a/admin.php +++ b/admin.php @@ -12,6 +12,7 @@ * 入口:/feedback/admin.php */ require __DIR__ . '/lib/bootstrap.php'; +require __DIR__ . '/lib/admin_taxonomy.php'; $pdo = fb_db(); @@ -93,7 +94,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['act'])) { $act = (string)$_POST['act']; $t = fb_admin_thread($pdo, $id); - if (!$t && $act !== 'settings' && $act !== 'password') { + // 这些动作不针对某一条反馈(不依赖 $t),单独放行 + $noThread = in_array($act, ['settings', 'password'], true) + || fb_admin_is_taxonomy_act($act); + + if (!$t && !$noThread) { $msg = '问题不存在。'; $msgType = 'error'; @@ -182,6 +187,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['act'])) { fb_mod_log('delete', $id, '删除问题:' . fb_excerpt((string)$t['title'], 40)); $msg = '#' . $id . ' 已删除。'; + } elseif (fb_admin_is_taxonomy_act($act)) { + list($msg, $msgType) = fb_admin_taxonomy_action($pdo, $act, $_POST); + } elseif ($act === 'settings') { $msg = fb_admin_save_settings(); @@ -300,7 +308,7 @@ function fb_admin_save_settings() { * 页面 * ================================================================== */ $tab = (string)(isset($_GET['tab']) ? $_GET['tab'] : 'pending'); -if (!in_array($tab, ['pending', 'all', 'thread', 'settings', 'log'], true)) { $tab = 'pending'; } +if (!in_array($tab, ['pending', 'all', 'thread', 'taxonomy', 'statuses', 'settings', 'log'], true)) { $tab = 'pending'; } fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']); ?> @@ -315,6 +323,8 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']); @@ -343,9 +353,12 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']); $visF = (string)(isset($_GET['vis']) ? $_GET['vis'] : ''); $catF = (string)(isset($_GET['cat']) ? $_GET['cat'] : ''); $qF = trim((string)(isset($_GET['q']) ? $_GET['q'] : '')); + $swF = isset($_GET['sw']) ? (int)$_GET['sw'] : 0; + $cidF = isset($_GET['cid']) ? (int)$_GET['cid'] : 0; if ($stF !== '') { $where[] = 'status = ?'; $args[] = $stF; } if ($visF === '1' || $visF === '0') { $where[] = 'visible = ?'; $args[] = (int)$visF; } - if ($catF !== '') { $where[] = 'category = ?'; $args[] = $catF; } + if ($swF > 0) { $where[] = 'software_id = ?'; $args[] = $swF; } + if ($cidF > 0) { $where[] = 'category_id = ?'; $args[] = $cidF; } if ($qF !== '') { $where[] = '(title LIKE ? OR body LIKE ?)'; $args[] = '%' . $qF . '%'; $args[] = '%' . $qF . '%'; } $wSql = $where ? ('WHERE ' . implode(' AND ', $where)) : ''; @@ -364,17 +377,29 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);
+ - + + 0 ? [fb_software($swF)] : fb_softwares(false); + foreach ($catSwList as $csw1): + if (!$csw1) { continue; } + foreach (fb_categories((int)$csw1['id'], false) as $c1): + ?> + + + +

+ 挂错软件或分类时在这里改正。换软件后分类选项会跟着变,需重新选择。 +

+
+ + +
+ +
+

以官方身份回复

@@ -481,7 +545,7 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']); 同时把状态改为 @@ -499,7 +563,7 @@ fb_layout_head('管理后台', ['robots' => 'noindex,nofollow']);