function tryCache ( ) { #---------------------------------------------------------------------- global $cacheFile, $config; #--- Build whole cacheId $cacheIdParts = func_get_args(); # indirect because direct usage results in error before PHP 5.3 (see documentation) $cacheId = implode( '_', $cacheIdParts ); #--- If cacheId is invalid, then don't use the cache if ( ! preg_match( '/^\w+$/', $cacheId ) ) { cacheLog( "invalid: $cacheId" ); return; } #--- If debugging or caching disabled, then don't use the cache if ( wcaDebug() || paramExists('nocache') ) { cacheLog( "debug/noCache: $cacheId" ); return; } #--- If it's in the cache already, then just deliver from cache and exit $cacheFile = $config->get('filesPath') . "generated/cache/$cacheId.cache"; if ( file_exists( $cacheFile ) ) { echo "<!-- rfc -->\n"; echo file_get_contents( $cacheFile ); cacheLog( "use: $cacheId\t" . filesize($cacheFile) ); exit; } #--- Otherwise, start recording for the cache ob_start(); }
function get_GET($key, $regexp = null) { if (!paramExists($key)) { return null; } else { $GET = getRawParamsThisShouldBeAnException(); if ($regexp) { return preg_replace($regexp, '', $GET[$key]); } else { return $GET[$key]; } } }