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

📄 documentation-1.html

📁 PHPLOB注释详细版 使用模板技术的好帮手 PHP最有用的东东了
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>PHP Base Library Documentation, Release phplib_7_2: Quick Start</TITLE> <LINK HREF="documentation-2.html" REL=next> <LINK HREF="documentation.html#toc1" REL=contents></HEAD><BODY><A HREF="documentation-2.html">Next</A>Previous<A HREF="documentation.html#toc1">Contents</A><HR><H2><A NAME="s1">1. Quick Start</A></H2><P>The Quick Start chapter tries to give you a ten-minute introduction toPHPLIB installation, outlines a few simple testing procedures and closeswith an overview of PHPLIB features.<P><H2><A NAME="ss1.1">1.1 License</A></H2><P><P>PHPLIB consists of the files in this directory and all itssubdirectories. It is made available as free software under theLIBRARY GNU General Public license, as spelled out in the file<CODE>COPYING</CODE> in this directory. Also, it is distributed in thehope that it will be useful, but WITHOUT ANY WARRANTY; withouteven the implied warranty of MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE.  See the license for more details.<P><P><H2><A NAME="ss1.2">1.2 Target Group and Prerequisites</A></H2><P><P>PHPLIB targets the PHP application developer. You need to havegood knowledge of the PHP language, at least basic SQL databaseknowhow and at least basic knowledge on how to operate yourweb server to be able to use the library.<P>The library will help you to write medium to large sizeddata-driven web applications. "Medium to large sizedapplications" are applications that consist of multiple databasequeries, have to generate tables from database data, need a userinterface that generates SQL queries or need a comfortable anduser-friendly way to protect pages or functionality on pages."Data-driven" applications are applications that make use of asupported SQL-database to create HTML content and that use HTMLforms to drive database transactions.<P>To make use of the library you obviously need access to a webserver with a working installation of a current PHP interpreter(we recommend 3.0.12 or newer for this release of the library)and access to a supported SQL database (currently, PHPLIBsupports MySQL, PostgreSQL, mSQL, Oracle 7 and Oracle 8, Sybase,Microsoft SQL Server and ODBC databases). You need to be able tocreate and drop database tables in that database and your webserver must be able to execute <CODE>SELECT</CODE>, <CODE>INSERT</CODE>,<CODE>UPDATE</CODE> and <CODE>DELETE</CODE> statements on these tables.<P>Throughout this manual, we assume that you are using the MySQLdatabase server. PHPLIB will run with any supported SQL server,but we are using MySQL in the development of PHPLIB.<P>PHPLIB can be used in conjunction with the CGI version of PHP andwith <CODE>mod_php</CODE>, integrated into Apache. Usage of the CGIversion has an impact on overall speed, because you cannot takeadvantage of persistent database connection. We recommendthe Apache module over the CGI version, although we personallyuse the CGI version for various reasons (easier to update andcan be run with Apache <CODE>suexec</CODE>).<P>PHP 4 is still in beta. We do not support deployment of thislibrary with beta software.<P><H2><A NAME="ss1.3">1.3 Quick Guide to Installation</A></H2><P><P>These instructions apply to PHPLIB running with CGI PHP. Most ofthem are valid for mod_php as well, though. <EM>VERYIMPORTANT NOTE:</EM> This is a quick installation guide to getyou started if you have an installation where you control theweb server, PHP interpreter and database server completely. Theyare not suitable for a web hosting setup where you have onlylimited to no control over the installation. Refer to Chapter 2of this documentation for the complete installation instructionsand troubleshooting information.<P>Before installing PHPLIB, get your web server up and running andhave it executing files with the extension .php3. Check thatwith a simple <CODE>&lt;?php phpinfo() ?&gt;</CODE> script. Make surethe web server accepts <CODE>index.php3</CODE> as well as <CODE>index.html</CODE>as a default file for URLs ending in "/" (Apache:<CODE>DirectoryIndex index.html index.php3</CODE>).<P>Get your MySQL database server up an running. Create an emptydatabase for your application and make sure the owner of yourweb server processes can access this database with <CODE>SELECT</CODE>,<CODE>INSERT</CODE>, <CODE>UPDATE</CODE> and <CODE>DELETE</CODE> access. Don't forgetthe <CODE>mysqladmin reload</CODE> after changing the user and db tables.<P><DL><DT><B>Step 1</B><DD><P>Create an include directory named <CODE>php</CODE> parallel to yourweb servers document root directory. Do not put the includedirectory below your web servers document root.<P><DT><B>Step 2</B><DD><P>Unpack your PHPLIB distribution. Move the contents of the<CODE>php</CODE> distribution directory into the <CODE>php</CODE> directoryyou just created.<P><DT><B>Step 3</B><DD><P>Get to the <CODE>php3.ini</CODE> file for your web servers PHPinterpreter and update the <CODE>include_path</CODE> statement sothat it points to that <CODE>php</CODE> directory. Update the<CODE>auto_prepend_file</CODE> statement so that it points to the<CODE>prepend.php3</CODE> file in that include directory.<P>If you do not have control over your php3.ini file, you did notread the <EM>VERY IMPORTANT NOTE</EM> above.<P><DT><B>Step 4</B><DD><P>Also check that <CODE>track_vars</CODE> are enabled and that you haveenabled <CODE>magic_quotes_gpc</CODE>. While you are at it, you mightwant to check <CODE>sendmail_path</CODE>, if you plan to send mail fromyour application. It has to be set to <CODE>/usr/lib/sendmail -t</CODE>on most UNIX systems to work.<P>If you do not have control over your php3.ini file, you didnot read the <EM>VERY IMPORTANT NOTE</EM> above.<P><DT><B>Step 5</B><DD><P>cd into the <CODE>php</CODE> include directory. Edit <CODE>local.inc</CODE>.In <CODE>class DB_Example</CODE> supply the appropriate parameters foryour database connection.<P><DT><B>Step 6</B><DD><P>For this database, run <CODE>create_database.mysql</CODE> from thedistribution to create <CODE>active_sessions</CODE> and<CODE>auth_user</CODE>.  <CODE>auth_user</CODE> will be populated with asample user named <CODE>kris</CODE> with a password <CODE>test</CODE>.<P><DT><B>Step 7</B><DD><P>Move the contents of the <CODE>pages</CODE> directory and all itssubdirectories into your document root directory.<P><DT><B>Step 8</B><DD><P>Access the "/" URL of your web server with cookies enabled. Ifno <CODE>index.html</CODE> is present, <CODE>index.php3</CODE> will be displayed.If you reload that page, the number shown must increment.Access your database with the mysql command client and <CODE>select* from active_sessions</CODE>. Check that there is a single sessionrecord for your browser and see how the text in <CODE>val</CODE>changes when you reload the page and <CODE>select * fromactive_sessions</CODE> again. If this works, the session class isfunctional with cookie mode.<P><DT><B>Step 9</B><DD><P>Now access <CODE>showoff.php3</CODE>. Try to login as <CODE>kris</CODE>,password <CODE>test</CODE>. Check <CODE>active_sessions</CODE> again. You nowshould have a <CODE>Example_Session</CODE> entry (see the <CODE>name</CODE>column) and a <CODE>Example_User</CODE> entry in your table. Both shouldincrement on reload.<P><DT><B>Step 10</B><DD><P>Try again with cookies disabled. You should get a new session(the cookie is lost) and you should be able to see yoursession id as the get parameter part of your URL.</DL><P><H2><A NAME="ss1.4">1.4 Using core features of PHPLIB</A></H2><P>Many applications don't use PHPLIB's advanced features, butsee PHPLIB as a convenient way to protect pages orfunctionality with passwords. This section covers suchcore functionality usage of PHPLIB.<P><DL><DT><B>Customizing the login screen</B><DD><P>Edit <CODE>loginform.ihtml</CODE> in the include directory to suityour needs.<P><DT><B>Customizing the permission levels</B><DD><P>Edit <CODE>local.inc</CODE> and change the class <CODE>Example_Perm</CODE> toenumerate your permissions. Your users in <CODE>auth_user</CODE> musthave one or more comma separated permission names from thatlist. Edit <CODE>perminvalid.ihtml</CODE> for a suitable error message.<P><DT><B>Creating New Users</B><DD><P>Use <CODE>new_user.php3</CODE> from the <CODE>pages/admin</CODE> directoryof the distribution. If you followed the installationinstructions, it should be available under the<CODE>/admin</CODE> URL of your web server.<P>To manually create a user, run <CODE>print md5(uniqid("some magicstring")</CODE> to get a user id. <CODE>insert into auth_user values ("that userid", "username", "password", "permissions");</CODE>.<P><DT><B>Creating an unprotected session page</B><DD><P>Begin that page with <P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php page_open(array("sess" =&gt; "Example_Session")); ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P>End that page with <P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php page_close(); ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P><DT><B>Creating a protected session page</B><DD><P>Begin that page with<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php  page_open(    array("sess" =&gt; "Example_Session",          "auth" =&gt; "Example_Auth",          "perm" =&gt; "Example_Perm"));  $perm->check("desired protection");?&gt;</PRE><HR></CODE></BLOCKQUOTE><P>and end that page with<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php page_close(); ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P><DT><B>Creating protected functionality</B><DD><P>Begin that page with<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php  page_open(    array("sess" =&gt; "Example_Session",          "auth" =&gt; "Example_Auth",          "perm" =&gt; "Example_Perm"));?&gt;</PRE><HR></CODE></BLOCKQUOTE><P>and end that page with<P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php page_close(); ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P>Enclose the protected functionality in

⌨️ 快捷键说明

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