From 02b7328ec7f2c4d9eb7862553da000f386830017 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sun, 8 Jun 2008 10:09:23 -0700 Subject: NEW FEATURE: added caching to stats.php since reloading always took a while and things don't really change that much over a day, I added a caching to it. Signed-off-by: Arun Persaud --- include/functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index f8a0da4..8307648 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1071,6 +1071,30 @@ function format_score_table_html($score,$userid) return $output; } +function createCache($content, $cacheFile) +{ + $fp = fopen($cacheFile,"w"); + if($fp) + { + fwrite($fp,$content); + fclose($fp); + } + else + echo "WARNING: couldn't create cache file"; + + return; +} + +function getCache($cacheFile, $expireTime) +{ + if( file_exists($cacheFile) && + filemtime($cacheFile )>( time() - $expireTime ) ) + { + return file_get_contents($cacheFile); + } + + return false; +} ?> -- cgit v1.2.3-18-g5258