📄 documentation-2.html
字号:
<!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: Overview and Installation</TITLE> <LINK HREF="documentation-3.html" REL=next> <LINK HREF="documentation-1.html" REL=previous> <LINK HREF="documentation.html#toc2" REL=contents></HEAD><BODY><A HREF="documentation-3.html">Next</A><A HREF="documentation-1.html">Previous</A><A HREF="documentation.html#toc2">Contents</A><HR><H2><A NAME="s2">2. Overview and Installation</A></H2><P><P>The following sections discuss the installation, verificationand layout of PHPLIB: How to install PHPLIB? Which functionalityand class definitions are contained in which files? How do youlayout a web server with PHPLIB installed? Which installationoptions are available and how do these affect performance?<P><H2><A NAME="ss2.1">2.1 Files, classes and functions</A></H2><P><P>PHPLIB contains a set of core classes and functions that offersession tracking, per-session and per-user persistent variables,user authentication and permission checking. Building upon thiscore functionality, PHPLIB offers a set of commonly needed"background" classes and a set of "HTML widgets", classes thatallow you to quickly generate HTML based user interfaces.<P>All PHPLIB definitions are designed that you don't need tochange any of these files. Your customization of PHPLIB can becontained in two or three files, depending on the setup:<CODE>local.inc</CODE>, <CODE>setup.inc</CODE> and, in some cases,<CODE>prepend.php3</CODE>. You <EM>NEVER</EM> need to change any other filewith PHPLIB. Details are outlined below.<P><H3>Customization</H3><P>The following three files are the only files from PHPLIB thatrequire changes in normal PHPLIB applications. <P><DL><DT><B>Application configuration in <CODE>local.inc</CODE>:</B><DD><P>Your application will almost certainly not work with thedefault values supplied by the above classes. You are supposedto extend the classes described below as you see fit.<P><P>In your subclasses, you only have to specify what is differentin your application. These are things like database host names,database names, table names and username/passwordcombinations. You need to provide login screen definitions(HTML) and user validation functions (SQL) to make theexample work.<P><P>The distribution provides a <CODE>local.inc</CODE> to illustratea typical setup. These definitions are also needed to getthe administration and testing scripts provided with thedistribution to run.<P><P>The file is required and you must change it for your setup.<P><DT><B>Application setup in <CODE>setup.inc</CODE>:</B><DD><P>The <CODE>Session</CODE> class provides the ability to executeinitialization code at session setup. See the classdescription for instructions on how to set this up.<P>Per convention, we store such code in <CODE>setup.inc</CODE>in the include directory. The code is being executedwhenever a new user connection to out application anda new session is started.<P><P>The file is optional. No default is provided.<P><DT><B>Selection of automatically loaded classes in <CODE>prepend.php3</CODE></B><DD><P>The file <CODE>prepend.php3</CODE> determines which code is beingloaded for all PHP3 interpreted pages. Normally, we includethe class definitions for all core classes in this file:<CODE>db_mysql.inc</CODE>, <CODE>session.inc</CODE>, <CODE>auth.inc</CODE>,<CODE>perm.inc</CODE>, <CODE>user.inc</CODE>, then your local customizationsfrom <CODE>local.inc</CODE> and the page management functions from<CODE>page.inc</CODE>.<P>You must change <CODE>prepend.php3</CODE> to reflect the databaseinterface that you are using: Change the <CODE>require</CODE>statement for <CODE>db_mysql.inc</CODE> appropriately.<P>If you are not using some core features from PHPLIB in yourapplication or if you want some other features to be presenton all your pages, you can delete or add <CODE>require</CODE>statements for their respective include files here.<P><P>The file is required. You must change it for your setup,unless you are using MySQL.</DL><P><H3>Core functionality</H3><P><P>The following files are included from <CODE>prepend.php3</CODE> andprovide definitions for the core classes of PHPLIB. We recommendthat you always include all of them, as they are a tightlyintegrated set of classes with many dependencies among them.<P><DL><DT><B>Class <CODE>DB_Sql</CODE> defined in exactly one of<CODE>db_mysql.inc</CODE>, <CODE>db_msql.inc</CODE>, <CODE>db_pgsql.inc</CODE>, <CODE>db_odbc.inc</CODE>, <CODE>db_sybase.inc</CODE>, <CODE>db_mssql.inc</CODE>,<CODE>db_oracle.inc</CODE> or <CODE>db_oci8.inc</CODE>:</B><DD><P><P>A database access class for your database server. PHPLIBdepends on the presence of a SQL database server. Dependingon the type of your database server, you have to select theappropriate include file. The file contains the definition ofa class <CODE>DB_Sql</CODE> suitable for your database server.<P><P>The class manages a database connection (connection setup isimplicit) and result memory is managed automatically.<P><P>An independent class.<P><DT><B>Class <CODE>Session</CODE> defined in <CODE>session.inc</CODE>:</B><DD><P>Manages an arbitrary amount of arbitrarily named sessionvariables of scalar, array and object types (Object supportrequires that you implement two instance variables in yourclasses). Tracks sessions via cookies or a <CODE>get</CODE>-variableappended to each URL.<P><P>Depends on <CODE>DB_Sql</CODE>.<P><DT><B>Class <CODE>Auth</CODE> defined in <CODE>auth.inc</CODE>:</B><DD><P>Manages session authentication. Sessions are authenticatedagainst usernames and passwords in a database. Authenticationcan be time limited.<P><P>Depends on <CODE>Session</CODE> and <CODE>DB_Sql</CODE>.<P><DT><B>Class <CODE>Perm</CODE> defined in <CODE>perm.inc</CODE>:</B><DD><P>Manages permission checks on authenticated session pages.Protected pages are only accessible to users with thespecified rights.<P><P>Depends on <CODE>Auth</CODE>, <CODE>Session</CODE> and <CODE>DB_Sql</CODE>.<P><DT><B>Class <CODE>User</CODE> defined in <CODE>user.inc</CODE>:</B><DD><P>Manages user dependent variables. Unlike session variablesthese are bound to a user id, not to a session id. They arepersistent over multiple sessions, but are only availableafter a user has been authenticated.<P><P>Depends on <CODE>Auth</CODE>, <CODE>Session</CODE> and <CODE>DB_Sql</CODE>,extension of <CODE>Session</CODE>.<P><DT><B>functions <CODE>page_open()</CODE> and <CODE>page_close()</CODE>defined in <CODE>page.inc</CODE>:</B><DD><P>Setup and Shutdown functions, must be present on any session page.<P><P>Depend on <CODE>Session</CODE>.</DL><P><H3>Extended functionality</H3><P><P>The extended functionality classes offer GUI-less backgroundfeatures that are commonly needed in HTML-applications. Theymay make use of core functionality (indicated for each classbelow).<P><DL><P><DT><B><CODE>Cart</CODE> in <CODE>cart.inc</CODE>:</B><DD><P>Manages a simple shopping cart. Items can be put into thecart, taken out of the cart and the carts contents can beenumerated.<P><P>Depends on <CODE>Session</CODE> to be useful. Requires that you add thestatement <CODE>require("cart.inc")</CODE> to <CODE>prepend.php3</CODE>.<P><DT><B><CODE>Template</CODE> in <CODE>template.inc</CODE>:</B><DD><P>Manages templates and variable replacement. Templates can bestored in files. They are loaded on demand and variables arereplaced in these files.<P><P>An independent class. Requires that you add the statement<CODE>require("template.inc")</CODE> to <CODE>prepend.php3</CODE> or thatyou include it manually on each page where you want to use it.</DL><P><H3>HTML widgets</H3><P><P>HTML widgets are classes that generate some HTML-code (oftenforms or tables) to display GUI-elements. We try to providefunctionality commonly used in applications, in a way that theactual look of the GUI-elements can be easily customized.<P><DL><DT><B><CODE>CSV_Table</CODE> in <CODE>csv_table.inc</CODE>:</B><DD><P>Creates a dump of a two dimensional array or a query resultin CSV format, suitable for loading into a database or aspreadsheet program.<P><P>Depends on <CODE>Table</CODE>, extension of <CODE>Table</CODE>.<P><DT><B><CODE>Sql_Query</CODE> in <CODE>sql_query.inc</CODE>:</B><DD><P>Create a selection widget that allows a user to choosearbitrary conditions on one or more table columns. SQL isbeing created from these selections that can be used in thewhere-clause of a larger SQL select statement.<P><P>Depends on <CODE>Session</CODE> and <CODE>DB_Sql</CODE>. Requires thatyou add the statement <CODE>require("sqlquery.inc")</CODE> to<CODE>prepend.php3</CODE>.<P><DT><B><CODE>Table</CODE> in <CODE>table.inc</CODE>:</B><DD><P>Creates HTML tables from two dimensional arrays or fromdatabase query results. The class can either filter out thedesired columns from an array or you can explicitly namewhich columns to show. A heading can be turned on if desired.All generated HTML elements are tagged with a classnameyou specify for stylesheet support, if needed. When used in aform tag, each table row can be prefixed with a checkboxinput element to allow for row selection.<P><P>An independent class.<P><DT><B><CODE>Form</CODE> in <CODE>oohforms.inc</CODE>:</B><DD><P>Creates HTML forms from feature->value arrays. This provides asingle syntax for creating all of the different types of formelements. The class provides easy access to Javascript and serverside validation, and supports 'freezing' some or all of the formelements to display static data. In addition, the library relies onobject oriented implementations for the various form elements andthese can easily be extended and customized.<P><P>An independent class.</DL><P><H2><A NAME="ss2.2">2.2 Downloading and unpacking the distribution</A></H2><P>The base library is supplied at <A HREF="http://phplib.netuse.de/">the PHP Base Library download location</A>. Two different formats are provided: Atar.gz version and a shar version.<P>If you are on a windows system, you can use phplib.tar.gz, ifyou have WinZIP installed. Current versions of WinZIP know howto handle compressed tar archives. The uncompressed files may beinstalled on your windows system or transferred to your Unixsystem.<P>If you can't handle binary files, you may download phplib.shar.This is a pure ASCII file containing a self extracting shellscript. Just save the file, make it executable and feed it toyour Unix shell (for example, by typing <CODE>sh phplib.shar</CODE>).<P>The <A HREF="mailto:phplib@lists.netuse.de">PHPLIB support mailing list</A> is available should you run into problemswith the library. To subscribe send the command <CODE>subscribe</CODE>to <A HREF="mailto:phplib-request@lists.netuse.de">the mailing list subscription address</A>.<P><H2><A NAME="ss2.3">2.3 Requirements and things to check for</A></H2><H3>Interpreter requirements</H3><P><P>The PHP base library requires a working web server with CGIcapability and the CGI version of PHP 3.0.12 or higherinstalled. Alternatively mod_php can be used. Lowerversions of PHP do not work at all: The session class uses the<CODE>base64_encode()</CODE> and <CODE>base64_decode()</CODE>functions which are known to be buggy in lower versions (up to3.0.7) of the library. Also, the OOH Forms classes are usingconstructor syntax, which has been introduced into the PHPlanguage in 3.0.5 and later versions. An issue with the$PHP_SELF variable and CGI PHP has been resolved withversion 3.0.5 and later. Perl regular expression functions arebeing used in the <CODE>Template</CODE> class and these are not reallyavilable up to 3.0.12.<P><EM>Note:</EM> If you are using CGI PHP, it <EM>must</EM> have beencompiled with the <CODE>--enable-force-cgi-redirect</CODE> switch for$PHP_SELF to have the correct value.<P>Basically, if PHP_SELF is the exact local part of your$URL, all is well. If it instead contains the modified URL with/your cgi-bin/php prefixed, you have a buggy version of CGI PHP.Either upgrade your version of PHP or replace all occurrences of$PHP_SELF with $PATH_INFO in PHPLIB.<P><EM>Note:</EM> PHPLIB requires that you have <CODE>track_vars</CODE>compiled in and enabled.<P><EM>Note:</EM> PHPLIB does not require<CODE>short_open_tag</CODE> to be enabled. The libraryalways uses <CODE><?php</CODE> as the PHP command introducer.<P><EM>Note:</EM> PHPLIB does not require<CODE>magic_quotes_gpc</CODE> to be enabled. The libraryalways uses <CODE>addslashes()</CODE> when necessary.<P><H3>Database requirements </H3><P>The PHP base library requires a database connection in thedefault setup for storage of session variables, but this can becircumvented by selection another storage container type atinstallation time. Currently, storage containers are availablefor SQL databases (the default), SQL databases with limitedstring length (ct_split_sql.inc), System V sharedmemory (requires a PHP interpreter with SYSVSHM and SYSVSEMsupport), LDAP servers (requires a PHP interpreter with LDAPsupport), flat files, and DBM files.<P>Using SQL, currently MySQL is fully supported and PostgreSQL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -