NEW FEATURE: added caching to stats.php
[e-DoKo.git] / include / functions.php
index f8a0da4e58d7e4faf1121a6eb44f707a9bb66899..8307648975873ed49ddfb4bf66e0ec7fb0e193e7 100644 (file)
@@ -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;
+}
 
 
 ?>