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

📄 documentation-3.html

📁 PHPLOB注释详细版 使用模板技术的好帮手 PHP最有用的东东了
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<P><H2><A NAME="ss3.2">3.2 Page Management</A></H2><P><P><H3>Accessible Functions</H3><P><P>Page Management currently consists a collection of functions:<P><DL><DT><B>page_open(array("feature" => "classname"))</B><DD><P>This function is to be called with an array of pagefeatures/classname pairs. Valid features are at the moment:<P><DL><DT><B>sess</B><DD><P>This page makes use of session variables.<P><DT><B>auth</B><DD><P>This page uses session authentication. If youspecify the <CODE>auth</CODE> feature, you MUST specifythe <CODE>sess</CODE> feature, also.<P><DT><B>perm</B><DD><P>This page is protected by permissions and onlyaccessible to authenticated users with matching rights.If you specify the <CODE>perm</CODE> feature, you MUST specifythe <CODE>auth</CODE> and <CODE>sess</CODE> features, also.<P><DT><B>user</B><DD><P>This page makes use of user variables. If you specifythe <CODE>user</CODE> feature, you MUST specify the <CODE>auth</CODE> and<CODE>sess</CODE> features, also.</DL><P>Each feature specifies the name of the class that implements that feature,for example<P><HR><PRE>  page_open(array("sess" =&gt; "Shop_Session"));</PRE><HR><P>The function creates an instance of <CODE>Shop_Session</CODE> as<CODE>$sess</CODE> and initializes it. It also checks featuredependencies. Note that you are expected to provide animplementation of the class <CODE>Shop_Session</CODE>. This isusually done in <CODE>local.inc</CODE> and usually you do so byextending the provided <CODE>Session</CODE> class.<P>Examples on how to do this is given in the documentation belowwhen the classes are introduced.<P><DT><B>page_close()</B><DD><P><P>At the end of your page (after all results have been calculated)you have to call <CODE>page_close()</CODE>. This will save allpage state, session and user variables into database. Changes tosession or user variables after <CODE>page_close()</CODE> hasbeen called are not recorded. Currently it is allowed to call<CODE>page_close()</CODE> multiple times on a single page (notguaranteed for future versions!). Each time session state will besaved.<P><EM>Note:</EM> This is going to change. When we introduce recordlocking, it is important that you call <CODE>page_close()</CODE> onlyonce per page, because that will implicitly unlock your sessionrecord. Also, it is important that you call <CODE>page_close()</CODE> asearly as possible on a page so that the locking time is keptminimal.<P><DT><B>sess_load(array("var" => "classname")</B><DD><P> <P><EM>Advanced feature</EM>. Some applications have need to manuallyload data belonging to one or multiple session classes. @@TODO<P><DT><B>sess_save(array("var" => "classname"))</B><DD><P><EM>Advanced feature</EM>. @@TODO<P></DL><P><H3>Example</H3><P><P><BLOCKQUOTE><CODE><HR><PRE>&lt;?php  page_open(array("sess" =&gt; "Shop_Session"));  $sess-&gt;register("s");  // See "Session" below for explanation. ?&gt;&lt;html&gt;&lt;h1&gt;&lt;?php print ++$s ?&gt;&lt;/h1&gt;&lt;/html&gt;&lt;?php page_close(); ?&gt;</PRE><HR></CODE></BLOCKQUOTE><P><H3>The "cart" feature is gone</H3><P> There used to be a feature "cart" for <CODE>page_open()</CODE> inversions of PHPLIB up to release-5. The cart has been removedfrom the core functionality of PHPLIB to keep the library small,maintainable and structured. Consequently the "cart" feature isgone.<P>The <CODE>Cart</CODE> class is still present and exists as an extendedfeature. You have to include and instantiate your cart manuallyon that pages that use it, though. See the <CODE>Cart</CODE> class formore information.<P><P><H2><A NAME="ss3.3">3.3 CT_Sql</A></H2><P><P>The <CODE>Session</CODE> class used to contain a bit of SQL to readand write session data from and to a database. To make sessionsdatabase independent, this SQL has been isolated and put ina separate class, <CODE>CT_Sql</CODE>. <CODE>Session</CODE> now makesall storage accesses through a container class, which may ormay not be an SQL container.<P><H3>Instance variables</H3><P><P><CENTER><TABLE BORDER><TR><TD><BR>database_table</TD><TD>The name of the database table which should be used</TD></TR><TR><TD>database_class</TD><TD>A classname. CT_Sql uses this class to store and retrieve data</TD></TR><TR><TD><CAPTION>Accessible instance variables.</CAPTION></TD></TR></TABLE></CENTER><P><H3>Example</H3><P><P>Use a subclass to provide the appropriate parameters to your container. Usually your subclass looks like this: <P><BLOCKQUOTE><CODE><HR><PRE>class My_Sql extends CT_Sql {        var $classname = "My_Sql";        var $database_table = "active_sessions";        var $database_class = "DB_Session";}</PRE><HR></CODE></BLOCKQUOTE><P>You can then use My_Sql in class Session. Reference itby putting "My_Sql" in the "that_class" variable.<P><P><H2><A NAME="ss3.4">3.4 CT_Split_Sql</A></H2><P><P>The <CODE>Session</CODE> class used to contain a bit of SQL to read andwrite session data from and to a database. To make sessionsdatabase independent, <CODE>Session</CODE> now makes all storageaccesses through a container class. The<CODE>CT_split_sql</CODE> container is very similar to<CODE>CT_Sql</CODE> container, with the difference that ifserialized data exceeds a specified amount of bytes, multiplerows will be used to memorized the entire field.<P>This class is NOT compatible with <CODE>CT_Sql</CODE> class, sincetable layout is different and column names are different in order toavoid reserved words in various database implementation. This uses a<CODE>DB_Sql</CODE> like class so you can access all supported databaseswith this container.<P><H3>Instance variables</H3><P><P><CENTER><TABLE BORDER><TR><TD><BR>database_table</TD><TD>The name of the database table which should be used</TD></TR><TR><TD>database_class</TD><TD>A classname. CT_Sql uses this class to store and retrieve data</TD></TR><TR><TD>split_length</TD><TD>A number. This specifies the maximum amount of bytessaved in each row of the table.<CAPTION>Accessible instance variables.</CAPTION></TD></TR></TABLE></CENTER><P><H3>Example</H3><P><P>Use a subclass to provide the appropriate parameters to your container. Usually your subclass looks like this: <P><BLOCKQUOTE><CODE><HR><PRE>class My_Sql extends CT_Split_Sql {        var $classname = "My_Sql";        var $database_table = "active_sessions_split";        var $database_class = "DB_Session";        var $split_length = 4096;}</PRE><HR></CODE></BLOCKQUOTE><P>You can then use My_Sql in class Session. Reference itby putting "My_Sql" in the "that_class" variable.<P><P><H2><A NAME="ss3.5">3.5 CT_Shm</A></H2><P><P>The <CODE>Session</CODE> class used to contain a bit of SQL to read andwrite session data from and to a database. To make sessionsdatabase independent, <CODE>Session</CODE> now makes all storageaccesses through a container class. To let <CODE>Session</CODE> use sharedmemory as container, you use <CODE>CT_Shm</CODE>.<P><H3>Instance variables</H3><P><P><CENTER><TABLE BORDER><TR><TD><BR>max_sessions</TD><TD>The maximum number of concurrent sessions supported by this container.</TD></TR><TR><TD>shm_key</TD><TD>The unique (important!) key of the shared memory&nbsp;segment you want to use.</TD></TR><TR><TD>shm_size</TD><TD>The size of the shared memory segment. The size is&nbsp;set, when the segment is accessed for the first time. If you do not use &nbsp;too many session variables, the formula shm_size = max_sessions * 600&nbsp;should be sufficient.</TD></TR><TR><TD><CAPTION>Accessible instance variables.</CAPTION></TD></TR></TABLE></CENTER><P><H3>Example</H3><P><P>Use a subclass to provide the appropriate parameters to your container. Usually your subclass looks like this: <P><BLOCKQUOTE><CODE><HR><PRE>class My_Shm extends CT_Shm {        var $classname = "My_Shm";        var $max_sessions = 500;        var $shm_key = 0x1234232;        var $shm_size = 64000;}</PRE><HR></CODE></BLOCKQUOTE><P>You can then use My_Shm in class Session. Reference itby putting "My_Shm" in the "that_class" variable.<P><P><H2><A NAME="ss3.6">3.6 CT_Dbm</A></H2><P><P>The <CODE>Session</CODE> class used to contain a bit of SQL to read andwrite session data from and to a database. To make sessionsdatabase independent, <CODE>Session</CODE> now makes all storageaccesses through a container class. To let <CODE>Session</CODE> use a DBMdatabase file as a container, you use <CODE>CT_Dbm</CODE>.<P><H3>Instance variables</H3><P><P><CENTER><TABLE BORDER><TR><TD><BR>dbm_file</TD><TD>The path to the dbm file (must exist already AND must be writable by the server process)</TD></TR><TR><TD><CAPTION>Accessible instance variables.</CAPTION></TD></TR></TABLE></CENTER><P><H3>Example</H3><P><P>Use a subclass to provide the appropriate parameters to your container. Usually your subclass looks like this: <P><BLOCKQUOTE><CODE><HR><PRE>class My_Dbm extends CT_Dbm {        var $dbm_file = "data/session.dbm";}</PRE><HR></CODE></BLOCKQUOTE><P>You can then use My_Dbm in class Session. Reference itby putting "My_Dbm" in the "that_class" variable.<P><P><H2><A NAME="ss3.7">3.7 CT_Ldap</A></H2><P><P>The <CODE>Session</CODE> class used to contain a bit of SQL to read andwrite session data from and to a database. To make sessionsdatabase independent, <CODE>Session</CODE> now makes all storageaccesses through a container class. To let <CODE>Session</CODE> use aLDAP database as a container, you use <CODE>CT_Ldap</CODE>.<P><H3>Instance variables</H3><P><P><CENTER><TABLE BORDER><TR><TD><BR>ldap_host</TD><TD>This is the hostname of the LDAP server to connect to</TD></TR><TR><TD>ldap_port</TD><TD>And this is its port (LDAP default is 389)</TD></TR><TR><TD>basedn</TD><TD>This is the basedn</TD></TR><TR><TD>rootdn</TD><TD>This is the rootdn which is required to modify the database</TD></TR><TR><TD>rootpw</TD><TD>The respective password for rootdn</TD></TR><TR><TD>objclass</TD><TD>The objectclass for PHPLIB's data</TD></TR><TR><TD><CAPTION>Accessible instance variables.</CAPTION></TD></TR></TABLE></CENTER><P><H3>Example</H3><P><P>Use a subclass to provide the appropriate parameters to your container. Usually your subclass looks like this: <P>

⌨️ 快捷键说明

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