<?php
function cache_filename()
{
	$Type = $GLOBALS['Type'];
	$Sous_Type = $GLOBALS['Sous_Type'];
	$request = $_SERVER['REQUEST_URI'];
	$md5 = substr(md5($request.date('Y-m-d')),0,8);
	return '../cache/'.$Type.'-'.$Sous_Type.'-'.$md5.'.cache';
}
function create_cache()
{
	$filename = cache_filename();
	if (!file_exists($filename))
	{
		$GLOBALS['must_save_cache'] = true;
	}
}
function save_cache($data)
{
	$filename = cache_filename();
	$file = fopen($filename, 'w');
	fwrite($file, $data);
	fclose($file);
}
function clear_cache($Type, $Sous_Type)
{
	exec("rm -f ../cache/$Type-$Sous_Type*.*");
}
function get_cache()
{
	$filename = cache_filename();
	if (file_exists($filename))
	{
		$file = fopen($filename, 'r');
		$data = fread($file, filesize($filename));
		fclose($file);
		return $data;
	}
	return null;
}
?>