Georg Hopp 18 years ago
parent
commit
91a21fd5b3
  1. 7
      components/personAdmin.php
  2. 10
      config.php
  3. 45
      libs/c_cache.php

7
components/personAdmin.php

@ -12,9 +12,7 @@ ob_start ('ob_gzhandler');
if (! $cache->check (60)) if (! $cache->check (60))
{ {
sleep (10);
$personAdmin->show (); $personAdmin->show ();
$cache->update (); $cache->update ();
} }
else else
@ -22,6 +20,11 @@ else
print "<p>[kein update]<p>"; print "<p>[kein update]<p>";
} }
print "<pre>";
var_dump (get_included_files ());
var_dump (get_required_files ());
print "</pre>";
ob_flush (); ob_flush ();
?> ?>

10
config.php

@ -16,17 +16,15 @@ switch ($_SERVER["HTTP_HOST"])
{ {
// Georgs Testumgebung // Georgs Testumgebung
case 'bilder-workingcopy': case 'bilder-workingcopy':
define ('BASEURL', "http://". $_SERVER['SERVER_NAME'] . "/");
define ('BASESURL', "https://". $_SERVER['SERVER_NAME'] . "/");
define ('URLPATH', '/');
break; break;
// Evolver // Evolver
default: 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 ('IMGURL', BASEURL . 'img/');
define ('LIBURL', BASEURL . 'libs/'); define ('LIBURL', BASEURL . 'libs/');

45
libs/c_cache.php

@ -6,6 +6,7 @@ class c_cache
{ {
private $lock; private $lock;
private $cacheFile; private $cacheFile;
private $scriptChanged;
// generiere den Cache Filename aus dem // generiere den Cache Filename aus dem
// 1. script Namen // 1. script Namen
@ -72,16 +73,51 @@ class c_cache
$this->lock = NULL; $this->lock = NULL;
$this->cacheFile = $cacheDir . '/cache_' . $parmStr . '.html'; $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) function check ($interval=0)
{ {
$scriptFile = HOME . substr ($_SERVER['PHP_SELF'], strlen (URLPATH));
ob_start (); ob_start ();
if ($interval <= 0)
{
$this->lock = NULL;
return FALSE;
}
print "<pre>";
var_dump ($this->scriptChanged);
print "</pre>";
clearstatcache (); clearstatcache ();
if (file_exists ($this->cacheFile) &&
if (! $this->scriptChanged &&
file_exists ($this->cacheFile) &&
time () - filemtime ($this->cacheFile) < $interval) time () - filemtime ($this->cacheFile) < $interval)
{ {
readfile ($this->cacheFile); readfile ($this->cacheFile);
@ -109,9 +145,12 @@ class c_cache
function update () function update ()
{ {
$page = ob_get_flush (); $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);
}
} }
}; };

Loading…
Cancel
Save