<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>File Source for AlberT-cache.inc.php</title>
<link rel="stylesheet" href="../media/stylesheet.css" />
<!-- template designed by Julien Damon based on PHPEdit's generated templates, and tweaked by Greg Beaver -->
<body bgcolor="#ffffff" ><h1 align="center">Source for file AlberT-cache.inc.php</h1>
<p>Documentation is available at <a href="../AlberT-cache/_AlberT-cache_inc_php.html">AlberT-cache.inc.php</a></p>
<pre><a name="a1"></a><br />1 <strong><?php</strong><a name="a2"></a><br />2 <font color="#009999">/**</font><a name="a3"></a><br />3 <font color="#009999"> * AlberT-cache</font><a name="a4"></a><br />4 <font color="#009999"> * fast and portable full-page caching system</font><a name="a5"></a><br />5 <font color="#009999"> *</font><a name="a6"></a><br />6 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@copyright</font></strong><font color="#009999"> Copyleft Emiliano Gabrielli</font><a name="a7"></a><br />7 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@license</font></strong><font color="#009999"> http://opensource.org/licenses/gpl-license.php GNU Public License</font><a name="a8"></a><br />8 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@author</font></strong><font color="#009999"> Emiliano Gabrielli <[email protected]></font><a name="a9"></a><br />9 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@version</font></strong><font color="#009999"> $Id: AlberT-cache.inc.php,v 1.7 2004/12/14 17:41:04 albert Exp $</font><a name="a10"></a><br />10 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@package</font></strong><font color="#009999"> AlberT-cache</font><a name="a11"></a><br />11 <font color="#009999"> */</font><a name="a12"></a><br />12 <a name="a13"></a><br />13 <font color="#009999">/**</font><a name="a14"></a><br />14 <font color="#009999"> * Configuration file</font><a name="a15"></a><br />15 <font color="#009999"> */</font><a name="a16"></a><br />16 <font color="blue">require_once</font><strong>(</strong>dirname<strong>(</strong>__FILE__<strong>)</strong>.<font color="#66cccc">'/config.inc.php'</font><strong>)</strong>;<a name="a17"></a><br />17 <a name="a18"></a><br />18 <font color="#009999">/**</font><a name="a19"></a><br />19 <font color="#009999"> * Automatically handles the entire caching stuffs</font><a name="a20"></a><br />20 <font color="#009999"> *</font><a name="a21"></a><br />21 <font color="#009999"> * It automagically handles everything concerning the caching mechanism:</font><a name="a22"></a><br />22 <font color="#009999"> * gzipping of the contents when the browser supports it, the browser</font><a name="a23"></a><br />23 <font color="#009999"> * cache validation, etc..</font><a name="a24"></a><br />24 <font color="#009999"> *</font><a name="a25"></a><br />25 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@package</font></strong><font color="#009999"> AlberT-cache</font><a name="a26"></a><br />26 <font color="#009999"> */</font><a name="a27"></a><br />27 <font color="blue">class</font> <a href="../AlberT-cache/AlberTcache.html">AlberTcache</a><a name="a28"></a><br />28 <strong>{</strong><a name="a29"></a><br />29 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$dbg">$dbg</a>;<a name="a30"></a><br />30 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$gzip">$gzip</a>;<a name="a31"></a><br />31 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$post">$post</a>;<a name="a32"></a><br />32 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$timeout">$timeout</a>;<a name="a33"></a><br />33 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$expire">$expire</a>;<a name="a34"></a><br />34 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$also">$also</a>;<a name="a35"></a><br />35 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$oneSite">$oneSite</a>;<a name="a36"></a><br />36 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$storDir">$storDir</a>;<a name="a37"></a><br />37 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$gcProb">$gcProb</a>;<a name="a38"></a><br />38 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$isOn">$isOn</a>;<a name="a39"></a><br />39 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$mask">$mask</a>;<a name="a40"></a><br />40 <a name="a41"></a><br />41 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$absfile">$absfile</a>;<a name="a42"></a><br />42 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$data">$data</a>;<a name="a43"></a><br />43 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$variables">$variables</a>;<a name="a44"></a><br />44 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$file">$file</a>;<a name="a45"></a><br />45 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$gzcont">$gzcont</a>;<a name="a46"></a><br />46 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$size">$size</a>;<a name="a47"></a><br />47 <font color="blue">var</font> <a href="../AlberT-cache/AlberTcache.html#var$crc32">$crc32</a>;<a name="a48"></a><br />48 <a name="a49"></a><br />49 <font color="#009999">/**</font><a name="a50"></a><br />50 <font color="#009999"> * Class constructor</font><a name="a51"></a><br />51 <font color="#009999"> */</font><a name="a52"></a><br />52 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodAlberTcache">AlberTcache</a><strong>(</strong><strong>)</strong><a name="a53"></a><br />53 <strong>{</strong><a name="a54"></a><br />54 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$dbg">dbg</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_DEBUG'</font><strong>]</strong>;<a name="a55"></a><br />55 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzip">gzip</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_GZIP'</font><strong>]</strong>;<a name="a56"></a><br />56 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$post">post</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_POST'</font><strong>]</strong>;<a name="a57"></a><br />57 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$timeout">timeout</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_TIMEOUT'</font><strong>]</strong>;<a name="a58"></a><br />58 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$expire">expire</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_EXP'</font><strong>]</strong>;<a name="a59"></a><br />59 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$also">also</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_ALSO'</font><strong>]</strong>;<a name="a60"></a><br />60 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$oneSite">oneSite</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_1SITE'</font><strong>]</strong>;<a name="a61"></a><br />61 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$storDir">storDir</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_DIR'</font><strong>]</strong>;<a name="a62"></a><br />62 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gcProb">gcProb</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_GC'</font><strong>]</strong>;<a name="a63"></a><br />63 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$isOn">isOn</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_ON'</font><strong>]</strong>;<a name="a64"></a><br />64 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$mask">mask</a> = <strong>$GLOBALS</strong><strong>[</strong><font color="#66cccc">'CACHE_UMASK'</font><strong>]</strong>;<a name="a65"></a><br />65 <a name="a66"></a><br />66 <font color="green">/**</font><a name="a67"></a><br />67 <font color="green"> * We check if gzip functions are avaible</font><a name="a68"></a><br />68 <font color="green"> */</font><a name="a69"></a><br />69 <font color="blue">if</font> <strong>(</strong><strong>!</strong><a href="http://www.php.net/function_exists">function_exists</a><strong>(</strong><font color="#66cccc">'gzcompress'</font><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a70"></a><br />70 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzip">gzip</a> = FALSE;<a name="a71"></a><br />71 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'GZIP disabled, gzcompress() does not exists. '</font>.<a name="a72"></a><br />72 <font color="#66cccc">'May be we are on Win...'</font><strong>)</strong>;<a name="a73"></a><br />73 <strong>}</strong><a name="a74"></a><br />74 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodstart">start</a><strong>(</strong><strong>)</strong>;<a name="a75"></a><br />75 <font color="blue">return</font> TRUE;<a name="a76"></a><br />76 <strong>}</strong><a name="a77"></a><br />77 <a name="a78"></a><br />78 <font color="#009999">/**</font><a name="a79"></a><br />79 <font color="#009999"> * Resets the cache state</font><a name="a80"></a><br />80 <font color="#009999"> */</font><a name="a81"></a><br />81 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methoddoReset">doReset</a><strong>(</strong><strong>)</strong><a name="a82"></a><br />82 <strong>{</strong><a name="a83"></a><br />83 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a> = NULL;<a name="a84"></a><br />84 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a> = array<strong>(</strong><strong>)</strong>;<a name="a85"></a><br />85 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$variables">variables</a> = array<strong>(</strong><strong>)</strong>;<a name="a86"></a><br />86 <a name="a87"></a><br />87 <font color="blue">return</font> TRUE;<a name="a88"></a><br />88 <strong>}</strong><a name="a89"></a><br />89 <a name="a90"></a><br />90 <font color="#009999">/**</font><a name="a91"></a><br />91 <font color="#009999"> * Saves a variable state between caching</font><a name="a92"></a><br />92 <font color="#009999"> *</font><a name="a93"></a><br />93 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@param </font></strong><font color="#009999"></font><em>mixed </em><font color="#009999"></font><strong>$vn </strong><font color="#009999"> the name of the variable to save</font><a name="a94"></a><br />94 <font color="#009999"> */</font><a name="a95"></a><br />95 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodstoreVar">storeVar</a><strong>(</strong><strong>$vn</strong><strong>)</strong><a name="a96"></a><br />96 <strong>{</strong><a name="a97"></a><br />97 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Adding '</font>.<strong>$vn</strong>.<font color="#66cccc">' to the variable store'</font><strong>)</strong>;<a name="a98"></a><br />98 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$variables">variables</a><strong>[</strong><strong>]</strong> = <strong>$vn</strong>;<a name="a99"></a><br />99 <a name="a100"></a><br />100 <font color="blue">return</font> TRUE;<a name="a101"></a><br />101 <strong>}</strong><a name="a102"></a><br />102 <a name="a103"></a><br />103 <font color="#009999">/**</font><a name="a104"></a><br />104 <font color="#009999"> * A simple deguggig handler function</font><a name="a105"></a><br />105 <font color="#009999"> *</font><a name="a106"></a><br />106 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@param </font></strong><font color="#009999"></font><em>string </em><font color="#009999"></font><strong>$s </strong><font color="#009999">The debugging message</font><a name="a107"></a><br />107 <font color="#009999"> */</font><a name="a108"></a><br />108 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><strong>$s</strong><strong>)</strong><a name="a109"></a><br />109 <strong>{</strong><a name="a110"></a><br />110 <font color="blue">static</font> <strong>$debugline</strong> = 0;<a name="a111"></a><br />111 <a name="a112"></a><br />112 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong>dbg<strong>)</strong> <strong>{</strong><a name="a113"></a><br />113 header<strong>(</strong><font color="#66cccc">'X-Debug-'</font>.++<strong>$debugline</strong>.<font color="#66cccc">': '</font>.<strong>$s</strong><strong>)</strong>;<a name="a114"></a><br />114 <a name="a115"></a><br />115 <font color="green">// we can't print any output without generating a warning !!!</font><a name="a116"></a><br />116 <font color="green">//print_r("Line$debugline: $s<br>\n");</font><a name="a117"></a><br />117 <strong>}</strong><a name="a118"></a><br />118 <a name="a119"></a><br />119 <font color="blue">return</font> TRUE;<a name="a120"></a><br />120 <strong>}</strong><a name="a121"></a><br />121 <a name="a122"></a><br />122 <font color="#009999">/**</font><a name="a123"></a><br />123 <font color="#009999"> * Generates the key for the request</font><a name="a124"></a><br />124 <font color="#009999"> */</font><a name="a125"></a><br />125 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodgetDefaultKey">getDefaultKey</a><strong>(</strong><strong>)</strong><a name="a126"></a><br />126 <strong>{</strong><a name="a127"></a><br />127 <font color="blue">return</font> <a href="http://www.php.net/md5">md5</a><strong>(</strong><font color="#66cccc">'POST='</font>.<a href="http://www.php.net/serialize">serialize</a><strong>(</strong><strong>$_POST</strong><strong>)</strong>.<a name="a128"></a><br />128 <font color="#66cccc">' GET='</font>.<a href="http://www.php.net/serialize">serialize</a><strong>(</strong><strong>$_GET</strong><strong>)</strong>.<a name="a129"></a><br />129 <font color="#66cccc">' OTHER='</font>.<a href="http://www.php.net/serialize">serialize</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$also">also</a><strong>)</strong><strong>)</strong>;<a name="a130"></a><br />130 <strong>}</strong><a name="a131"></a><br />131 <a name="a132"></a><br />132 <font color="#009999">/**</font><a name="a133"></a><br />133 <font color="#009999"> * Returns the default object used by the helper functions</font><a name="a134"></a><br />134 <font color="#009999"> */</font><a name="a135"></a><br />135 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodgetDefaultObj">getDefaultObj</a><strong>(</strong><strong>)</strong><a name="a136"></a><br />136 <strong>{</strong><a name="a137"></a><br />137 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$oneSite">oneSite</a><strong>)</strong><a name="a138"></a><br />138 <strong>$name</strong> = <strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'PHP_SELF'</font><strong>]</strong>;<a name="a139"></a><br />139 else<a name="a140"></a><br />140 <strong>$name</strong> = <strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'PATH_TRANSLATED'</font><strong>]</strong>;<a name="a141"></a><br />141 <a name="a142"></a><br />142 <font color="blue">if</font> <strong>(</strong><strong>$name</strong>==<font color="#66cccc">''</font><strong>)</strong><a name="a143"></a><br />143 <strong>$name</strong> = <font color="#66cccc">'http://'</font>.<strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'HTTP_HOST'</font><strong>]</strong>.<font color="#66cccc">'/'</font>.<strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'PHP_SELF'</font><strong>]</strong>;<a name="a144"></a><br />144 <a name="a145"></a><br />145 <font color="blue">return</font> <strong>$name</strong>;<a name="a146"></a><br />146 <strong>}</strong><a name="a147"></a><br />147 <a name="a148"></a><br />148 <font color="#009999">/**</font><a name="a149"></a><br />149 <font color="#009999"> * Caches the current page based on the page name and the GET/POST</font><a name="a150"></a><br />150 <font color="#009999"> * variables. All must match or else it will not be fetched</font><a name="a151"></a><br />151 <font color="#009999"> * from the cache!</font><a name="a152"></a><br />152 <font color="#009999"> */</font><a name="a153"></a><br />153 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodcacheAll">cacheAll</a><strong>(</strong><strong>$cachetime</strong>=60<strong>)</strong><a name="a154"></a><br />154 <strong>{</strong><a name="a155"></a><br />155 <strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodgetDefaultObj">getDefaultObj</a><strong>(</strong><strong>)</strong>;<a name="a156"></a><br />156 <font color="blue">return</font> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodtheCache">theCache</a><strong>(</strong><strong>$cachetime</strong><strong>,</strong> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodgetDefaultKey">getDefaultKey</a><strong>(</strong><strong>)</strong><strong>)</strong>;<a name="a157"></a><br />157 <strong>}</strong><a name="a158"></a><br />158 <a name="a159"></a><br />159 <font color="#009999">/**</font><a name="a160"></a><br />160 <font color="#009999"> * Obtains a lock on the cache storage</font><a name="a161"></a><br />161 <font color="#009999"> */</font><a name="a162"></a><br />162 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodlock_fs">lock_fs</a><strong>(</strong><strong>$fp</strong><strong>,</strong> <strong>$mode</strong>=<font color="#66cccc">'w'</font><strong>)</strong><a name="a163"></a><br />163 <strong>{</strong><a name="a164"></a><br />164 <font color="blue">switch</font> <strong>(</strong><strong>$mode</strong><strong>)</strong> <strong>{</strong><a name="a165"></a><br />165 case <font color="#66cccc">'w'</font>:<a name="a166"></a><br />166 case <font color="#66cccc">'W'</font>:<a name="a167"></a><br />167 <font color="blue">return</font> <a href="http://www.php.net/flock">flock</a><strong>(</strong><strong>$fp</strong><strong>,</strong> LOCK_EX<strong>)</strong>;<a name="a168"></a><br />168 break;<a name="a169"></a><br />169 case <font color="#66cccc">'r'</font>:<a name="a170"></a><br />170 case <font color="#66cccc">'R'</font>:<a name="a171"></a><br />171 <font color="blue">return</font> <a href="http://www.php.net/flock">flock</a><strong>(</strong><strong>$fp</strong><strong>,</strong> LOCK_SH<strong>)</strong>;<a name="a172"></a><br />172 break;<a name="a173"></a><br />173 default:<a name="a174"></a><br />174 die<strong>(</strong><font color="#66cccc">'FATAL: invalid lock mode: '</font>.<strong>$mode</strong>.<font color="#66cccc">' in '</font>.__FILE__.<a name="a175"></a><br />175 <font color="#66cccc">' for method lock_fs()'</font><strong>)</strong>;<a name="a176"></a><br />176 <strong>}</strong><a name="a177"></a><br />177 <strong>}</strong><a name="a178"></a><br />178 <a name="a179"></a><br />179 <font color="#009999">/**</font><a name="a180"></a><br />180 <font color="#009999"> * Performs the unlock</font><a name="a181"></a><br />181 <font color="#009999"> */</font><a name="a182"></a><br />182 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodunlock_fs">unlock_fs</a><strong>(</strong><strong>$fp</strong><strong>)</strong><a name="a183"></a><br />183 <strong>{</strong><a name="a184"></a><br />184 <font color="blue">return</font> <a href="http://www.php.net/flock">flock</a><strong>(</strong><strong>$fp</strong><strong>,</strong> LOCK_UN<strong>)</strong>;<a name="a185"></a><br />185 <strong>}</strong><a name="a186"></a><br />186 <a name="a187"></a><br />187 <font color="#009999">/**</font><a name="a188"></a><br />188 <font color="#009999"> * Writes out the cache</font><a name="a189"></a><br />189 <font color="#009999"> */</font><a name="a190"></a><br />190 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodadd_fs">add_fs</a><strong>(</strong><strong>$file</strong><strong>,</strong> <strong>$data</strong><strong>)</strong><a name="a191"></a><br />191 <strong>{</strong><a name="a192"></a><br />192 <strong>$fp</strong> = <strong>@</strong><a href="http://www.php.net/fopen">fopen</a><strong>(</strong><strong>$file</strong><strong>,</strong> <font color="#66cccc">'wb'</font><strong>)</strong>;<a name="a193"></a><br />193 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$fp</strong><strong>)</strong> <strong>{</strong><a name="a194"></a><br />194 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Failed to open for write out to '</font>.<strong>$file</strong><strong>)</strong>;<a name="a195"></a><br />195 <font color="blue">return</font> FALSE;<a name="a196"></a><br />196 <strong>}</strong><a name="a197"></a><br />197 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodlock_fs">lock_fs</a><strong>(</strong><strong>$fp</strong><strong>,</strong> <font color="#66cccc">'w'</font><strong>)</strong>;<a name="a198"></a><br />198 <a href="http://www.php.net/fwrite">fwrite</a><strong>(</strong><strong>$fp</strong><strong>,</strong> <strong>$data</strong><strong>,</strong> <a href="http://www.php.net/strlen">strlen</a><strong>(</strong><strong>$data</strong><strong>)</strong><strong>)</strong>;<a name="a199"></a><br />199 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodunlock_fs">unlock_fs</a><strong>(</strong><strong>$fp</strong><strong>)</strong>;<a name="a200"></a><br />200 <a href="http://www.php.net/fclose">fclose</a><strong>(</strong><strong>$fp</strong><strong>)</strong>;<a name="a201"></a><br />201 <font color="blue">return</font> TRUE;<a name="a202"></a><br />202 <strong>}</strong><a name="a203"></a><br />203 <a name="a204"></a><br />204 <font color="#009999">/**</font><a name="a205"></a><br />205 <font color="#009999"> * Reads in the cache</font><a name="a206"></a><br />206 <font color="#009999"> */</font><a name="a207"></a><br />207 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodget_fs">get_fs</a><strong>(</strong><strong>$file</strong><strong>)</strong><a name="a208"></a><br />208 <strong>{</strong><a name="a209"></a><br />209 <strong>$fp</strong> = <strong>@</strong><a href="http://www.php.net/fopen">fopen</a><strong>(</strong><strong>$file</strong><strong>,</strong> <font color="#66cccc">'rb'</font><strong>)</strong>;<a name="a210"></a><br />210 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$fp</strong><strong>)</strong> <strong>{</strong><a name="a211"></a><br />211 <font color="blue">return</font> NULL;<a name="a212"></a><br />212 <strong>}</strong><a name="a213"></a><br />213 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodlock_fs">lock_fs</a><strong>(</strong><strong>$fp</strong><strong>,</strong> <font color="#66cccc">'r'</font><strong>)</strong>;<a name="a214"></a><br />214 <strong>$buff</strong> = <a href="http://www.php.net/fread">fread</a><strong>(</strong><strong>$fp</strong><strong>,</strong> <a href="http://www.php.net/filesize">filesize</a><strong>(</strong><strong>$file</strong><strong>)</strong><strong>)</strong>;<a name="a215"></a><br />215 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodunlock_fs">unlock_fs</a><strong>(</strong><strong>$fp</strong><strong>)</strong>;<a name="a216"></a><br />216 <a href="http://www.php.net/fclose">fclose</a><strong>(</strong><strong>$fp</strong><strong>)</strong>;<a name="a217"></a><br />217 <font color="blue">return</font> <strong>$buff</strong>;<a name="a218"></a><br />218 <strong>}</strong><a name="a219"></a><br />219 <a name="a220"></a><br />220 <font color="#009999">/**</font><a name="a221"></a><br />221 <font color="#009999"> * Returns the storage for cache</font><a name="a222"></a><br />222 <font color="#009999"> */</font><a name="a223"></a><br />223 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodgetStorage">getStorage</a><strong>(</strong><strong>$cacheobject</strong><strong>)</strong><a name="a224"></a><br />224 <strong>{</strong><a name="a225"></a><br />225 <font color="blue">return</font> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$storDir">storDir</a>.<font color="#66cccc">'/'</font>.<strong>$cacheobject</strong>;<a name="a226"></a><br />226 <strong>}</strong><a name="a227"></a><br />227 <a name="a228"></a><br />228 <font color="#009999">/**</font><a name="a229"></a><br />229 <font color="#009999"> * Cache garbage collector</font><a name="a230"></a><br />230 <font color="#009999"> */</font><a name="a231"></a><br />231 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methoddoGC">doGC</a><strong>(</strong><strong>)</strong><a name="a232"></a><br />232 <strong>{</strong><a name="a233"></a><br />233 <strong>$de</strong> = <font color="#66cccc">''</font>;<a name="a234"></a><br />234 <a name="a235"></a><br />235 <font color="green">// Should we garbage collect ?</font><a name="a236"></a><br />236 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gcProb">gcProb</a>>0<strong>)</strong> <strong>{</strong><a name="a237"></a><br />237 <a href="http://www.php.net/mt_srand">mt_srand</a><strong>(</strong><a href="http://www.php.net/time">time</a><strong>(</strong><strong>)</strong><strong>)</strong>;<a name="a238"></a><br />238 <strong>$precision</strong> = 100000;<a name="a239"></a><br />239 <strong>$r</strong> = <strong>(</strong><a href="http://www.php.net/mt_rand">mt_rand</a><strong>(</strong><strong>)</strong>%<strong>$precision</strong><strong>)</strong>/<strong>$precision</strong>;<a name="a240"></a><br />240 <font color="blue">if</font> <strong>(</strong><strong>$r</strong>><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gcProb">gcProb</a>/100<strong>)</strong><strong>)</strong> <strong>{</strong><a name="a241"></a><br />241 <font color="blue">return</font> FALSE;<a name="a242"></a><br />242 <strong>}</strong><a name="a243"></a><br />243 <strong>}</strong><a name="a244"></a><br />244 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Running gc'</font><strong>)</strong>;<a name="a245"></a><br />245 <strong>$dp</strong> = <strong>@</strong><a href="http://www.php.net/opendir">opendir</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$storDir">storDir</a><strong>)</strong>;<a name="a246"></a><br />246 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$dp</strong><strong>)</strong> <strong>{</strong><a name="a247"></a><br />247 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong>"<font color="#66cccc">Error opening '{<strong>$this</strong></font><strong>-></strong>storDir<font color="#66cccc"><strong>}</strong>' for cleanup</font>"<strong>)</strong>;<a name="a248"></a><br />248 <font color="blue">return</font> FALSE;<a name="a249"></a><br />249 <strong>}</strong><a name="a250"></a><br />250 <font color="green">// walking into the dir and remove expired files</font><a name="a251"></a><br />251 while <strong>(</strong>FALSE !== <strong>(</strong><strong>$de</strong>=<a href="http://www.php.net/readdir">readdir</a><strong>(</strong><strong>$dp</strong><strong>)</strong><strong>)</strong> <strong>)</strong> <strong>{</strong><a name="a252"></a><br />252 <font color="blue">if</font> <strong>(</strong> <strong>$de</strong> != <font color="#66cccc">'.'</font> && <strong>$de</strong> != <font color="#66cccc">'..'</font> <strong>)</strong> <strong>{</strong><a name="a253"></a><br />253 <font color="green">// To get around strange php-strpos, add additional char</font><a name="a254"></a><br />254 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/strpos">strpos</a><strong>(</strong>"<font color="#66cccc"> <strong>$de</strong></font>"<strong>,</strong> <font color="#66cccc">'cache-'</font><strong>)</strong>==1<strong>)</strong> <strong>{</strong><a name="a255"></a><br />255 <strong>$absfile</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$storDir">storDir</a>.<font color="#66cccc">'/'</font>.<strong>$de</strong>;<a name="a256"></a><br />256 <strong>$thecache</strong> = <a href="http://www.php.net/unserialize">unserialize</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodget_fs">get_fs</a><strong>(</strong><strong>$absfile</strong><strong>)</strong><strong>)</strong>;<a name="a257"></a><br />257 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/is_array">is_array</a><strong>(</strong><strong>$thecache</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a258"></a><br />258 <font color="blue">if</font> <strong>(</strong><strong>$thecache</strong><strong>[</strong><font color="#66cccc">'cachetime'</font><strong>]</strong>!=<font color="#66cccc">'0'</font> && <strong>$thecache</strong><strong>[</strong><font color="#66cccc">'expire'</font><strong>]</strong><=<a href="http://www.php.net/time">time</a><strong>(</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a259"></a><br />259 <font color="blue">if</font> <strong>(</strong><strong>@</strong><a href="http://www.php.net/unlink">unlink</a><strong>(</strong><strong>$absfile</strong><strong>)</strong><strong>)</strong><a name="a260"></a><br />260 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Deleted '</font>.<strong>$absfile</strong><strong>)</strong>;<a name="a261"></a><br />261 else<a name="a262"></a><br />262 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Failed to delete '</font>.<strong>$absfile</strong><strong>)</strong>;<a name="a263"></a><br />263 <strong>}</strong><a name="a264"></a><br />264 else<a name="a265"></a><br />265 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><strong>$absfile</strong>.<font color="#66cccc">' expires in '</font>.<strong>(</strong><strong>$thecache</strong><strong>[</strong><font color="#66cccc">'expire'</font><strong>]</strong>-<a href="http://www.php.net/time">time</a><strong>(</strong><strong>)</strong><strong>)</strong><strong>)</strong>;<a name="a266"></a><br />266 <strong>}</strong><a name="a267"></a><br />267 else<a name="a268"></a><br />268 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><strong>$absfile</strong>.<font color="#66cccc">' is empty, being processed in another process?'</font><strong>)</strong>;<a name="a269"></a><br />269 <strong>}</strong><a name="a270"></a><br />270 <strong>}</strong><a name="a271"></a><br />271 <strong>}</strong><a name="a272"></a><br />272 <strong>@</strong><a href="http://www.php.net/closedir">closedir</a><strong>(</strong><strong>$dp</strong><strong>)</strong>;<a name="a273"></a><br />273 <font color="blue">return</font> TRUE;<a name="a274"></a><br />274 <strong>}</strong><a name="a275"></a><br />275 <a name="a276"></a><br />276 <font color="#009999">/** theCache()</font><a name="a277"></a><br />277 <font color="#009999"> *</font><a name="a278"></a><br />278 <font color="#009999"> * Caches $object based on $key for $cachetime, will return 0 if the</font><a name="a279"></a><br />279 <font color="#009999"> * object has expired or does not exist.</font><a name="a280"></a><br />280 <font color="#009999"> */</font><a name="a281"></a><br />281 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodtheCache">theCache</a><strong>(</strong><strong>$cachetime</strong><strong>,</strong> <strong>$key</strong>=NULL<strong>)</strong><a name="a282"></a><br />282 <strong>{</strong><a name="a283"></a><br />283 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$isOn">isOn</a><strong>)</strong> <strong>{</strong><a name="a284"></a><br />284 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Not caching, CACHE_ON is 0'</font><strong>)</strong>;<a name="a285"></a><br />285 <font color="blue">return</font> 0;<a name="a286"></a><br />286 <strong>}</strong><a name="a287"></a><br />287 <strong>$curtime</strong> = <a href="http://www.php.net/time">time</a><strong>(</strong><strong>)</strong>;<a name="a288"></a><br />288 <font color="green">// Make it a valid name</font><a name="a289"></a><br />289 <strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a> = <a href="http://www.php.net/eregi_replace">eregi_replace</a><strong>(</strong><font color="#66cccc">'[^A-Z,0-9,=]'</font><strong>,</strong> <font color="#66cccc">'_'</font><strong>,</strong> <strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a><strong>)</strong>;<a name="a290"></a><br />290 <strong>$key</strong> = <a href="http://www.php.net/eregi_replace">eregi_replace</a><strong>(</strong><font color="#66cccc">'[^A-Z,0-9,=]'</font><strong>,</strong> <font color="#66cccc">'_'</font><strong>,</strong> <strong>$key</strong><strong>)</strong>;<a name="a291"></a><br />291 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Caching based on OBJECT='</font>.<strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a>.<font color="#66cccc">' KEY='</font>.<strong>$key</strong><strong>)</strong>;<a name="a292"></a><br />292 <strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a> = <font color="#66cccc">'cache-'</font>.<strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a>.<font color="#66cccc">'-'</font>.<strong>$key</strong>;<a name="a293"></a><br />293 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodgetStorage">getStorage</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="http://www.php.net/file">file</a><strong>)</strong>;<a name="a294"></a><br />294 <font color="green">// Can we access the cache_file ?</font><a name="a295"></a><br />295 <font color="blue">if</font> <strong>(</strong><strong>(</strong><strong>$buff</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodget_fs">get_fs</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>)</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a296"></a><br />296 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Opened the cache file'</font><strong>)</strong>;<a name="a297"></a><br />297 <strong>$cdata</strong> = <a href="http://www.php.net/unserialize">unserialize</a><strong>(</strong><strong>$buff</strong><strong>)</strong>;<a name="a298"></a><br />298 <font color="green">//var_dump($cdata);</font><a name="a299"></a><br />299 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/is_array">is_array</a><strong>(</strong><strong>$cdata</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a300"></a><br />300 <strong>$curco</strong> = <strong>$cdata</strong><strong>[</strong><font color="#66cccc">'cache_object'</font><strong>]</strong>;<a name="a301"></a><br />301 <font color="blue">if</font> <strong>(</strong><strong>$curco</strong> != <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>)</strong> <strong>{</strong><a name="a302"></a><br />302 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'WTF?! That is not my cache file! got='</font>.<strong>$curco</strong>.<a name="a303"></a><br />303 <font color="#66cccc">' wanted='</font>.<strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>)</strong>;<a name="a304"></a><br />304 <strong>}</strong><a name="a305"></a><br />305 else <strong>{</strong><a name="a306"></a><br />306 <font color="blue">if</font> <strong>(</strong><strong>$cdata</strong><strong>[</strong><font color="#66cccc">'cachetime'</font><strong>]</strong>==<font color="#66cccc">'0'</font> || <strong>$cdata</strong><strong>[</strong><font color="#66cccc">'expire'</font><strong>]</strong>>=<strong>$curtime</strong><strong>)</strong> <strong>{</strong><a name="a307"></a><br />307 <font color="green">// data not yet expired (or never expiring)</font><a name="a308"></a><br />308 <strong>$expirein</strong> = <strong>$cdata</strong><strong>[</strong><font color="#66cccc">'expire'</font><strong>]</strong>-<strong>$curtime</strong>+1;<a name="a309"></a><br />309 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Cache expires in '</font>.<strong>$expirein</strong><strong>)</strong>;<a name="a310"></a><br />310 <a name="a311"></a><br />311 <font color="green">// restore variables</font><a name="a312"></a><br />312 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/is_array">is_array</a><strong>(</strong><strong>$cdata</strong><strong>[</strong><font color="#66cccc">'variables'</font><strong>]</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a313"></a><br />313 <font color="blue">foreach</font> <strong>(</strong><strong>$cdata</strong><strong>[</strong><font color="#66cccc">'variables'</font><strong>]</strong> as <strong>$k</strong>=><strong>$v</strong><strong>)</strong> <strong>{</strong><a name="a314"></a><br />314 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Restoring variable '</font>.<strong>$k</strong>.<font color="#66cccc">' to value '</font>.<strong>$v</strong><strong>)</strong>;<a name="a315"></a><br />315 <strong>$GLOBALS</strong><strong>[</strong><strong>$k</strong><strong>]</strong> = <strong>$v</strong>;<a name="a316"></a><br />316 <strong>}</strong><a name="a317"></a><br />317 <strong>}</strong><a name="a318"></a><br />318 <font color="green">// restore gzcontent</font><a name="a319"></a><br />319 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Restoring gzipped content'</font><strong>)</strong>;<a name="a320"></a><br />320 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a> = <strong>$cdata</strong><strong>[</strong><font color="#66cccc">'gzcontent'</font><strong>]</strong>;<a name="a321"></a><br />321 <a name="a322"></a><br />322 <strong>$ret</strong> = <strong>$expirein</strong>;<a name="a323"></a><br />323 <font color="blue">if</font> <strong>(</strong><strong>$cdata</strong><strong>[</strong><font color="#66cccc">'cachetime'</font><strong>]</strong>==<font color="#66cccc">'0'</font><strong>)</strong> <strong>{</strong><a name="a324"></a><br />324 <strong>$ret</strong> = <font color="#66cccc">'INFINITE'</font>;<a name="a325"></a><br />325 <strong>}</strong><a name="a326"></a><br />326 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoReset">doReset</a><strong>(</strong><strong>)</strong>;<a name="a327"></a><br />327 <font color="blue">return</font> <strong>$ret</strong>;<a name="a328"></a><br />328 <strong>}</strong><a name="a329"></a><br />329 <strong>}</strong><a name="a330"></a><br />330 <strong>}</strong><a name="a331"></a><br />331 <strong>}</strong><a name="a332"></a><br />332 else <strong>{</strong><a name="a333"></a><br />333 <font color="green">// No cache file (yet) or unable to read</font><a name="a334"></a><br />334 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'No previous cache of '</font>.<strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a>.<font color="#66cccc">' or unable to read'</font><strong>)</strong>;<a name="a335"></a><br />335 <strong>}</strong><a name="a336"></a><br />336 <a name="a337"></a><br />337 <font color="green">// If we came here: start caching!</font><a name="a338"></a><br />338 <strong>$umask</strong> = <strong>(</strong><a href="http://www.php.net/function_exists">function_exists</a><strong>(</strong><font color="#66cccc">'umask'</font><strong>)</strong><strong>)</strong> ? TRUE : FALSE;<a name="a339"></a><br />339 <font color="green">// Create the file for this page</font><a name="a340"></a><br />340 <font color="blue">if</font> <strong>(</strong><strong>$umask</strong> === TRUE<strong>)</strong> <strong>{</strong><a name="a341"></a><br />341 <strong>$oldum</strong> = <a href="http://www.php.net/umask">umask</a><strong>(</strong><strong>)</strong>;<a name="a342"></a><br />342 <a href="http://www.php.net/umask">umask</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$mask">mask</a><strong>)</strong>;<a name="a343"></a><br />343 <strong>}</strong><a name="a344"></a><br />344 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/function_exists">function_exists</a><strong>(</strong><font color="#66cccc">'readlink'</font><strong>)</strong> && <strong>@</strong><a href="http://www.php.net/readlink">readlink</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a345"></a><br />345 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a>.<font color="#66cccc">' is a symlink! not caching!'</font><strong>)</strong>;<a name="a346"></a><br />346 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a> = NULL;<a name="a347"></a><br />347 <strong>}</strong><a name="a348"></a><br />348 else <strong>{</strong><a name="a349"></a><br />349 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Created '</font>.<strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a>.<font color="#66cccc">', waiting for callback'</font><strong>)</strong>;<a name="a350"></a><br />350 <strong>$fp</strong> = <strong>@</strong><a href="http://www.php.net/fopen">fopen</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>,</strong> <font color="#66cccc">'wb'</font><strong>)</strong>;<a name="a351"></a><br />351 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$fp</strong><strong>)</strong> <strong>{</strong><a name="a352"></a><br />352 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Unable to open for write '</font>.<strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>)</strong>;<a name="a353"></a><br />353 <strong>}</strong><a name="a354"></a><br />354 <strong>}</strong><a name="a355"></a><br />355 <font color="blue">if</font> <strong>(</strong><strong>$umask</strong> === TRUE<strong>)</strong> <strong>{</strong><a name="a356"></a><br />356 <a href="http://www.php.net/umask">umask</a><strong>(</strong><strong>$oldum</strong><strong>)</strong>;<a name="a357"></a><br />357 <strong>}</strong><a name="a358"></a><br />358 <font color="green">// Set expire and cachetime</font><a name="a359"></a><br />359 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>[</strong><font color="#66cccc">'expire'</font><strong>]</strong> = <strong>$curtime</strong> + <strong>$cachetime</strong>;<a name="a360"></a><br />360 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>[</strong><font color="#66cccc">'cachetime'</font><strong>]</strong> = <strong>$cachetime</strong>;<a name="a361"></a><br />361 <a name="a362"></a><br />362 <font color="blue">return</font> 0;<a name="a363"></a><br />363 <strong>}</strong><a name="a364"></a><br />364 <a name="a365"></a><br />365 <font color="#009999">/** doWrite()</font><a name="a366"></a><br />366 <font color="#009999"> *</font><a name="a367"></a><br />367 <font color="#009999"> * Does the actual caching</font><a name="a368"></a><br />368 <font color="#009999"> */</font><a name="a369"></a><br />369 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methoddoWrite">doWrite</a><strong>(</strong><strong>)</strong><a name="a370"></a><br />370 <strong>{</strong><a name="a371"></a><br />371 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$isOn">isOn</a><strong>)</strong> <strong>{</strong><a name="a372"></a><br />372 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Not caching, CACHE_ON is off'</font><strong>)</strong>;<a name="a373"></a><br />373 <font color="blue">return</font> 0;<a name="a374"></a><br />374 <strong>}</strong><a name="a375"></a><br />375 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a>!=NULL<strong>)</strong> <strong>{</strong><a name="a376"></a><br />376 <strong>$variables</strong> = array<strong>(</strong><strong>)</strong>;<a name="a377"></a><br />377 <font color="blue">foreach</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$variables">variables</a> as <strong>$vn</strong><strong>)</strong> <strong>{</strong><a name="a378"></a><br />378 <font color="blue">if</font> <strong>(</strong>isset<strong>(</strong><strong>$GLOBALS</strong><strong>[</strong><strong>$vn</strong><strong>]</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a379"></a><br />379 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Setting variable '</font>.<strong>$vn</strong>.<font color="#66cccc">' to '</font>.<strong>$GLOBALS</strong><strong>[</strong><strong>$vn</strong><strong>]</strong><strong>)</strong>;<a name="a380"></a><br />380 <strong>$variables</strong><strong>[</strong><strong>$vn</strong><strong>]</strong> = <strong>$GLOBALS</strong><strong>[</strong><strong>$vn</strong><strong>]</strong>;<a name="a381"></a><br />381 <strong>}</strong><a name="a382"></a><br />382 <strong>}</strong><a name="a383"></a><br />383 <font color="green">// Fill cache_data</font><a name="a384"></a><br />384 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>[</strong><font color="#66cccc">'gzcontent'</font><strong>]</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a>;<a name="a385"></a><br />385 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>[</strong><font color="#66cccc">'cache_object'</font><strong>]</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a>;<a name="a386"></a><br />386 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>[</strong><font color="#66cccc">'variables'</font><strong>]</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$variables">variables</a>;<a name="a387"></a><br />387 <strong>$datas</strong> = <a href="http://www.php.net/serialize">serialize</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$data">data</a><strong>)</strong>;<a name="a388"></a><br />388 <font color="green">// write data</font><a name="a389"></a><br />389 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodadd_fs">add_fs</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$absfile">absfile</a><strong>,</strong> <strong>$datas</strong><strong>)</strong>;<a name="a390"></a><br />390 <strong>}</strong><a name="a391"></a><br />391 <strong>}</strong><a name="a392"></a><br />392 <a name="a393"></a><br />393 <font color="#009999">/** getEncoding()</font><a name="a394"></a><br />394 <font color="#009999"> *</font><a name="a395"></a><br />395 <font color="#009999"> * Are we capable of receiving gzipped data ?</font><a name="a396"></a><br />396 <font color="#009999"> * Returns the encoding that is accepted. Maybe additional check for Mac ?</font><a name="a397"></a><br />397 <font color="#009999"> */</font><a name="a398"></a><br />398 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodgetEncoding">getEncoding</a><strong>(</strong><strong>)</strong><a name="a399"></a><br />399 <strong>{</strong><a name="a400"></a><br />400 <font color="blue">if</font> <strong>(</strong> <a href="http://www.php.net/is_array">is_array</a><strong>(</strong><strong>$_SERVER</strong><strong>)</strong> && <a href="http://www.php.net/array_key_exists">array_key_exists</a><strong>(</strong><font color="#66cccc">'HTTP_ACCEPT_ENCODING'</font><strong>,</strong> <strong>$_SERVER</strong><strong>)</strong> <strong>)</strong> <strong>{</strong><a name="a401"></a><br />401 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/strpos">strpos</a><strong>(</strong><strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'HTTP_ACCEPT_ENCODING'</font><strong>]</strong><strong>,</strong> <font color="#66cccc">'x-gzip'</font><strong>)</strong> !== FALSE<strong>)</strong> <strong>{</strong><a name="a402"></a><br />402 <font color="blue">return</font> <font color="#66cccc">'x-gzip'</font>;<a name="a403"></a><br />403 <strong>}</strong><a name="a404"></a><br />404 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/strpos">strpos</a><strong>(</strong><strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'HTTP_ACCEPT_ENCODING'</font><strong>]</strong><strong>,</strong> <font color="#66cccc">'gzip'</font><strong>)</strong> !== FALSE<strong>)</strong> <strong>{</strong><a name="a405"></a><br />405 <font color="blue">return</font> <font color="#66cccc">'gzip'</font>;<a name="a406"></a><br />406 <strong>}</strong><a name="a407"></a><br />407 <strong>}</strong><a name="a408"></a><br />408 <font color="blue">return</font> FALSE;<a name="a409"></a><br />409 <strong>}</strong><a name="a410"></a><br />410 <a name="a411"></a><br />411 <font color="#009999">/** init()</font><a name="a412"></a><br />412 <font color="#009999"> *</font><a name="a413"></a><br />413 <font color="#009999"> * Checks some global variables and might decide to disable caching</font><a name="a414"></a><br />414 <font color="#009999"> * and calls appropriate initialization-methods</font><a name="a415"></a><br />415 <font color="#009999"> */</font><a name="a416"></a><br />416 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodinit">init</a><strong>(</strong><strong>)</strong><a name="a417"></a><br />417 <strong>{</strong><a name="a418"></a><br />418 <font color="green">// Override default CACHE_TIME ?</font><a name="a419"></a><br />419 <font color="blue">if</font> <strong>(</strong>isset<strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$timeout">timeout</a><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a420"></a><br />420 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$expire">expire</a> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$timeout">timeout</a>;<a name="a421"></a><br />421 <strong>}</strong><a name="a422"></a><br />422 <font color="green">// Force cache off when POST occured when you don't want it cached</font><a name="a423"></a><br />423 <font color="blue">if</font> <strong>(</strong><strong>!</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$post">post</a> && <strong>(</strong><a href="http://www.php.net/count">count</a><strong>(</strong><strong>$_POST</strong><strong>)</strong> > 0<strong>)</strong><strong>)</strong> <strong>{</strong><a name="a424"></a><br />424 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$isOn">isOn</a> = 0;<a name="a425"></a><br />425 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$expire">expire</a> = -1;<a name="a426"></a><br />426 <strong>}</strong><a name="a427"></a><br />427 <font color="green">// A cachetimeout of -1 disables writing, only ETag and content</font><a name="a428"></a><br />428 <font color="green">// encoding if possible</font><a name="a429"></a><br />429 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$expire">expire</a> == -1<strong>)</strong> <strong>{</strong><a name="a430"></a><br />430 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$isOn">isOn</a> = 0;<a name="a431"></a><br />431 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'$expire == -1 disabling cache: CACHE_ON is off'</font><strong>)</strong>;<a name="a432"></a><br />432 <strong>}</strong><a name="a433"></a><br />433 <font color="green">// Reset cache</font><a name="a434"></a><br />434 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoReset">doReset</a><strong>(</strong><strong>)</strong>;<a name="a435"></a><br />435 <strong>}</strong><a name="a436"></a><br />436 <a name="a437"></a><br />437 <font color="#009999">/** start()</font><a name="a438"></a><br />438 <font color="#009999"> *</font><a name="a439"></a><br />439 <font color="#009999"> * Sets the handler for callback</font><a name="a440"></a><br />440 <font color="#009999"> */</font><a name="a441"></a><br />441 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodstart">start</a><strong>(</strong><strong>)</strong><a name="a442"></a><br />442 <strong>{</strong><a name="a443"></a><br />443 <font color="green">// Initialize cache</font><a name="a444"></a><br />444 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodinit">init</a><strong>(</strong><strong>)</strong>;<a name="a445"></a><br />445 <a name="a446"></a><br />446 <font color="green">// Check cache</font><a name="a447"></a><br />447 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodcacheAll">cacheAll</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$expire">expire</a><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a448"></a><br />448 <font color="green">/** @internal Cache is valid: flush it! */</font><a name="a449"></a><br />449 echo <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoFlush">doFlush</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a><strong>,</strong> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$size">size</a><strong>,</strong><a name="a450"></a><br />450 <strong>$this</strong><strong>-></strong><a href="http://www.php.net/crc32">crc32</a><strong>)</strong>;<a name="a451"></a><br />451 exit;<a name="a452"></a><br />452 <strong>}</strong><a name="a453"></a><br />453 else <strong>{</strong><a name="a454"></a><br />454 <font color="green">/** @internal if we came here, cache is invalid: go generate</font><a name="a455"></a><br />455 <font color="green"> * page and wait for 'finalize()' callback which will be</font><a name="a456"></a><br />456 <font color="green"> * called automagically</font><a name="a457"></a><br />457 <font color="green"> */</font><a name="a458"></a><br />458 <a name="a459"></a><br />459 <font color="green">// Check garbage collection</font><a name="a460"></a><br />460 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoGC">doGC</a><strong>(</strong><strong>)</strong>;<a name="a461"></a><br />461 <a name="a462"></a><br />462 <a href="http://www.php.net/ob_start">ob_start</a><strong>(</strong>array<strong>(</strong><strong>&</strong><strong>$this</strong><strong>,</strong><font color="#66cccc">'finalize'</font><strong>)</strong><strong>)</strong>;<a name="a463"></a><br />463 <a href="http://www.php.net/ob_implicit_flush">ob_implicit_flush</a><strong>(</strong>0<strong>)</strong>;<a name="a464"></a><br />464 <strong>}</strong><a name="a465"></a><br />465 <strong>}</strong><a name="a466"></a><br />466 <a name="a467"></a><br />467 <font color="#009999">/** finalize()</font><a name="a468"></a><br />468 <font color="#009999"> *</font><a name="a469"></a><br />469 <font color="#009999"> * This function is called by the callback-funtion of the ob_start</font><a name="a470"></a><br />470 <font color="#009999"> *</font><a name="a471"></a><br />471 <font color="#009999"> *</font><font color="#009999"> </font><strong><font color = "#0099FF">@param </font></strong><font color="#009999"></font><em>string </em><font color="#009999"></font><strong>$contents </strong><font color="#009999">the string representing the page to be flushed out</font><a name="a472"></a><br />472 <font color="#009999"> *</font><font color="#009999"> </font><font color="#009999"> to the client</font><a name="a473"></a><br />473 <font color="#009999"> */</font><a name="a474"></a><br />474 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methodfinalize">finalize</a><strong>(</strong><strong>$contents</strong><strong>)</strong><a name="a475"></a><br />475 <strong>{</strong><a name="a476"></a><br />476 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$size">size</a> = <a href="http://www.php.net/strlen">strlen</a><strong>(</strong><strong>$contents</strong><strong>)</strong>;<a name="a477"></a><br />477 <strong>$this</strong><strong>-></strong><a href="http://www.php.net/crc32">crc32</a> = <a href="http://www.php.net/crc32">crc32</a><strong>(</strong><strong>$contents</strong><strong>)</strong>;<a name="a478"></a><br />478 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodpdebug">pdebug</a><strong>(</strong><font color="#66cccc">'Callback happened'</font><strong>)</strong>;<a name="a479"></a><br />479 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzip">gzip</a>===TRUE<strong>)</strong> <strong>{</strong><a name="a480"></a><br />480 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a> = <a href="http://www.php.net/gzcompress">gzcompress</a><strong>(</strong><strong>$contents</strong><strong>,</strong> 9<strong>)</strong>;<a name="a481"></a><br />481 <strong>}</strong><a name="a482"></a><br />482 else <strong>{</strong><a name="a483"></a><br />483 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a> = <strong>$contents</strong>;<a name="a484"></a><br />484 <strong>}</strong><a name="a485"></a><br />485 <font color="green">/**</font><a name="a486"></a><br />486 <font color="green"> * @internal cache these variables, as they are about original content</font><a name="a487"></a><br />487 <font color="green"> * which is lost after this</font><a name="a488"></a><br />488 <font color="green"> */</font><a name="a489"></a><br />489 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodstoreVar">storeVar</a><strong>(</strong><font color="#66cccc">'size'</font><strong>)</strong>;<a name="a490"></a><br />490 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodstoreVar">storeVar</a><strong>(</strong><font color="#66cccc">'crc32'</font><strong>)</strong>;<a name="a491"></a><br />491 <font color="green">// write the cache</font><a name="a492"></a><br />492 <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoWrite">doWrite</a><strong>(</strong><strong>)</strong>;<a name="a493"></a><br />493 <a name="a494"></a><br />494 <font color="green">// Return flushed data</font><a name="a495"></a><br />495 <font color="blue">return</font> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methoddoFlush">doFlush</a><strong>(</strong><strong>)</strong>;<a name="a496"></a><br />496 <strong>}</strong><a name="a497"></a><br />497 <a name="a498"></a><br />498 <font color="#009999">/** doFlush()</font><a name="a499"></a><br />499 <font color="#009999"> *</font><a name="a500"></a><br />500 <font color="#009999"> * Responsible for final flushing everything.</font><a name="a501"></a><br />501 <font color="#009999"> * Sets ETag-headers and returns "Not modified" when possible</font><a name="a502"></a><br />502 <font color="#009999"> *</font><a name="a503"></a><br />503 <font color="#009999"> * When ETag doesn't match (or is invalid), it is tried to send</font><a name="a504"></a><br />504 <font color="#009999"> * the gzipped data. If that is also not possible, we sadly have to</font><a name="a505"></a><br />505 <font color="#009999"> * uncompress (assuming $CACHE_GZIP is on)</font><a name="a506"></a><br />506 <font color="#009999"> */</font><a name="a507"></a><br />507 <font color="blue">function</font> <a href="../AlberT-cache/AlberTcache.html#methoddoFlush">doFlush</a><strong>(</strong><strong>)</strong><a name="a508"></a><br />508 <strong>{</strong><a name="a509"></a><br />509 <strong>$foundETag</strong> = <font color="#66cccc">''</font>;<a name="a510"></a><br />510 <strong>$ret</strong> = NULL;<a name="a511"></a><br />511 <a name="a512"></a><br />512 <font color="green">/**</font><a name="a513"></a><br />513 <font color="green"> * @internal First check if we can send last-modified</font><a name="a514"></a><br />514 <font color="green"> */</font><a name="a515"></a><br />515 <strong>$myETag</strong> = <font color="#66cccc">'"AlberT-'</font>.<strong>$this</strong><strong>-></strong><a href="http://www.php.net/crc32">crc32</a>.<strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$size">size</a>.<font color="#66cccc">'"'</font>;<a name="a516"></a><br />516 <a href="http://www.php.net/header">header</a><strong>(</strong><font color="#66cccc">'ETag: '</font>.<strong>$myETag</strong><strong>)</strong>;<a name="a517"></a><br />517 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/array_key_exists">array_key_exists</a><strong>(</strong><font color="#66cccc">'HTTP_IF_NONE_MATCH'</font><strong>,</strong> <strong>$_SERVER</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a518"></a><br />518 <strong>$foundETag</strong> = <a href="http://www.php.net/stripslashes">stripslashes</a><strong>(</strong><strong>$_SERVER</strong><strong>[</strong><font color="#66cccc">'HTTP_IF_NONE_MATCH'</font><strong>]</strong><strong>)</strong>;<a name="a519"></a><br />519 <strong>}</strong><a name="a520"></a><br />520 <font color="blue">if</font> <strong>(</strong><a href="http://www.php.net/strstr">strstr</a><strong>(</strong><strong>$foundETag</strong><strong>,</strong> <strong>$myETag</strong><strong>)</strong><strong>)</strong> <strong>{</strong><a name="a521"></a><br />521 <font color="green">/**</font><a name="a522"></a><br />522 <font color="green"> * @internal Browser has the page in its cache.</font><a name="a523"></a><br />523 <font color="green"> * We send only a "Not modified" header and exit!</font><a name="a524"></a><br />524 <font color="green"> */</font><a name="a525"></a><br />525 <strong>(</strong><a href="http://www.php.net/php_sapi_name">php_sapi_name</a><strong>(</strong><strong>)</strong> == <font color="#66cccc">'cgi'</font><strong>)</strong> ? <a href="http://www.php.net/header">header</a><strong>(</strong><font color="#66cccc">'Status: 304'</font><strong>)</strong> : <a href="http://www.php.net/header">header</a><strong>(</strong><font color="#66cccc">'HTTP/1.0 304'</font><strong>)</strong>;<a name="a526"></a><br />526 <strong>}</strong><a name="a527"></a><br />527 else <strong>{</strong><a name="a528"></a><br />528 <font color="green">// Are we gzipping ?</font><a name="a529"></a><br />529 <font color="blue">if</font> <strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzip">gzip</a>===TRUE<strong>)</strong> <strong>{</strong><a name="a530"></a><br />530 <strong>$encod</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#methodgetEncoding">getEncoding</a><strong>(</strong><strong>)</strong>;<a name="a531"></a><br />531 <font color="blue">if</font> <strong>(</strong>FALSE!==<strong>$encod</strong><strong>)</strong> <strong>{</strong><a name="a532"></a><br />532 <font color="green">// compressed output: set header</font><a name="a533"></a><br />533 <a href="http://www.php.net/header">header</a><strong>(</strong><font color="#66cccc">'Content-Encoding: '</font>.<strong>$encod</strong><strong>)</strong>;<a name="a534"></a><br />534 <strong>$ret</strong> = <font color="#66cccc">"\x1f\x8b\x08\x00\x00\x00\x00\x00"</font>;<a name="a535"></a><br />535 <strong>$ret</strong> .= <a href="http://www.php.net/substr">substr</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a><strong>,</strong> 0<strong>,</strong><a name="a536"></a><br />536 <a href="http://www.php.net/strlen">strlen</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a><strong>)</strong> - 4<strong>)</strong>;<a name="a537"></a><br />537 <strong>$ret</strong> .= <a href="http://www.php.net/pack">pack</a><strong>(</strong><font color="#66cccc">'V'</font><strong>,</strong> <strong>$this</strong><strong>-></strong><a href="http://www.php.net/crc32">crc32</a><strong>)</strong>;<a name="a538"></a><br />538 <strong>$ret</strong> .= <a href="http://www.php.net/pack">pack</a><strong>(</strong><font color="#66cccc">'V'</font><strong>,</strong> <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$size">size</a><strong>)</strong>;<a name="a539"></a><br />539 <strong>}</strong><a name="a540"></a><br />540 else <strong>{</strong><a name="a541"></a><br />541 <font color="green">// We need to uncompress :(</font><a name="a542"></a><br />542 <strong>$ret</strong> = <a href="http://www.php.net/gzuncompress">gzuncompress</a><strong>(</strong><strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a><strong>)</strong>;<a name="a543"></a><br />543 <strong>}</strong><a name="a544"></a><br />544 <strong>}</strong><a name="a545"></a><br />545 else <strong>{</strong><a name="a546"></a><br />546 <strong>$ret</strong> = <strong>$this</strong><strong>-></strong><a href="../AlberT-cache/AlberTcache.html#var$gzcont">gzcont</a>;<a name="a547"></a><br />547 <strong>}</strong><a name="a548"></a><br />548 <strong>}</strong><a name="a549"></a><br />549 <font color="blue">return</font> <strong>$ret</strong>;<a name="a550"></a><br />550 <strong>}</strong><a name="a551"></a><br />551 <strong>}</strong><a name="a552"></a><br />552 <a name="a553"></a><br />553 new <a href="../AlberT-cache/AlberTcache.html#methodAlberTcache">AlberTcache</a>;<a name="a554"></a><br />554 <strong>?></strong></pre>
<div id="credit">
<hr />
Documentation generated on Wed, 15 Dec 2004 15:11:09 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a>
</div>
</body>
</html>