file <===========\n $file\n=================================",0,0,3); fclose($file_ptr); if($unserialize) $file=unserialize($file); return $file; } } } function hopp_is_old_cache_file($ttl, $file_name) { $oldtime=time()-filemtime ($file_name); s_log("file_name: $file_name\toldtime: $oldtime",0,0,3); if($oldtime>$ttl) return 1; } function hopp_get_file_name_from_url($host, $url) { return hopp_get_file_name_from_host_and_string($host, $url); } function hopp_get_file_name_from_string($string) { return hopp_get_file_name_from_host_and_string('HOPP', $string); } function hopp_get_file_name_from_host_and_string($host, $string) { $hash_pre=md5($string); //s_log("hash_pre: $hash_pre",0,0,3); return hopp_get_file_name_from_md5($host, $hash_pre); } function hopp_get_file_name_from_md5($host, $hash_pre) { $time_0=s_time(); $subdir=substr($hash_pre,0,__HOPP_BASIC_CACHE_DEPTH); $hash=substr($hash_pre,__HOPP_BASIC_CACHE_DEPTH,32); s_log("MD5\nhash_pre:\t$hash_pre\nsubdir\t\t$subdir\nhash:\t\t$hash",0,0,3); $filename=__HOPP_BASIC_CACHE_DIR_NAME."/$host/$subdir/$hash"; $time_1=s_time(); s_log("Cache Filename Time:\t".($time_1-$time_0),0,0,3); return $filename; } function hopp_check_cache_dir($filename, $hops=0) { if($hops>__HOPP_BASIC_CACHE_DIR_MAX_HOPS) return; if(ereg("\/", $filename)) $dirname=dirname($filename); else $dirname=$filename; s_log("filename: $filename\tdirname: $dirname\thops: $hops",0,0,3); if(!file_exists($dirname)) { if(ereg("\/", $dirname)) hopp_check_cache_dir($dirname, $hops+1); mkdir($dirname, __HOPP_BASIC_CACHE_DIR_MODE); } } //-------------------------------------------------------------------- } //__HOPP_BASIC_CACHE_ ?>