--- /dev/null
+<?php
+require_once('functions.php');
+define('CACHE_DIR',"/tmp/cache.php");
+if (!file_exists(CACHE_DIR)) mkdir(CACHE_DIR,7770);
+
+function cache_get_file($id,$expires) {
+ $file = CACHE_DIR."$id.cache";
+ if (!file_exists($file)) return null;
+
+ $content = file_get_contents($file);
+ if ( filectime($file) < (time()-$expires) ) @unlink($file);
+
+ return $content;
+
+}
+
+function cache_set_file($id,$content) {
+ $file = CACHE_DIR."/$id.cache";
+
+ if (!$ftmp = fopen($file,'w')) {
+ debug("Can't write into $file");
+ return;
+ }
+
+ if (fwrite($ftmp,$content) === FALSE) {
+ debug("Can't write into $file");
+ return;
+ }
+
+ fclose($ftmp);
+ return $file;
+}
+?>