function deleteOldFiles ($hours = 24,$path) {
if ( $handle = opendir( $path ) ) {
while (false !== ($file = readdir($handle))) {
$filelastmodified = filemtime($path.$file);
if((time()-$filelastmodified) > $hours*3600 && is_file($path.$file))
{
unlink($path.$file);
}
}
closedir($handle);
}
}

Advertisements