summaryrefslogtreecommitdiffstats
path: root/include/functions.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2008-06-08 10:09:23 -0700
committerArun Persaud <arun@nubati.net>2008-06-08 10:09:23 -0700
commit02b7328ec7f2c4d9eb7862553da000f386830017 (patch)
tree5dbd61cd5f646627c2d6f2b122c0f78bef2f47b1 /include/functions.php
parent765a4fb590113faa80a8560711f9c89de14a50ba (diff)
downloade-DoKo-02b7328ec7f2c4d9eb7862553da000f386830017.tar.gz
e-DoKo-02b7328ec7f2c4d9eb7862553da000f386830017.tar.bz2
e-DoKo-02b7328ec7f2c4d9eb7862553da000f386830017.zip
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 <arun@nubati.net>
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php24
1 files changed, 24 insertions, 0 deletions
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;
+}
?>