class Cache {
var $_file = '';
var $_cacheFile = '';
function Cache($file, $cacheFile = false) {
$this->_file = $file;
$this->_cacheFile = ($cacheFile) ? $cacheFile : str_replace('.php', '.cache', $file);
}
function Fetch() {
if (file_exists('/cache/'.$this->_cacheFile))
return '
CACHED FILE:
'.file_get_contents('/cache/'.$this->_cacheFile).'END CACHED FILE
';
else {
ob_start();
require($this->_file);
$buffer = ob_get_contents();
ob_end_clean();
$file = fopen('/cache/'.$this->_cacheFile, 'wb');
fwrite($file, $buffer);
fclose($file);
return $buffer;
}
}
function Display() {
echo $this->Fetch();
}
function GetContents() {
return $this->Fetch();
}
}
?>