Location: PHPKode > projects > phpCAMALEO > common/fun2inc/cleanup_tmpdir.inc
<?php
if(!function_exists('cleanup_tmpdir'))
{
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Clean the TMP directory
	#
	function cleanup_tmpdir($days=2,$dir='')
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		if($dir=='') { $dir=$_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'tmp/'; } # 9 Oct 2006
		$old=$days*86400;
		$today=time();
		$dd=@opendir($dir) || die('(cleanup_tmpdir.inc) Impossible to read directory: '.$dir);
		while($dir_entry=@readdir($dd))
		{
			if($dir_entry!='.' && $dir_entry!='..')
			{
				$tmp=explode('.',$dir_entry);
				$ext=$tmp[count($tmp)-1];
				switch($ext)
				{
					case 'gz':
					case 'png':
						$check=$today-filemtime($dir.'/'.$dir_entry);
						if($check>=$old) { @unlink($dir.'/'.$dir_entry); }
						break;
				}
			}
		}
		@closedir($dd);
	}
}
?>
Return current item: phpCAMALEO