This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
luowei_exam/acl_list.php
2025-01-09 11:57:41 +08:00

18 lines
402 B
PHP

<?php
// 定义 ACL 表
$acl = array(
"cto" => array("p_1.php", "p_2.php", "p_3.php"),
"manager" => array("p_2.php", "p_3.php"),
"staff" => array("p_3.php")
);
// 定义检查权限的函数
function checkAccess($role, $resource) {
global $acl;
if (isset($acl[$role]) && in_array($resource, $acl[$role])) {
return true; // 有权限
}
return false; // 无权限
}