From 498151c36083d6ce1fa8bc3cb9ba5d8b7469332c Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Sat, 30 Mar 2013 21:09:47 +0530 Subject: [PATCH] cache --- cache/.htaccess | 4 ++++ index.php | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 cache/.htaccess diff --git a/cache/.htaccess b/cache/.htaccess new file mode 100644 index 00000000..d87fe95b --- /dev/null +++ b/cache/.htaccess @@ -0,0 +1,4 @@ + +Order allow,deny +Deny from all + \ No newline at end of file diff --git a/index.php b/index.php index 25e4a9d6..325708be 100644 --- a/index.php +++ b/index.php @@ -43,9 +43,25 @@ else { die('Security: Please activate security class!'); } + +$cachefile = 'cache/'.basename($_SERVER['PHP_SELF']).'.cache'; // e.g. cache/index.php.cache +$cachetime = 3600; // time to cache in seconds + +if(file_exists($cachefile) && time()-$cachetime <= filemtime($cachefile)){ + $c = @file_get_contents($cf); + echo $c; + exit; +}else{ + unlink($cachefile); +} + +ob_start(); + include ("GameEngine/Database.php"); include ("GameEngine/Lang/".LANG.".php"); + ?> + @@ -272,4 +288,10 @@ include ("GameEngine/Lang/".LANG.".php"); var galarie = new Fx.Screenshots('screen_view', 'screen_hl', 'screen_desc', screenshots); - \ No newline at end of file + + \ No newline at end of file