您的位置:首页 > 编程语言 > PHP开发

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"

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息