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

📄 documentation-2.html

📁 PHPLOB注释详细版 使用模板技术的好帮手 PHP最有用的东东了
💻 HTML
📖 第 1 页 / 共 2 页
字号:
mSQL, Sybase, Microsoft SQL Server, ODBC and Oracle have limitedsupport (the limitation is only relevant if you intend to accessmetadata information, i.e. table definitions and the like).Database interfaces are not difficult to write and you caneasily write your own interface.<P>You need a database server connection with <CODE>select</CODE>,<CODE>insert</CODE>, <CODE>update</CODE> and <CODE>delete</CODE> privileges from yourCGI environment. You need <CODE>create</CODE> and <CODE>drop</CODE> privilegesfrom an administrative account outside your CGI environment aswell.<P>PHPLIB core functionality requires two tables as part of yourapplication table name space: <CODE>active_sessions</CODE> (select,insert, update and delete privilege required for the applicationuser) and <CODE>auth_user</CODE> (select privilege required for theapplication user. insert, update and delete privilege requiredfor the application user if user management is to be done fromwithin the application).<P>Extended functionality may require additional tables.<P><H3>Name space requirements</H3><P><P>PHPLIB tries to be as name space neutral as possible with itscore features. Is issues no HTML by default and it occupies onlyfew names in the global name space. These are the class namesfor the classes defined: <CODE>DB_Sql</CODE>, <CODE>DB_SAM</CODE>,<CODE>CT_Sql</CODE>, <CODE>Session</CODE>, <CODE>Auth</CODE>, <CODE>Perm</CODE>,<CODE>User</CODE>. Additionally, the classnames <CODE>DB_Example</CODE>,<CODE>Example_CT_Sql</CODE>, <CODE>Example_Session</CODE>,<CODE>Example_Auth</CODE>,<CODE>Example_Challenge_Auth</CODE>,<CODE>Example_Perm</CODE> and <CODE>Example_User</CODE> aredefined by the sample setup in <CODE>local.inc</CODE>, but these namescan and shall be customized by the application developer. PHPLIBdefines the function names <CODE>page_open()</CODE>,<CODE>page_close</CODE>, <CODE>sess_load()</CODE> and<CODE>sess_save()</CODE> for the page management functions. Theglobal variable $_PHPLIB (a hash) is taken. Only if<CODE>page_open()</CODE> is being used, globals are defined bythe library by default, but one global for each "feature"requested in the <CODE>page_open()</CODE> statement is taken.These are at most <CODE>$sess</CODE>, <CODE>$user</CODE>, <CODE>$auth</CODE> and<CODE>$perm</CODE>.<P>Including extension functionality or HTML widgets may occupyadditional classnames, function names or variables in the globalname space.<P><H3>Year 2000 compliance statement</H3><P><P>PHPLIB uses date fields within the column <CODE>changed</CODE> in thetable <CODE>active_sessions</CODE> in your database.  The<CODE>changed</CODE> field is used in garbage collection, that is, toclean out abandoned sessions. The date field is a 14 characterfield of the format <CODE>YYYYMMDDhhmmss</CODE>, that is, the date fieldhas four digit years and will cope properly with the newmillennium.<P>PHPLIB sets cookies in the client browser. These cookies bydefault have session lifetime, that is, they do not expire butare not written to disk. Date calculations are not involved.<P>It is possible to have PHPLIB set cookies with a limitedlifetime by defining the $lifetime slot of the Session class.If this is done, it depends on the date handling of the clientbrowser and client operating system, if the result is Y2Kcompliant. There are known issues with longterm cookies and anybrowser on MS-DOS/Windows 3.11 systems.<P>PHPLIB does some date arithmetic internally that involvesmktime() and date() functions of the PHP3 language and Unixtime_t data types. The signed 32 bit Unix time_tdata type counts seconds since 01-Jan-1970 Midnight GMT and willoverflow sometime in the year 2038.<P>PHPLIB itself will function up to 2038 and longer, if the Unixtime_t is being extended in time. PHPLIB does not protectyou from date and Y2K issues in your PHPLIB application, thePHP3 interpreter, the server operating system oder serversoftware, the client browser, the client operating system orother parts of your installation.<P><H2><A NAME="ss2.4">2.4 Installation procedure </A></H2><P><CODE>mod_php</CODE> note: The following instructions applyto the CGI version of PHP as well as to the module version. Ifyou are working with <CODE>mod_php</CODE>, you must restart yourweb server to force a reload of the <CODE>php3.ini</CODE> file, though.<P>If you are using <CODE>mod_php</CODE>, you have additionalconfiguration options: See the section below on using PHPLIBmit <CODE>mod_php</CODE>.<P><DL><P><DT><B>Library Setup</B><DD><P>Create a directory php next to your cgi:<P><BLOCKQUOTE><CODE><HR><PRE>/home/www/servers/phplib.netuse.de/pages   &lt;- document root                                   cgi     &lt;- php binary                                   php     &lt;- includes and prepends</PRE><HR></CODE></BLOCKQUOTE><P>Make this php directory your php include directory: Put <CODE>include_path = /home/www/servers/phplib.netuse.de/php</CODE>into <CODE>cgi/php3.ini</CODE>. If you already have an include pathdefined in your setup, add the PHPLIB include path to theexisting include path using the separator character applicablefor your operating system (":" on UNIX, ";" on Windows).Defining an include path will not actually include code on yourpages; it only tells the PHP interpreter in which directories tolook for files referenced in <CODE>require()</CODE> and <CODE>include()</CODE>statements.<P>Into the <CODE>php</CODE> directory go all the files from the <CODE>php</CODE>directory of the distribution. Into documentroot, put all thefiles and directories from the <CODE>pages</CODE> directory of thedistribution.<P>Have <CODE>documentation.txt</CODE> handy and read it.<P><DT><B>Database access with MySQL</B><DD><P>The following information applies to MySQL only. No informationis provided for other database servers as of now. You areencouraged to copy this section, adapt it for your databaseserver and submit it to the authors. It will be included infurther releases of PHPLIB.<P>Edit <CODE>prepend.php3</CODE>. Change the first <CODE>require()</CODE>statement to <CODE>require("db_mysql.inc");</CODE>. This willinclude the MySQL database interface (Interfaces for otherdatabases are provided in<CODE>db_&lt;databasename&gt;.inc</CODE>. The <CODE>require()</CODE>statement has to be adapted to reflect this).<P>Assuming your database server is named <CODE>database.netuse.de</CODE>and your CGI user is <CODE>webuser</CODE> and you are accessing thedatabase <CODE>myapp</CODE>, do<P><BLOCKQUOTE><CODE><HR><PRE>mysql -h database -u webuser myapp</PRE><HR></CODE></BLOCKQUOTE><P>If it does not work, connect your database as administrator andcreate the proper mysql access permissions. Adapt and run<CODE>create_database.mysql</CODE> from the <CODE>stuff</CODE>subdirectory of the distribution to create the databases<CODE>active_sessions</CODE> and <CODE>auth_user</CODE> as well asthe sample user <CODE>kris</CODE> with password <CODE>test</CODE>. Try again toconnect like shown above. Can you do <CODE>select * fromactive_sessions</CODE>? and <CODE>insert intoactive_sessions values ("1", "2", "3", "")</CODE> as well as<CODE>delete from active_sessions</CODE>? Can you <CODE>select *from auth_user</CODE>?<P><EM>Note:</EM> Additional database creation scripts are provided forseveral different databases in the <CODE>stuff</CODE> directory of thedistribution.<P><DT><B>Merging the library with your PHP files</B><DD><P>Decide if you want to use <CODE>include</CODE> or<CODE>auto_prepend_file</CODE>. We do use<CODE>auto_prepend_file</CODE>here and we add the statement<CODE>auto_prepend_file =/home/www/servers/phplib.netuse.de/php/prepend.php3</CODE> to our<CODE>php3.ini</CODE>.<P>Not all classes are included/required by <CODE>prepend.php3</CODE>, onlycore functionality files are: <CODE>db_xxx.inc</CODE>,<CODE>ct_sql.inc</CODE>, <CODE>session.inc</CODE>,<CODE>auth.inc</CODE>, <CODE>perm.inc</CODE>, <CODE>user.inc</CODE>, <CODE>local.inc</CODE> and<CODE>page.inc</CODE>. The library provides other, less essentialclasses that can be included manually on a page-by-page basis.Some classes make themselves persistent, if used. These classesrequire that you include their definitions in the<CODE>prepend.php3</CODE> file where indicated to function correctly.See the usage instructions for these classes for details.<P>Having done this, access <CODE>/index.php3</CODE>. The countershould increment when that page is being reloaded. Also, checking<CODE>active_sessions</CODE> in the database should reflect thatsession.<P><DT><B>Subscribe for support</B><DD><P>Subscribe to the mailing list <A HREF="mailto:phplib@lists.netuse.de">phplib@lists.netuse.de</A>. Do so by sending a mail body of <CODE>subscribe</CODE>to <A HREF="mailto:phplib-request@lists.netuse.de">phplib-request@lists.netuse.de</A> and follow instructions. Share yourexperiences.</DL><P><H2><A NAME="ss2.5">2.5 Using <CODE>include()</CODE> instead of <CODE>auto_prepend_file=</CODE></A></H2><P>If you do not want to use <CODE>auto_prepend_file</CODE> to load thePHPLIB core functionality, you can load the class definitionsfor the core manually on each page that requires them.<P>You will have to define a valid<CODE>include_path=</CODE>-statement in your <CODE>php3.ini</CODE> fileas outlined previously to reflect the location of the <CODE>*.inc</CODE>files. Then, all core functionality can be loaded with<CODE>include("prepend.php3")</CODE> as the first statement at the topof each page.<P>To further optimize performance, you can minimize the contentsof the prepend file, if you do not need all core functionality.You <EM>may</EM> leave out <CODE>auth.inc</CODE>, <CODE>perm.inc</CODE> and<CODE>user.inc</CODE>, if you do not require these features (note thatthere are dependencies among these classes!).<P><H2><A NAME="ss2.6">2.6 PHPLIB with mod_php (Apache module)</A></H2><P><P>Installing PHPLIB onto a web server that has PHP3 as a module(actually Apache) mainly differs in where you can set up runtimesettings for PHP3 itself.  PHP3 can be compiled with a wealth ofparameters (see the PHP section in <CODE>phpinfo()</CODE>), most of which canget overridden by the <CODE>php3.ini</CODE> file. The location of thisfile is shows as part of the output of <CODE>phpinfo()</CODE>.<P>With PHP3 as a module you have a wider choice on placing thesesettings: they are overridden, in this order, by what is definedin <CODE>httpd.conf</CODE> and in your per-directory <CODE>.htaccess</CODE>file. Directives in these files are identical to their<CODE>php3.ini</CODE> brothers, but are prefixed with <CODE>php_</CODE>to avoid clashes with Apache configuration keywords. Also, asthey are Apache configuration keywords, they have no equals("=") sign in them. If <CODE>x=y</CODE> is a configuration directivefrom <CODE>php3.ini</CODE>, you should be using <CODE>php3_x y</CODE>within the Apache configuration instead. That is, you shouldprepend <CODE>php3_</CODE> to the keyword and omit the equalssign. If you misspell a configuration directive, you will get anerror 500 from your webserver and find more details about theerror in the logfile you configured with <CODE>ErrorLog</CODE> in yourwebserver setup.<P><EM>Example:</EM> If below we talk about setting in your<CODE>php3.ini</CODE> the configuration<P><BLOCKQUOTE><CODE><HR><PRE>include_path = "/bla"</PRE><HR></CODE></BLOCKQUOTE><P><CODE>mod_php</CODE> users may alternatively configure in their<CODE>httpd.conf</CODE> the following:<P><BLOCKQUOTE><CODE><HR><PRE>&lt;Directory /home/www/servers/phplib.netuse.de/pages&gt;php3_include_path "/bla"&lt;/Directory&gt;</PRE><HR></CODE></BLOCKQUOTE><P>Of special interest to PHPLIB users are the followingdirectives:<P><BLOCKQUOTE><CODE><HR><PRE>;;;;;;;;;;;;;;;;;; Data Handling ;;;;;;;;;;;;;;;;;;magic_quotes_gpc = Off    ; magic quotes for incoming                           ; GET/POST/Cookie datamagic_quotes_runtime = Off; magic quotes for runtime-generated data,                          ; e.g. data from SQL, from exec(), etc.magic_quotes_sybase = Off ; Use Sybase-style magic quotes                           ; (escape ' with '' instead of \')track_vars = On           ; enable $PHP_GET_VARS[], $PHP_POST_VARS[]                           ; and $PHP_COOKIE_VARS[] arrays; automatically add files before or after any PHP 3.0 documentauto_prepend_file = (add path to prepend.php3 here)auto_append_file  =;;;;;;;;;;;;;;;;;;;;;;;;;; Paths and Directories ;;;;;;;;;;;;;;;;;;;;;;;;;;include_path      = (add path to the directory with all .inc files)</PRE><HR></CODE></BLOCKQUOTE><P>All of this comes very handy when you have multiple virtualhosts (e.g. you are an ISP). In this case you can comfortablyplace the php3 directives in the <CODE>&lt;VirtualHost&gt;</CODE> blockor in an <CODE>.htaccess</CODE> file in the client directory.<P><P><HR><A HREF="documentation-3.html">Next</A><A HREF="documentation-1.html">Previous</A><A HREF="documentation.html#toc2">Contents</A></BODY></HTML>

⌨️ 快捷键说明

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