📄 documentation.txt
字号:
___________________________________________________________________ <?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); ?> ___________________________________________________________________ When executing properly, this page will show you the user entry for kris, password test, permissions admin from the auth_user table. If this does not happen, your DB_Example definition in local.inc is broken. CChheecckkiinngg tthhaatt sseessssiioonnss wwoorrkk Access the page /index.php3 that has been provided with the distribution. This page will try to set a cookie in your browser. Allow that cookie to be set. The page will display a headline with a counter. Reload that page. The counter must increment. If not, either your browser cannot deal properly with cookies or PHPLIB cannot properly read or write the table active_sessions in your database. Check that the cookie is being set by viewing the output of phpinfo() (the fourth table will report the cookie and other per-call data). Check your database permissions with your database command line interface. CChheecckkiinngg tthhaatt AAuutthheennttiiccaattiioonn wwoorrkkss Try loading /showoff.php3 that has been provided with the distribution. This page will require a login. Login as kris, using a password of test. If the login is successful, you will see the per-session counter and a per-user counter again. Reload that page: The counters must increment. 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 auth_user table. You must be able to SELECT on that table and there must be at an entry for the user you are trying to login. 22.. OOvveerrvviieeww aanndd IInnssttaallllaattiioonn The following sections discuss the installation, verification and layout of PHPLIB: How to install PHPLIB? Which functionality and class definitions are contained in which files? How do you layout a web server with PHPLIB installed? Which installation options are available and how do these affect performance? 22..11.. FFiilleess,, ccllaasssseess aanndd ffuunnccttiioonnss PHPLIB contains a set of core classes and functions that offer session tracking, per-session and per-user persistent variables, user authentication and permission checking. Building upon this core functionality, PHPLIB offers a set of commonly needed "background" classes and a set of "HTML widgets", classes that allow you to quickly generate HTML based user interfaces. All PHPLIB definitions are designed that you don't need to change any of these files. Your customization of PHPLIB can be contained in two or three files, depending on the setup: local.inc, setup.inc and, in some cases, prepend.php3. You _N_E_V_E_R need to change any other file with PHPLIB. Details are outlined below. 22..11..11.. CCuussttoommiizzaattiioonn The following three files are the only files from PHPLIB that require changes in normal PHPLIB applications. AApppplliiccaattiioonn ccoonnffiigguurraattiioonn iinn local.inc: Your application will almost certainly not work with the default values supplied by the above classes. You are supposed to extend the classes described below as you see fit. In your subclasses, you only have to specify what is different in your application. These are things like database host names, database names, table names and username/password combinations. You need to provide login screen definitions (HTML) and user validation functions (SQL) to make the example work. The distribution provides a local.inc to illustrate a typical setup. These definitions are also needed to get the administration and testing scripts provided with the distribution to run. The file is required and you must change it for your setup. AApppplliiccaattiioonn sseettuupp iinn setup.inc: The Session class provides the ability to execute initialization code at session setup. See the class description for instructions on how to set this up. Per convention, we store such code in setup.inc in the include directory. The code is being executed whenever a new user connection to out application and a new session is started. The file is optional. No default is provided. SSeelleeccttiioonn ooff aauuttoommaattiiccaallllyy llooaaddeedd ccllaasssseess iinn prepend.php3 The file prepend.php3 determines which code is being loaded for all PHP3 interpreted pages. Normally, we include the class definitions for all core classes in this file: db_mysql.inc, session.inc, auth.inc, perm.inc, user.inc, then your local customizations from local.inc and the page management functions from page.inc. You must change prepend.php3 to reflect the database interface that you are using: Change the require statement for db_mysql.inc appropriately. If you are not using some core features from PHPLIB in your application or if you want some other features to be present on all your pages, you can delete or add require statements for their respective include files here. The file is required. You must change it for your setup, unless you are using MySQL. 22..11..22.. CCoorree ffuunnccttiioonnaalliittyy The following files are included from prepend.php3 and provide definitions for the core classes of PHPLIB. We recommend that you always include all of them, as they are a tightly integrated set of classes with many dependencies among them. CCllaassss DB_Sql defined in exactly one of db_mysql.inc, db_msql.inc, db_pgsql.inc, db_odbc.inc, db_sybase.inc, db_mssql.inc, db_oracle.inc or db_oci8.inc:" A database access class for your database server. PHPLIB depends on the presence of a SQL database server. Depending on the type of your database server, you have to select the appropriate include file. The file contains the definition of a class DB_Sql suitable for your database server. The class manages a database connection (connection setup is implicit) and result memory is managed automatically. An independent class. CCllaassss Session defined in session.inc: Manages an arbitrary amount of arbitrarily named session variables of scalar, array and object types (Object support requires that you implement two instance variables in your classes). Tracks sessions via cookies or a get-variable appended to each URL. Depends on DB_Sql. CCllaassss Auth defined in auth.inc: Manages session authentication. Sessions are authenticated against usernames and passwords in a database. Authentication can be time limited. Depends on Session and DB_Sql. CCllaassss Perm defined in perm.inc: Manages permission checks on authenticated session pages. Protected pages are only accessible to users with the specified rights. Depends on Auth, Session and DB_Sql. CCllaassss User defined in user.inc: Manages user dependent variables. Unlike session variables these are bound to a user id, not to a session id. They are persistent over multiple sessions, but are only available after a user has been authenticated. Depends on Auth, Session and DB_Sql, extension of Session. ffuunnccttiioonnss page_open() and page_close() defined in page.inc:" Setup and Shutdown functions, must be present on any session page. Depend on Session. 22..11..33.. EExxtteennddeedd ffuunnccttiioonnaalliittyy The extended functionality classes offer GUI-less background features that are commonly needed in HTML-applications. They may make use of core functionality (indicated for each class below). Cart in cart.inc: Manages a simple shopping cart. Items can be put into the cart, taken out of the cart and the carts contents can be enumerated. Depends on Session to be useful. Requires that you add the statement require("cart.inc") to prepend.php3. Template in template.inc: Manages templates and variable replacement. Templates can be stored in files. They are loaded on demand and variables are replaced in these files. An independent class. Requires that you add the statement require("template.inc") to prepend.php3 or that you include it manually on each page where you want to use it. 22..11..44.. HHTTMMLL wwiiddggeettss HTML widgets are classes that generate some HTML-code (often forms or tables) to display GUI-elements. We try to provide functionality commonly used in applications, in a way that the actual look of the GUI-elements can be easily customized. CSV_Table in csv_table.inc: Creates a dump of a two dimensional array or a query result in CSV format, suitable for loading into a database or a spreadsheet program. Depends on Table, extension of Table. Sql_Query in sql_query.inc: Create a selection widget that allows a user to choose arbitrary conditions on one or more table columns. SQL is being created from these selections that can be used in the where-clause of a larger SQL select statement. Depends on Session and DB_Sql. Requires that you add the statement require("sqlquery.inc") to prepend.php3. Table in table.inc: Creates HTML tables from two dimensional arrays or from database query results. The class can either filter out the desired columns from an array or you can explicitly name which columns to show. A heading can be turned on if desired. All generated HTML elements are tagged with a classname you specify for stylesheet support, if needed. When used in a form tag, each table row can be prefixed with a checkbox input element to allow for row selection. An independent class. Form in oohforms.inc: Creates HTML forms from feature->value arrays. This provides a single syntax for creating all of the different types of form elements. The class provides easy access to Javascript and server side validation, and supports 'freezing' some or all of the form elements to display static data. In addition, the library relies on object oriented implementations for the various form elements and these can easily be extended and customized. An independent class. 22..22.. DDoowwnnllooaaddiinngg aanndd uunnppaacckkiinngg tthhee ddiissttrriibbuuttiioonn The base library is supplied at the PHP Base Library download location. Two different formats are provided: A tar.gz version and a shar version. If you are on a windows system, you can use phplib.tar.gz, if you have WinZIP installed. Current versions of WinZIP know how to handle compressed tar archives. The uncompressed files may be installed on your windows system or transferred to your Unix system. If you can't handle binary files, you may download phplib.shar. This is a pure ASCII file containing a self extracting shell script. Just save the file, make it executable and feed it to your Unix shell (for example, by typing sh phplib.shar). The PHPLIB support mailing list is available should you run into problems with the library. To subscribe send the command subscribe to the mailing list subscription address. 22..33.. RReeqquuiirreemmeennttss aanndd tthhiinnggss ttoo cchheecckk ffoorr 22..33..11.. IInntteerrpprreetteerr rreeqquuiirreemmeennttss The PHP base library requires a working web server with CGI capability and the CGI version of PHP 3.0.12 or higher installed. Alternatively mod_php can be used. Lower versions of PHP do not work at all: The session class uses the base64_encode() and base64_decode() functions which are known to be buggy in lower versions (up to 3.0.7) of the library. Also, the OOH Forms classes are using constructor syntax, which has been introduced into the PHP language in 3.0.5 and later versions. An issue with the $PHP_SELF variable and CGI PHP has been resolved with version 3.0.5 and later. Perl regular expression functions are being used in the Template class and these are not really avilable up to 3.0.12. _N_o_t_e_: If you are using CGI PHP, it _m_u_s_t have been compiled with the --enable-force-cgi-redirect switch for $PHP_SELF to have the correct value. 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -