phpGACL中文手册(十一)
2006-08-11 15:56
302 查看
sing phpGACL in your application
在你的应用程序中使用phpGACL
Basic usage 基本用法
This example shows a basic example of using phpGACL in your code. It uses the ADOdb abstraction layer as well, and shows a simple way to validate a login attempt against a database.
这个实例展示了在你程序中使用phpGACL的基本用法。它使用了ADOdb数据抽象层,并且用一种简单的方式来确保登录数据库的合法性。
// include basic ACL api
include('phpgacl/gacl.class.php');
$gacl = new gacl(); $username = $db->quote($_POST['username']);
$password = $db->quote(md5($_POST['password']));
$sql = 'SELECT name FROM users WHERE name=';
$sql .= $username.' AND password='.$password;
$row = $db->GetRow($sql); if($gacl->acl_check('system','login','user',$row['name'])){
$_SESSION['username'] = $row['name'];
return true;
}
else return false;
As you can see there is only one call to acl_check() in this code. What does it do? Well, it checks the ARO object $row['name'] from the ARO section 'user' against the ACO object 'login' from the ACO section 'system'.
你可以看到在这儿仅仅调用了acl_check()函数。它做了什么呢?它从ARO节"user"中检查ARO对象$row['name']从ACO节"system"中对比ACO对象"login"
在你的应用程序中使用phpGACL
Basic usage 基本用法
This example shows a basic example of using phpGACL in your code. It uses the ADOdb abstraction layer as well, and shows a simple way to validate a login attempt against a database.
这个实例展示了在你程序中使用phpGACL的基本用法。它使用了ADOdb数据抽象层,并且用一种简单的方式来确保登录数据库的合法性。
// include basic ACL api
include('phpgacl/gacl.class.php');
$gacl = new gacl(); $username = $db->quote($_POST['username']);
$password = $db->quote(md5($_POST['password']));
$sql = 'SELECT name FROM users WHERE name=';
$sql .= $username.' AND password='.$password;
$row = $db->GetRow($sql); if($gacl->acl_check('system','login','user',$row['name'])){
$_SESSION['username'] = $row['name'];
return true;
}
else return false;
As you can see there is only one call to acl_check() in this code. What does it do? Well, it checks the ARO object $row['name'] from the ARO section 'user' against the ACO object 'login' from the ACO section 'system'.
你可以看到在这儿仅仅调用了acl_check()函数。它做了什么呢?它从ARO节"user"中检查ARO对象$row['name']从ACO节"system"中对比ACO对象"login"
相关文章推荐
- phpGACL中文手册(二)
- phpGACL中文手册(八)
- phpGACL中文手册(九)
- phpGACL中文手册(三)
- phpGACL中文手册(十)
- phpGACL中文手册(四)
- phpGACL中文手册(一)
- phpGACL中文手册(五)
- phpGACL中文手册(六)
- phpGACL中文手册(七)
- phpredis中文手册——《redis中文手册》 php版
- eXtremeComponents中文手册 http://extremecomponents.org/wiki/index.php/Simplified_Chinese_Reference
- PHPExcel中文开发手册翻译版(2)
- phpExcel中文帮助手册
- phpquery中文手册
- php-redis中文参考手册_list容器相关_lPush_rPush_lPushx_rPu...
- php-redis中文参考手册_randomKey_select_move_rename_re...
- PhpExcel中文帮助手册|PhpExcel使用方法
- php chm中文手册201502月更新
- 对vim配置,主要是中文手册,php手册