这真的取决于你需要什么。
例如,如果页面有彻底改变大的一部分,我的建议是创造不同的模板,包括他们根据自己的“权限”
$permission = $_SESSION['type_user'];
include '/path/to/file/with/permission/'.$permission.'/tpl.html';
,并有类似
东西在页面
<?php
//inside include.php you have the line similar to
//$permission = isset($_SESSION['type_user']) && $_SESSION['type_user']!=''?$_SESSION['type_user']:'common';
require_once '/mast/config/include.php';
include '/path/to/file/with/permission/common/header.html';
include '/path/to/file/with/permission/'.$permission.'/tpl_1.html';
include '/path/to/file/with/permission/common/tpl_2.html';
include '/path/to/file/with/permission/'.$permission.'/tpl_3.html';
include '/path/to/file/with/permission/common/footer.html';
?>
如果脚本充满了像“显示这个文本”,或“显示这个按钮”,您可以创建将检查的权限为您
功能小配件
<?php
function can_user($action, $what){
switch($action){
case 'write':
return $your_current_if_on_what;
break;
case 'read':
default:
return $your_current_if_on_what;
break;
}
}
?>
and the template will look like:
[my html]
<?=can_user('read','button')?'My Button':''?>
[my html]
作为一条经验法则,如果一段代码被使用超过2次,需要分别放入一个函数/文件中,所以如果你有很多“IFS”,你需要创建一个函数
扩展答案:是的,ACL是一个访问控制列表。它基本上说“这是一个用户帐户详细信息页面,因此可以通过以下角色访问:'注册用户','管理员','超级用户','上帝'”。 – cypher