修复权限管理,角色认证,更新工单认领系统,增加表格导出支持区间选择,增加docker管理(开发中

This commit is contained in:
2026-07-09 10:06:44 +08:00
parent 0c2fe393df
commit 3b84698fd3
25 changed files with 8975 additions and 102 deletions
+30 -12
View File
@@ -26,7 +26,7 @@ $userName = htmlspecialchars($_SESSION['username'] ?? '');
$isAdmin = intval($_SESSION['is_admin'] ?? 0);
$userRoleId = intval($_SESSION['role_id'] ?? 0);
// ====================== 双库固定连接(修复null根源) ======================
// ====================== 双库固定连接 ======================
$dbHost = "10.150.117.190";
$dbUser = "root";
$dbPass = "hp93000";
@@ -48,27 +48,43 @@ if (!$connMonitor) {
mysqli_set_charset($connMonitor, "utf8mb4");
// ========================================================================
// 获取当前访问页面文件名(去掉.php后缀)
$currentPage = basename($_SERVER['SCRIPT_NAME'], '.php');
// ========== 新增:读取角色真实名称 ==========
$roleRealName = "未知角色";
if ($userRoleId > 0) {
$getRoleSql = "SELECT role_name FROM sys_role WHERE id = $userRoleId";
$roleResult = mysqli_query($connMonitor, $getRoleSql);
if ($roleResult && $roleRow = mysqli_fetch_assoc($roleResult)) {
$roleRealName = $roleRow['role_name'];
}
}
// 超级管理员强制覆盖文字
if ($isAdmin === 1) {
$roleRealName = "超级管理员";
}
// ===========================================
// 非超级管理员校验页面权限
if ($isAdmin !== 1) {
// 1. 登录时一次性加载当前角色全部权限,存入全局变量(侧边栏共用)
$allowPages = [];
if ($userRoleId > 0) {
$permSql = "SELECT page_key FROM sys_role_permission WHERE role_id = $userRoleId";
$permRes = mysqli_query($connMonitor, $permSql);
$allowPages = [];
if ($permRes) {
while ($row = mysqli_fetch_assoc($permRes)) {
$allowPages[] = $row['page_key'];
}
}
// 无权限拦截
if (!in_array($currentPage, $allowPages)) {
echo "<script>alert('无访问权限!');history.back();</script>";
exit;
}
}
// 读取右上角未读消息数量(修复第79/84/86行报错
// 2. 获取当前访问页面文件名(去掉.php后缀
$currentPage = basename($_SERVER['SCRIPT_NAME'], '.php');
// 3. 非管理员自动拦截无权限页面(全局统一校验,无需每个页面重复写)
if ($isAdmin !== 1 && !in_array($currentPage, $allowPages)) {
echo "<script>alert('无访问权限!');history.back();</script>";
exit;
}
// 读取右上角未读消息数量
$unreadMsgCount = 0;
$msgSql = "SELECT COUNT(id) cnt FROM sys_user_msg WHERE user_id = $loginUserId AND is_read = 0";
$msgRes = mysqli_query($connMonitor, $msgSql);
@@ -142,4 +158,6 @@ if (!empty($sidebarRawLinks)) {
}
}
}
// 【已删除冲突无用函数 hasPagePerm】
?>