⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 documentation-1.html

📁 PHPLOB注释详细版 使用模板技术的好帮手 PHP最有用的东东了
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php  if ($perm-&gt;have_perm("desired protection")):?&gt;Put protected HTML or PHP here&lt;?php  endif?&gt;</PRE><HR></CODE></BLOCKQUOTE><P><EM>Note:</EM> <CODE>desired protection</CODE> is any combination ofpermissions from <CODE>Example_Perm</CODE>. Using the default values fromExample_Perm, "<CODE>user</CODE>", "<CODE>user,author</CODE>" or "<CODE>admin</CODE>" are allvalid sample values. A user can access a page, if that user hasall permissions that are being requested in a$perm-&gt;check() or $perm-&gt;have_perm() call.<P><EM>Note:</EM> Users can have multiple permission in their permscolumn of <CODE>auth_user</CODE>. A user with perms"<CODE>user,author,editor</CODE>" can access all pages requesting anycombination of these permissions.<P><EM>Note:</EM> Don't use spaces. "<CODE>user,author,editor</CODE>" works."<CODE>user, author, editor</CODE>" does not.<P><EM>Note:</EM> If <CODE>$auth-&gt;auth["uid"]</CODE> is set on a protectedpage <EM>and</EM> if <CODE>(time &lt; auth-&gt;auth["exp"])</CODE>, then andonly then the authentication is valid. You may then use<CODE>$auth-&gt;auth["uname"]</CODE> as the user name,<CODE>$auth-&gt;auth["uid"]</CODE> as a unique user id and<CODE>$auth-&gt;auth["perm"]</CODE> for the current permissions of thatuser. Actually, you never want to touch<CODE>$auth-&gt;auth["perm"]</CODE> manually, but use<CODE>$perm-&gt;have_perm("...")</CODE> for that.<P><DT><B>Getting a grip on PHPLIB</B><DD><P>Read on. Then read the source. Read it again -Session-&gt;serialize() and Auth-&gt;start() are ugly. Get a CVSaccount. Contribute. Become famous. Buy a ferrari.<P><EM>Note:</EM> 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...</DL><P><P><H2><A NAME="ss1.5">1.5 Testing</A></H2><P><P>These instructions apply to PHPLIB running with CGI PHP. Most ofthem is valid for mod_php as well, though. This sectionoffers an incremental approach to find installation problems,should the above installation process fail.<P>We do have a support mailing list available under the address<CODE>phplib@lists.netuse.de</CODE>. To subscribe to the list, send the command<CODE>subscribe</CODE> to the address <CODE>phplib-request@lists.netuse.de</CODE>.<P><DL><DT><B>Checking that the web server is up and running</B><DD><P>Make sure your web server is up and serving the virtual host youjust set up. To do this, construct a small file <CODE>test1.html</CODE>in your DocumentRoot and access <CODE>test1.html</CODE> through yourweb server.<P><DT><B>Checking that the web server is executing CGI programs</B><DD><P>Make sure your web server is up and does run CGI. Check thecurrent directory, the UID/GID it is running programs under andhave a look at the environment variables. Install the shellscript<P><BLOCKQUOTE><CODE><HR><PRE>#! /bin/sh -- echo "Content-Type: text/plain"echoidechopwdechoenv | sortecho</PRE><HR></CODE></BLOCKQUOTE><P>in your cgi directory under the name of <CODE>cgi-test</CODE> and inyour document root under the name of <CODE>cgi-test.cgi</CODE>. Make itexecutable. Try to access<CODE>/cgi/cgi-test?par1=one&amp;par2=two</CODE> and<CODE>/cgi-test.cgi?par1=one&amp;par2=two</CODE> and check theoutput. What UID/GID are you running under, what is the outputof <CODE>pwd</CODE> and what environment variables are set? What does<CODE>QUERY_STRING</CODE> look like? What does the <CODE>PATH</CODE>variable look like, what does the<CODE>LD_LIBRARY_PATH</CODE> variable look like and areall libraries needed by PHP accessible to PHP running in the CGIenvironment (Check by running the Unix <CODE>ldd</CODE> command on PHP).<P>In particular, if you built Oracle support into PHP and linked<CODE>libclntsh</CODE> dynamically: Can it be loaded from the CGI environment? Ifnot, PHP will not come up later in the next step.<P><DT><B>Checking that the PHP interpreter is running (Assuming CGIPHP)</B><DD><P>Copy your PHP binary into the cgi binary directory (which shouldNOT be below DocumentRoot!) and make it executable. Copy<CODE>php3.ini</CODE> into the same directory. In DocumentRoot, create a<CODE>test2.php3</CODE> and put &lt;?php phpinfo() ?&gt; into it.<P>Are you running Apache? Add<P><BLOCKQUOTE><CODE><HR><PRE>Action       php3-script /cgi/phpAddHandler   php3-script .php3DirectoryIndex index.php3 index.html index.htmFancyIndexing on</PRE><HR></CODE></BLOCKQUOTE><P>to your config. This will map all requests to files ending in<CODE>.php3</CODE> to the <CODE>php3-script</CODE> handler and define<CODE>/cgi/php</CODE> as the URL handling <CODE>php3-script</CODE> requestsinternally.<P>Request <CODE>/test2.php3</CODE> and see that it is being executed.Make changes to your <CODE>php3.ini</CODE> (preferable some colordefinitions) and reload. Are they reflected in the output of<CODE>phpinfo()</CODE>? If not, your <CODE>php3.ini</CODE> is not being foundand your are having a problem. Recompile with proper settings.<P>Check the output of <CODE>phpinfo()</CODE> carefully! Is your PHPversion current (We have tested and developed this release withPHP 3.0.12)? Are your database interfaces present in the outputof <CODE>phpinfo()</CODE>? If not, recompile again.<P>Can you access <CODE>/test2.php3</CODE> under the URL<CODE>/cgi/php/test2.php3</CODE> as well? If so, you did not compileyour PHP interpreter with <CODE>--enable-force-cgi-redirect</CODE>.PHPLIB will not work with this interpreter. Recompile with theswitch being set.<P><DT><B>PHP interpreter (Assuming mod_php)</B><DD><P><P>Assuming your server is already correctly setup(don't forget to activate the PHP lines in <CODE>srm.conf</CODE>!),enter the following file and save it as <CODE>test2.php3</CODE>under your DocumentRoot.<P><BLOCKQUOTE><CODE><HR><PRE>&lt;? phpinfo() ?></PRE><HR></CODE></BLOCKQUOTE><P>If you access this using a web browser now, it should spit outmuch info about PHP, Apache and its environment.<P><DT><B>Checking PHPLIB inclusion</B><DD><P>Does you PHP include PHPLIB properly? Check your<CODE>php3.ini</CODE> file. It must include the following settings:<P><BLOCKQUOTE><CODE><HR><PRE>include_path = pathname to directory with all the .inc filesauto_prepend_file = path to prepend.php3track_vars = On</PRE><HR></CODE></BLOCKQUOTE><P>It should contain the following settings, too:<P><BLOCKQUOTE><CODE><HR><PRE>magic_quotes_gpc = On</PRE><HR></CODE></BLOCKQUOTE><P>If PHPLIB is included properly by your setup, the following pagewill execute without errors:<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php$db = new DB_Example;print "It works without error messages.&lt;br>\n"; ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P><DT><B>Checking database connectivity</B><DD><P>PHPLIB installation requires that you adapt <CODE>local.inc</CODE>properly. Particularly, the provided class <CODE>DB_Example</CODE> must becustomized for your database connection. Test that yourweb server can access the database with the following page:<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php  include("table.inc"); // requires include_path to be functioning  $db = new DB_Example;  $db->query("select * from auth_user");  $t = new Table;  $t->heading = "on";  $t->show_result($db);?&gt;</PRE><HR></CODE></BLOCKQUOTE><P>When executing properly, this page will show you the user entryfor <CODE>kris</CODE>, password <CODE>test</CODE>, permissions <CODE>admin</CODE> fromthe <CODE>auth_user</CODE> table. If this does not happen, your<CODE>DB_Example</CODE> definition in <CODE>local.inc</CODE> is broken.<P><DT><B>Checking that sessions work</B><DD><P>Access the page <CODE>/index.php3</CODE> that has been providedwith the distribution. This page will try to set a cookie inyour browser. Allow that cookie to be set.<P>The page will display a headline with a counter. Reload thatpage. The counter must increment. If not, either your browsercannot deal properly with cookies or PHPLIB cannot properly reador write the table <CODE>active_sessions</CODE> in your database.  Checkthat the cookie is being set by viewing the output of<CODE>phpinfo()</CODE> (the fourth table will report the cookie andother per-call data). Check your database permissions with yourdatabase command line interface.<P><DT><B>Checking that Authentication works</B><DD><P>Try loading <CODE>/showoff.php3</CODE> that has been providedwith the distribution. This page will require a login. Login as<CODE>kris</CODE>, using a password of <CODE>test</CODE>. If the login issuccessful, you will see the per-session counter and a per-usercounter again. Reload that page: The counters must increment.<P>If you can't login, you probably have a problem with cookies.Check again that your browser accepts and sends session cookies.Another problem may be access to the <CODE>auth_user</CODE> table. Youmust be able to <CODE>SELECT</CODE> on that table and there must be atan entry for the user you are trying to login.</DL><P><P><HR><A HREF="documentation-2.html">Next</A>Previous<A HREF="documentation.html#toc1">Contents</A></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -