Commit 91a21fd5b34ca1ec04959e878ae9204056d9fd4f

Authored by Georg Hopp
1 parent e3977133

--no commit message

... ... @@ -12,9 +12,7 @@ ob_start ('ob_gzhandler');
12 12
13 13 if (! $cache->check (60))
14 14 {
15   - sleep (10);
16 15 $personAdmin->show ();
17   -
18 16 $cache->update ();
19 17 }
20 18 else
... ... @@ -22,6 +20,11 @@ else
22 20 print "<p>[kein update]<p>";
23 21 }
24 22
  23 +print "<pre>";
  24 +var_dump (get_included_files ());
  25 +var_dump (get_required_files ());
  26 +print "</pre>";
  27 +
25 28 ob_flush ();
26 29
27 30 ?>
... ...
... ... @@ -16,17 +16,15 @@ switch ($_SERVER["HTTP_HOST"])
16 16 {
17 17 // Georgs Testumgebung
18 18 case 'bilder-workingcopy':
19   - define ('BASEURL', "http://". $_SERVER['SERVER_NAME'] . "/");
20   - define ('BASESURL', "https://". $_SERVER['SERVER_NAME'] . "/");
  19 + define ('URLPATH', '/');
21 20 break;
22 21
23 22 // Evolver
24 23 default:
25   - define ('BASEURL',
26   - "http://" . $_SERVER["HTTP_HOST"] . "/~georg/bilder/");
27   - define ('BASESURL',
28   - "https://" . $_SERVER["HTTP_HOST"] . "/~georg/bilder/");
  24 + define ('URLPATH', '/~georg/bilder/');
29 25 }
  26 +define ('BASEURL', "http://" . $_SERVER["HTTP_HOST"] . URLPATH);
  27 +define ('BASESURL', "https://" . $_SERVER["HTTP_HOST"] . URLPATH);
30 28
31 29 define ('IMGURL', BASEURL . 'img/');
32 30 define ('LIBURL', BASEURL . 'libs/');
... ...
... ... @@ -6,6 +6,7 @@ class c_cache
6 6 {
7 7 private $lock;
8 8 private $cacheFile;
  9 + private $scriptChanged;
9 10
10 11 // generiere den Cache Filename aus dem
11 12 // 1. script Namen
... ... @@ -72,16 +73,51 @@ class c_cache
72 73
73 74 $this->lock = NULL;
74 75 $this->cacheFile = $cacheDir . '/cache_' . $parmStr . '.html';
  76 +
  77 + if (file_exists ($this->cacheFile))
  78 + {
  79 + if (filemtime ($this->cacheFile) < filemtime ($scriptFile))
  80 + $this->scriptChanged = TRUE;
  81 + else
  82 + {
  83 + $incFiles = array_unique (array_merge (
  84 + get_included_files (), get_required_files ()));
  85 +
  86 + foreach ($incFiles as $incFile)
  87 + {
  88 + if (filemtime ($this->cacheFile) < filemtime ($incFile))
  89 + {
  90 + $this->scriptChanged = TRUE;
  91 + break;
  92 + }
  93 + }
  94 +
  95 + $this->scriptChanged = FALSE;
  96 + }
  97 + }
75 98 }
76 99
77 100
78 101
79 102 function check ($interval=0)
80 103 {
  104 + $scriptFile = HOME . substr ($_SERVER['PHP_SELF'], strlen (URLPATH));
  105 +
81 106 ob_start ();
82 107
  108 + if ($interval <= 0)
  109 + {
  110 + $this->lock = NULL;
  111 + return FALSE;
  112 + }
  113 +
  114 + print "<pre>";
  115 + var_dump ($this->scriptChanged);
  116 + print "</pre>";
  117 +
83 118 clearstatcache ();
84   - if (file_exists ($this->cacheFile) &&
  119 + if (! $this->scriptChanged &&
  120 + file_exists ($this->cacheFile) &&
85 121 time () - filemtime ($this->cacheFile) < $interval)
86 122 {
87 123 readfile ($this->cacheFile);
... ... @@ -109,9 +145,12 @@ class c_cache
109 145 function update ()
110 146 {
111 147 $page = ob_get_flush ();
112   - file_put_contents ($this->cacheFile, $page);
113 148
114   - releaseLock ($this->lock);
  149 + if ($this->lock !== NULL)
  150 + {
  151 + file_put_contents ($this->cacheFile, $page);
  152 + releaseLock ($this->lock);
  153 + }
115 154 }
116 155 };
117 156
... ...
Please register or login to post a comment