Return to Snippet

Revision: 13586
at April 28, 2009 13:48 by Keef


Initial Code
function download($url, $cache_time=0)
{
	$cache_file = sys_get_temp_dir(). '/'. sha1($url);
	
	if (file_exists($cache_file) && (time() - @filemtime($cache_file) < $cache_time))
	{
		$file = file_get_contents($cache_file);
	} else {
		$file = file_get_contents($url);
		file_put_contents($cache_file, $file);
	}
	
	return $file;
}

Initial URL

                                

Initial Description

                                

Initial Title
Simple download page with cache

Initial Tags

                                

Initial Language
PHP