From a39ec17057ccf486767b5d59cf595a6c650cc7c7 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 3 Aug 2009 21:53:30 +0000 Subject: [PATCH] MINOR batchactions JS fix git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@83594 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- static-main.php | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/static-main.php b/static-main.php index 67aa0c81d..b069b0ec4 100644 --- a/static-main.php +++ b/static-main.php @@ -13,30 +13,37 @@ * to no subdirectory. */ -if (file_exists('../subsites/host-map.php')) { - include_once '../subsites/host-map.php'; - $subsiteHostmap['default'] = isset($subsiteHostmap['default']) ? $subsiteHostmap['default'] : ''; - - // Look for the host, and find the cache dir - $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); - $cacheDir = (isset($subsiteHostmap[$host]) ? $subsiteHostmap[$host] : $subsiteHostmap['default']) . '/'; -} else { - $cacheDir = ''; -} +$cacheOn = true; +$hostmapLocation = '../subsites/host-map.php'; -// Look for the file in the cachedir -$file = preg_replace('/[^a-zA-Z0-9]/si', '_', trim($_SERVER['REQUEST_URI'], '/')); -$file = $file ? $file : 'index'; +if ($cacheOn) { + if (file_exists($hostmapLocation)) { + include_once $hostmapLocation; + $subsiteHostmap['default'] = isset($subsiteHostmap['default']) ? $subsiteHostmap['default'] : ''; -if (file_exists('../cache/'.$cacheDir.$file.'.html')) { - header('X-cache: hit at '.date('r')); - echo file_get_contents('../cache/'.$cacheDir.$file.'.html'); -} elseif (file_exists('../cache/'.$cacheDir.$file.'.php')) { - header('X-cache: hit at '.date('r')); - include_once '../cache/'.$cacheDir.$file.'.php'; + // Look for the host, and find the cache dir + $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); + $cacheDir = (isset($subsiteHostmap[$host]) ? $subsiteHostmap[$host] : $subsiteHostmap['default']) . '/'; + } else { + $cacheDir = ''; + } + + // Look for the file in the cachedir + $file = preg_replace('/[^a-zA-Z0-9]/si', '_', trim($_SERVER['REQUEST_URI'], '/')); + $file = $file ? $file : 'index'; + + if (file_exists('../cache/'.$cacheDir.$file.'.html')) { + header('X-cache: hit at '.date('r')); + echo file_get_contents('../cache/'.$cacheDir.$file.'.html'); + } elseif (file_exists('../cache/'.$cacheDir.$file.'.php')) { + header('X-cache: hit at '.date('r')); + include_once '../cache/'.$cacheDir.$file.'.php'; + } else { + header('X-cache: miss at '.date('r') . ' on ' . $cacheDir . $file); + // No cache hit... fallback!!! + include 'main.php'; + } } else { - header('X-cache: miss at '.date('r')); - // No cache hit... fallback!!! include 'main.php'; }