OpenSencillo
2015.002
|
Go to the source code of this file.
Functions | |
quickcache_debug ($s) | |
quickcache_key () | |
quickcache_varkey () | |
quickcache_scriptkey () | |
quickcache_check () | |
quickcache_encoding () | |
quickcache_init () | |
quickcache_gc () | |
quickcache_start () | |
quickcache_end ($contents) | |
quickcache_flush ($gzdata, $datasize, $datacrc) |
quickcache_check | ( | ) |
Definition at line 86 of file cache_main.php.
{ if (!$GLOBALS["QUICKCACHE_ON"]) { quickcache_debug("Cache has been disabled!"); return false; } // We need to set this global, as ob_start only calls the given method // with no parameters. $GLOBALS["quickcache_key"] = quickcache_key(); // Can we read the cached data for this key ? if (quickcache_restore()) { quickcache_debug("Cachedata for ".$GLOBALS["quickcache_key"]." found, data restored"); return true; } else { // No cache data (yet) or unable to read quickcache_debug("No (valid) cachedata for ".$GLOBALS["quickcache_key"]); return false; } }
quickcache_debug | ( | $ | s | ) |
Definition at line 20 of file cache_main.php.
{ static $quickcache_debugline; if ($GLOBALS["QUICKCACHE_DEBUG"]) { $quickcache_debugline++; header("X-CacheDebug-$quickcache_debugline: $s"); } }
Definition at line 111 of file cache_main.php.
{ if (headers_sent() || connection_aborted()) { return false; } if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"],'x-gzip') !== false) { return "x-gzip"; } if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"],'gzip') !== false) { return "gzip"; } return false; }
quickcache_end | ( | $ | contents | ) |
Definition at line 207 of file cache_main.php.
{ quickcache_debug("Callback happened"); $datasize = strlen($contents); $datacrc = crc32($contents); if ($GLOBALS["QUICKCACHE_USE_GZIP"]) { $gzdata = gzcompress($contents, $GLOBALS["QUICKCACHE_GZIP_LEVEL"]); } else { $gzdata = $contents; } // If the connection was aborted, do not write the cache. // We don't know if the data we have is valid, as the user // has interupted the generation of the page. // Also check if quickcache is not disabled if ((!connection_aborted()) && $GLOBALS["QUICKCACHE_ON"] && ($GLOBALS["QUICKCACHE_TIME"] >= 0)) { quickcache_debug("Writing cached data to storage"); // write the cache with the current data quickcache_write($gzdata, $datasize, $datacrc); } // Handle type-specific additional code if required quickcache_do_end(); // Return flushed data return quickcache_flush($gzdata, $datasize, $datacrc); }
quickcache_flush | ( | $ | gzdata, |
$ | datasize, | ||
$ | datacrc | ||
) |
Definition at line 246 of file cache_main.php.
{ // First check if we can send last-modified $myETag = "\"qcd-$datacrc.$datasize\""; header("ETag: $myETag"); $foundETag = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? stripslashes($_SERVER["HTTP_IF_NONE_MATCH"]) : ""; $ret = NULL; if (strstr($foundETag, $myETag)) { // Not modified! if(stristr($_SERVER["SERVER_SOFTWARE"], "microsoft")) { // IIS has already sent a HTTP/1.1 200 by this stage for // some strange reason header("Status: 304 Not Modified"); } else { if ( $QUICKCACHE_ISCGI ) { header('Status: 304 Not Modified'); } else { header('HTTP/1.0 304'); } } } else { // Are we gzipping ? if ($GLOBALS["QUICKCACHE_USE_GZIP"]) { $ENCODING = quickcache_encoding(); if ($ENCODING) { // compressed output: set header. Need to modify, as // in some versions, the gzipped content is not what // your browser expects. header("Content-Encoding: $ENCODING"); $ret = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; $ret .= substr($gzdata, 0, strlen($gzdata) - 4); $ret .= pack('V',$datacrc); $ret .= pack('V',$datasize); } else { // Darn, we need to uncompress :( $ret = gzuncompress($gzdata); } } else { // So content isn't gzipped either $ret=$gzdata; } } return $ret; }
quickcache_gc | ( | ) |
Definition at line 157 of file cache_main.php.
{ // Should we garbage collect ? if ($GLOBALS["QUICKCACHE_GC"]>0) { mt_srand(time(NULL)); $precision=100000; // Garbagecollection probability if (((mt_rand()%$precision)/$precision) <= ($GLOBALS["QUICKCACHE_GC"]/100)) { quickcache_debug("GarbageCollection hit!"); quickcache_do_gc(); } } }
quickcache_init | ( | ) |
Definition at line 127 of file cache_main.php.
{ // Override default QUICKCACHE_TIME ? if (isset($GLOBALS["cachetimeout"])) { $GLOBALS["QUICKCACHE_TIME"]=$GLOBALS["cachetimeout"]; } // Force gzip off if gzcompress does not exist if (!function_exists('gzcompress')) { $GLOBALS["QUICKCACHE_USE_GZIP"] = 0; } // Force cache off when POST occured when you don't want it cached if (!$GLOBALS["QUICKCACHE_POST"] && (count($_POST) > 0)) { $GLOBALS["QUICKCACHE_ON"] = 0; $GLOBALS["QUICKCACHE_TIME"] = -1; } // A cachetimeout of -1 disables writing, only ETag and content encoding if ($GLOBALS["QUICKCACHE_TIME"] == -1) { $GLOBALS["QUICKCACHE_ON"] = 0; } // Output header to recognize version header("X-Cache: QuickCache v".$GLOBALS["QUICKCACHE_VERSION"]. " - ".$GLOBALS["QUICKCACHE_TYPE"]); }
quickcache_key | ( | ) |
Definition at line 33 of file cache_main.php.
{ if ($GLOBALS["QUICKCACHE_CLEANKEYS"]) { $key = eregi_replace("[^A-Z,0-9,=]", "_", quickcache_scriptkey()); $key .= ".".eregi_replace("[^A-Z,0-9,=]", "_", quickcache_varkey()); if (strlen($key) > 255) { // Too large, fallback to md5! $key = md5(quickcache_scriptkey().quickcache_varkey()); } } else { $key = md5(quickcache_scriptkey().quickcache_varkey()); } quickcache_debug("Cachekey is set to $key"); return $key; }
Definition at line 66 of file cache_main.php.
{ // These should be available, unless running commandline if ($GLOBALS["QUICKCACHE_IGNORE_DOMAIN"]) { $name=$_SERVER["PHP_SELF"]; } else { $name=$_SERVER["SCRIPT_URI"]; } // Commandline mode will also fail this one, I'm afraid, as there is no // way to determine the scriptname if ($name=="") { $name="http://".$_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"]; } quickcache_debug("Cache scriptkey is set to $name"); return $name; }
quickcache_start | ( | ) |
Definition at line 175 of file cache_main.php.
{ // Initialize cache quickcache_init(); // Handle type-specific additional code if required quickcache_do_start(); // Check cache if (quickcache_check()) { // Cache is valid and restored: flush it! print quickcache_flush($GLOBALS["quickcachedata_gzdata"], $GLOBALS["quickcachedata_datasize"], $GLOBALS["quickcachedata_datacrc"]); // Handle type-specific additional code if required quickcache_do_end(); exit; } else { // if we came here, cache is invalid: go generate page // and wait for quickcache_end() which will be called automagically // Check garbagecollection quickcache_gc(); // Go generate page and wait for callback ob_start("quickcache_end"); ob_implicit_flush(0); } }
Definition at line 53 of file cache_main.php.
{ $varkey = ""; if ($GLOBALS["QUICKCACHE_POST"]) { $varkey = "POST=".serialize($_POST); } $varkey .= "GET=".serialize($_GET); quickcache_debug("Cache varkey is set to $varkey"); return $varkey; }