comparison CacheTimeCheck.inc @ 40:fbbb82ced6de

Fixes for CacheTimeCheck->includeOnce paths.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Fri, 05 Oct 2012 00:41:30 +0200
parents bd82b719a0de
children 66382989353f
comparison
equal deleted inserted replaced
39:bd82b719a0de 40:fbbb82ced6de
25 { 25 {
26 if (DEBUG_LEVEL >= VERBOSITY_DEBUG) 26 if (DEBUG_LEVEL >= VERBOSITY_DEBUG)
27 var_dump($_SERVER); 27 var_dump($_SERVER);
28 28
29 $gmdate_mod = gmdate('D, d M Y H:i:s', $this->newest) . ' GMT'; 29 $gmdate_mod = gmdate('D, d M Y H:i:s', $this->newest) . ' GMT';
30 30
31 if(array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { 31 if(array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
32 $HTTP_IF_MODIFIED_SINCE = $_SERVER['HTTP_IF_MODIFIED_SINCE']; 32 $HTTP_IF_MODIFIED_SINCE = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
33 $if_modified_since = preg_replace('/;.*$/', '', $HTTP_IF_MODIFIED_SINCE); 33 $if_modified_since = preg_replace('/;.*$/', '', $HTTP_IF_MODIFIED_SINCE);
34 34
35 if (strtotime($if_modified_since) >= $this->newest) { 35 if (strtotime($if_modified_since) >= $this->newest) {
39 } 39 }
40 40
41 header("Last-Modified: $gmdate_mod"); 41 header("Last-Modified: $gmdate_mod");
42 } 42 }
43 43
44 function cache_time($path) 44 function cache_time($path, $basedir = False)
45 { 45 {
46 if (!file_exists($path)) { 46 if (!file_exists($path)) {
47 if (DEBUG) 47 if (DEBUG_LEVEL >= VERBOSITY_WARNING)
48 print "${path} does not exist"; 48 print "${path} does not exist";
49 var_dump($_SERVER);
49 errorPage("Resource not available"); 50 errorPage("Resource not available");
50 } 51 }
51 52
52 array_push($this->files, $path); 53 array_push($this->files, $path);
53 $mtime = filemtime($path); 54 $mtime = filemtime($path);
54 if ($mtime > $this->newest) { 55 if ($mtime > $this->newest) {
55 $this->newest = $mtime; 56 $this->newest = $mtime;
56 } 57 }
57 } 58 }
58 59
59 function includeOnce($path) 60 function includeOnce($path, $basedir = false)
60 { 61 {
62 if ($basedir)
63 $path = $basedir . "/" . $path;
61 $this->cache_time($path); 64 $this->cache_time($path);
62 include_once($path); 65 include_once($path);
63 } 66 }
64 67
65 function loadFile($path) 68 function loadFile($path)