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

[翻译]PhpGACL手册(五)

2005-02-25 00:00 369 查看

Installation安装

Basic setup基本安装

Untar the distribution .tar.gz file into the root or a subdirectory of your web site. You might want to rename it to something more suitable.

将.tar.gz文件解压至你网站的根目录或子目录中,你可以将其重命名为你认为适合的名字。

Edit phpgacl/gacl.class.php using your favourite editor and set the db_type, db_host, db_user, db_password, and db_name you will be using.

你可以用你喜欢的编辑器来编辑phpgacl/gacl.class.php文件,并设置其中你将用到的 db_type, db_host, db_user, db_password和db_name变量。

Now edit phpgacl/admin/gacl_admin.inc.php to hold the same information. This file is used by the setup script as well as the ACL admin backend.

现在将hpgacl/admin/gacl_admin.inc.php文件中保持相同的信息。该文件不仅被安装脚本而且还将被ACL管理后台调用。 The reason for two files holding that (same) information, is that the core ACL library gacl.class.php is much smaller than the full-fledged API class, and there is no need to include all the code when you just want to call acl_check().

将两个文件保持相同信息的原因在于ACL核心库文件gacl.class.php比全部的API类文件要小得多,没有必要在你只想调用acl_check()文件时包含进全部代码。

Create the database you specified in db_name on the server.

在服务器上创建你在db_name变量中指定的数据库(以MySQL为例)

Surf to http://yoursite.net/phpgacl/setup.php. The required tables will be installed based on your choice of database. Don't be afraid of the truckload of output, if all goes well you will see only success messages.

在浏览器中输入网址http://你的站点/phpgacl/setup.php。被要求的表单将被建立在你创建的数据库中。不必担心会看到一堆的输出,如果正常运行的话,你将只会看到成功信息。

Now follow the last advice shown on that screen and create the phpgacl/admin/smarty/templates_c directory. It must be writable by the user the webserver runs as. If you don't do this, you will not be able to use the CAL admin!

现在按照最后在屏幕上出现的建议创建phpgacl/admin/smarty/templates_c目录。它必须是可以被WEB服务器用户写入的。如果你不能做到这一点,那么你将不能使用CAL管理!

Click the link at the bottom of the successful setup page or surf to:
http://yoursite.net/phpgacl/admin/acl_admin.php
点击成功安装页面底部的链接或直接在浏览器中输入网址: http://yoursite.net/phpgacl/admin/acl_admin.php

Advanced setup

高级安装

Reusing an already existing ADOdb installation

重新使用已有ADOdb的安装方法

If you already have ADOdb installed you can get phpGACL to use this copy of ADOdb.

如果你已经使用了ADOdb,你可以使phpGACL使用该ADOdb拷贝。

Edit phpgacl/gacl.class.php so that ADODB_DIR reflects the location of the ADOdb library in your path.

编辑 phpgacl/gacl.class.php文件,将ADODB_DIR变量设置为ADBdb库所在的目录。

Rename the phpgacl/adodb folder to something else like adodb_x and reload the phpgacl/admin/acl_admin.php page to ensure it still works.

将phpgacl/adodb目录重命名为其它名字如adodb_x,然后重新载入网页 phpgacl/admin/acl_admin.php,以确保其能正常工作。

Erase the adodb directory installed with phpGACL.

删除随phpGACL安装的adodb目录。

Reusing an already existing Smarty installation

重新使用已安装的Smarty

If you already have Smarty installed you can get phpGACL to use this copy of Smarty.

如果你已经安装了Smarty,你可以使phpGACL使用该Smarty拷贝。

Edit phpgacl/admin/gacl_admin.inc.php so that the variables $smarty_dir and $smarty_compile_dir reflect the location of the Smarty library in your path and the template_c directory you already use.

编辑 phpgacl/admin/gacl_admin.inc.php文件,以便变量$smarty_dir和 $smarty_compile_dir能指向已安装Smarty库所在位置,并且template_c目录你正在使用。
Move the templates directory that came with phpGACL to another directory (e.g. one level up). Adjust the $smarty_template_dir so it points to the new location. If you like you can move those templates to your existing templates folder, of course.

将phpGACL模板目录移至另一个目录(比如上级目录中),调整变量$smarty_template_dir使之指向新的位置。当然如果你愿意,你也可以将这些模板移到已存在的模板目录中。

Rename the phpgacl/smarty folder to something else like smarty_x and reload the phpgacl/admin/acl_admin.php page to ensure it still works.

将 phpgacl/smarty目录重命名为其他名称(如smarty_x)并重新载入 phpgacl/admin/acl_admin.php页,以确保它能正常工作。

Erase the smarty directory installed with phpGACL.

删除随phpGACL安装的smarty目录

How do I move the phpGACL files out of my website tree while leaving a link in the tree for administration?

我怎样将phpGACL文件移出网站目录,同时在该目录中留下一个链接以便管理呢?

Go to your website root.

进入你的网站根目录

Move the phpGACL directory to your includes directory and create a symlink to the admin directory where you want the admin tool to go. For example:

将phpGACL目录移入你的includes目录,同时创建一个软链接到管理工具目录。

mv phpgacl/ /www/includes_directory

ln -s /www/includes_directory/phpgacl/admin/ gacl

Now surfing to http://yoursite.net/gacl/acl_admin.php will take you to the admin page. If it doesn't work, make sure your Webserver allows symbolic links in the website tree.

现在输入网址:http://yoursite.net/gacl/acl_admin.php,进入管理页面。如果页面没有正常显示,请确认你的网站服务器允许在网站目录中存在软链接。

Using 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

你可以看到在这儿仅仅调用了acl_check()函数。它做了什么呢?它

checks the ARO object $row['name'] from the ARO section 'user'

从ARO节"user"中检查ARO对象$row['name']

against the ACO object 'login' from the ACO section 'system'.

从ACO节"system"中对比ACO对象"login"

Advanced usage高级用法

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