* 11 Jan 2004 */ /* file_get_contents was only introduced in php 4.3.0 */ if (!function_exists("file_get_contents")) { function file_get_contents($filename, $use_include_path = 0) { $data = ""; // just to be safe. Dunno, if this is really needed $file = @fopen($filename, "rb", $use_include_path); if ($file) { while (!feof($file)) $data .= fread($file, 1024); fclose($file); } return $data; } } /** * Includes and caches a file. */ function include_cache($name, $source) { global $basepath; /* basepath set by php scripts not appearing in root directory */ if (!isset($basepath)) { $basepath = "./"; } include($source); return /*********/ /* check for existing cache */ $cachefile = $basepath."cache/$name"; if (file_exists($cachefile) && filemtime($cachefile) > (time() - 1800)) { /* half hour */ include $cachefile; } else { /* cache the sourceforge block */ $inc = file_get_contents($source); $cache = @fopen($cachefile, 'w'); if ($cache && !empty($inc)) { if (@fwrite($cache, $inc) === false) { echo "couldn't $cachefile... is the cache directory ". "writeable by the web server?
"; } fclose($cache); } else { echo "couldn't open $cachefile for writing
"; } echo $inc; } } /* include_cache */