✏️ 编辑:auth.php
路径:
/home/boguraj1/public_html/isp/includes/auth.php
大小:988 B · 修改:2026-06-15 23:26:22 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php /** * Auth helper functions — call at the top of every protected page. */ function requireLogin(): void { if (session_status() === PHP_SESSION_NONE) { session_start(); } if (empty($_SESSION['user_id'])) { header('Location: login.php'); exit; } } /** Admin-only pages: redirect technicians to their dashboard. */ function requireAdmin(): void { requireLogin(); if (($_SESSION['role'] ?? '') !== 'admin') { header('Location: tech_dashboard.php'); exit; } } /** Technician-only pages: redirect admins to admin dashboard. */ function requireTechnician(): void { requireLogin(); if (($_SESSION['role'] ?? '') !== 'technician') { header('Location: dashboard.php'); exit; } } function isAdmin(): bool { return isset($_SESSION['role']) && $_SESSION['role'] === 'admin'; } function isTechnician(): bool { return isset($_SESSION['role']) && $_SESSION['role'] === 'technician'; }
💾 保存
取消
保存为 UTF-8,换行统一为 LF