| Server IP : 172.67.187.206 / Your IP : 162.159.115.42 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/supply_system/includes/ |
Upload File : |
<?php
// ตรวจสอบว่า config.php และ functions.php ถูก include แล้วหรือยัง
if (!isset($conn)) {
include_once __DIR__ . '/../config.php';
}
if (!function_exists('isLoggedIn')) {
include_once __DIR__ . '/../functions.php';
}
// ถ้ายังไม่ได้ล็อกอิน ให้ redirect ไปหน้า login
if (!isLoggedIn()) {
// อาจจะเก็บ URL ปัจจุบันไว้ใน session เพื่อ redirect กลับมาหลัง login สำเร็จ (optional)
// $_SESSION['redirect_url'] = $_SERVER['REQUEST_URI'];
redirect(BASE_URL . '/login.php');
}
// Optional: ตรวจสอบ Role เพิ่มเติมสำหรับบางหน้า
/*
function requireRole($allowedRoles = []) {
$user_type = getUserData('user_type');
if (!in_array($user_type, $allowedRoles)) {
// ถ้า Role ไม่ตรงตามที่กำหนด อาจจะ redirect ไปหน้าหลัก หรือแสดงข้อความผิดพลาด
// echo "Access Denied";
redirect(BASE_URL . '/index.php?error=permission_denied');
exit();
}
}
// ตัวอย่างการใช้งาน requireRole (ใส่ไว้ในหน้าที่ต้องการจำกัดสิทธิ์)
// requireRole(['admin', 'supply_manager']); // อนุญาตเฉพาะ admin และ supply_manager
// requireRole(['department']); // อนุญาตเฉพาะ department
*/
?>