升级页增加登录与班主任权限校验

upgrade.php 原来无任何校验,任何人可访问执行;现要求登录且拥有系统升级权限(manage_upgrade,默认仅班主任):
页面未授权跳登录页,POST 请求未授权返回 403 JSON。
This commit is contained in:
canglan committed 2026-10-10 15:55:33 +08:00
1 parent 982e6ad70f
commit fbd34b3d14
1 file changed
+18
+18
View File
@@ -4,8 +4,26 @@
*
* 读取 VERSION 文件确定目标版本,自动检测数据库当前版本,
* 依次执行增量 SQL 升级脚本。
*
* 仅限班主任(拥有系统升级权限 manage_upgrade)使用。
*/
// 登录与权限校验:仅班主任(系统升级权限)可访问与执行
require_once __DIR__ . '/frontend/config.php';
if (!isset($_SESSION['user_id'])
|| ($_SESSION['user_type'] ?? '') !== 'admin'
|| !has_perm('manage_upgrade')) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' || isset($_GET['action'])) {
header('Content-Type: application/json; charset=utf-8');
http_response_code(403);
echo json_encode(['success' => false, 'error' => '未授权:仅班主任(系统升级权限)可执行升级操作']);
exit();
}
header('Location: /index.php');
exit();
}
// ===========================================
// 辅助函数
// ===========================================