📄 01-usingcore.sgml
字号:
<!-- $Id: 01-usingcore.sgml,v 1.1.1.1 2000/04/17 16:39:58 kk Exp $ --><sect1>Using core features of PHPLIB<p>Many applications don't use PHPLIB's advanced features, but see PHPLIB as a convenient way to protect pages or functionality with passwords. This section covers such core functionality usage of PHPLIB.<descrip><tag>Customizing the login screen</tag><p>Edit <tt/loginform.ihtml/ in the include directory to suityour needs.<tag>Customizing the permission levels</tag>Edit <tt/local.inc/ and change the class <tt/Example_Perm/ toenumerate your permissions. Your users in <tt/auth_user/ musthave one or more comma separated permission names from thatlist. Edit <tt/perminvalid.ihtml/ for a suitable error message.<tag>Creating New Users</tag><p>Use <tt/new_user.php3/ from the <tt>pages/admin</tt> directory of the distribution. If you followed the installation instructions, it should be available under the <tt>/admin</tt> URL of your web server.To manually create a user, run <tt/print md5(uniqid("some magicstring")/ to get a user id. <tt/insert into auth_user values ("that userid", "username", "password", "permissions");/.<tag>Creating an unprotected session page</tag><p>Begin that page with <tscreen><code><?php page_open(array("sess" => "Example_Session")); ?></code></tscreen>End that page with <tscreen><code><?php page_close(); ?></code></tscreen><tag>Creating a protected session page</tag><p>Begin that page with<tscreen><code><?php page_open( array("sess" => "Example_Session", "auth" => "Example_Auth", "perm" => "Example_Perm")); $perm->check("desired protection");?></code></tscreen>and end that page with<tscreen><code><?php page_close(); ?></code></tscreen><tag>Creating protected functionality</tag><p>Begin that page with<tscreen><code><?php page_open( array("sess" => "Example_Session", "auth" => "Example_Auth", "perm" => "Example_Perm"));?></code></tscreen>and end that page with<tscreen><code><?php page_close(); ?></code></tscreen>Enclose the protected functionality in<tscreen><code><?php if ($perm->have_perm("desired protection")):?>Put protected HTML or PHP here<?php endif?></code></tscreen><em/Note:/ <tt/desired protection/ is any combination ofpermissions from <tt/Example_Perm/. Using the default values fromExample_Perm, "<tt/user/", "<tt/user,author/" or "<tt/admin/" are allvalid sample values. A user can access a page, if that user hasall permissions that are being requested in a$perm->check() or $perm->have_perm() call.<em/Note:/ Users can have multiple permission in their permscolumn of <tt/auth_user/. A user with perms"<tt/user,author,editor/" can access all pages requesting anycombination of these permissions.<em/Note:/ Don't use spaces. "<tt/user,author,editor/" works."<tt/user, author, editor/" does not.<em/Note:/ If <tt/$auth->auth["uid"]/ is set on a protectedpage <em/and/ if <tt/(time < auth->auth["exp"])/, then andonly then the authentication is valid. You may then use<tt/$auth->auth["uname"]/ as the user name,<tt/$auth->auth["uid"]/ as a unique user id and<tt/$auth->auth["perm"]/ for the current permissions of thatuser. Actually, you never want to touch<tt/$auth->auth["perm"]/ manually, but use<tt/$perm->have_perm("...")/ for that.<tag>Getting a grip on PHPLIB</tag><p>Read on. Then read the source. Read it again -Session->serialize() and Auth->start() are ugly. Get a CVSaccount. Contribute. Become famous. Buy a ferrari.<em/Note:/ You want to understand what registered variables are.You want to understand in what order form variables and sessionvariables are imported into your page. You want to understandhow to copy values from form values into session values withoutkilling yourself. You do not want to make form variablespersistent, ever. Then you will live happily thereafter...</descrip>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -