diff --git a/components/personAdmin.php b/components/personAdmin.php index fbc41dd..a808d13 100644 --- a/components/personAdmin.php +++ b/components/personAdmin.php @@ -12,9 +12,7 @@ ob_start ('ob_gzhandler'); if (! $cache->check (60)) { - sleep (10); $personAdmin->show (); - $cache->update (); } else @@ -22,6 +20,11 @@ else print "

[kein update]

"; } +print "

";
+var_dump (get_included_files ());
+var_dump (get_required_files ());
+print "
"; + ob_flush (); ?> diff --git a/config.php b/config.php index d163e20..d029c25 100644 --- a/config.php +++ b/config.php @@ -16,17 +16,15 @@ switch ($_SERVER["HTTP_HOST"]) { // Georgs Testumgebung case 'bilder-workingcopy': - define ('BASEURL', "http://". $_SERVER['SERVER_NAME'] . "/"); - define ('BASESURL', "https://". $_SERVER['SERVER_NAME'] . "/"); + define ('URLPATH', '/'); break; // Evolver default: - define ('BASEURL', - "http://" . $_SERVER["HTTP_HOST"] . "/~georg/bilder/"); - define ('BASESURL', - "https://" . $_SERVER["HTTP_HOST"] . "/~georg/bilder/"); + define ('URLPATH', '/~georg/bilder/'); } +define ('BASEURL', "http://" . $_SERVER["HTTP_HOST"] . URLPATH); +define ('BASESURL', "https://" . $_SERVER["HTTP_HOST"] . URLPATH); define ('IMGURL', BASEURL . 'img/'); define ('LIBURL', BASEURL . 'libs/'); diff --git a/libs/c_cache.php b/libs/c_cache.php index 17dcb96..c9697dd 100644 --- a/libs/c_cache.php +++ b/libs/c_cache.php @@ -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 "
";
+		var_dump ($this->scriptChanged);
+		print "
"; + clearstatcache (); - if (file_exists ($this->cacheFile) && + if (! $this->scriptChanged && + file_exists ($this->cacheFile) && time () - filemtime ($this->cacheFile) < $interval) { readfile ($this->cacheFile); @@ -109,9 +145,12 @@ class c_cache function update () { $page = ob_get_flush (); - file_put_contents ($this->cacheFile, $page); - releaseLock ($this->lock); + if ($this->lock !== NULL) + { + file_put_contents ($this->cacheFile, $page); + releaseLock ($this->lock); + } } };