|
|
|
@ -6,6 +6,7 @@ class c_cache |
|
|
|
{ |
|
|
|
private $lock; |
|
|
|
private $cacheFile; |
|
|
|
private $scriptChanged; |
|
|
|
|
|
|
|
// generiere den Cache Filename aus dem
|
|
|
|
// 1. script Namen
|
|
|
|
@ -72,16 +73,51 @@ class c_cache |
|
|
|
|
|
|
|
$this->lock = NULL; |
|
|
|
$this->cacheFile = $cacheDir . '/cache_' . $parmStr . '.html'; |
|
|
|
|
|
|
|
if (file_exists ($this->cacheFile)) |
|
|
|
{ |
|
|
|
if (filemtime ($this->cacheFile) < filemtime ($scriptFile)) |
|
|
|
$this->scriptChanged = TRUE; |
|
|
|
else |
|
|
|
{ |
|
|
|
$incFiles = array_unique (array_merge ( |
|
|
|
get_included_files (), get_required_files ())); |
|
|
|
|
|
|
|
foreach ($incFiles as $incFile) |
|
|
|
{ |
|
|
|
if (filemtime ($this->cacheFile) < filemtime ($incFile)) |
|
|
|
{ |
|
|
|
$this->scriptChanged = TRUE; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$this->scriptChanged = FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function check ($interval=0) |
|
|
|
{ |
|
|
|
$scriptFile = HOME . substr ($_SERVER['PHP_SELF'], strlen (URLPATH)); |
|
|
|
|
|
|
|
ob_start (); |
|
|
|
|
|
|
|
if ($interval <= 0) |
|
|
|
{ |
|
|
|
$this->lock = NULL; |
|
|
|
return FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
print "<pre>"; |
|
|
|
var_dump ($this->scriptChanged); |
|
|
|
print "</pre>"; |
|
|
|
|
|
|
|
clearstatcache (); |
|
|
|
if (file_exists ($this->cacheFile) && |
|
|
|
if (! $this->scriptChanged && |
|
|
|
file_exists ($this->cacheFile) && |
|
|
|
time () - filemtime ($this->cacheFile) < $interval) |
|
|
|
{ |
|
|
|
readfile ($this->cacheFile); |
|
|
|
@ -109,10 +145,13 @@ class c_cache |
|
|
|
function update () |
|
|
|
{ |
|
|
|
$page = ob_get_flush (); |
|
|
|
file_put_contents ($this->cacheFile, $page); |
|
|
|
|
|
|
|
if ($this->lock !== NULL) |
|
|
|
{ |
|
|
|
file_put_contents ($this->cacheFile, $page); |
|
|
|
releaseLock ($this->lock); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
?>
|