/*
This script remove folders older than $default_days
*/
$temp_folder = "./temporary_files/";
$default_days = 90;
$phpver = phpversion();
$phpver = doubleval($phpver[0].".".$phpver[2]);
if($phpver >= 4.1) extract($_POST);
function RmdirR($location) {
if (substr($location,-1) <> "/") $location = $location."/";
$all=opendir($location);
while ($file=readdir($all)) {
if (is_dir($location.$file) && $file <> ".." && $file <> ".") {
RmdirR($location.$file);
unset($file);
} elseif (!is_dir($location.$file)) {
unlink($location.$file);
unset($file);
}
}
closedir($all);
unset($all);
rmdir($location);
}
function GetLastModifiedR($location) {
if (substr($location,-1) <> "/") $location = $location."/";
$all=opendir($location);
$lasMod = filemtime($location.$file);
while ($file=readdir($all)) {
if($file != ".." && $file != ".") {
if (is_dir($location.$file)) {
$curMod = GetLastModifiedR($location.$file);
} else {
$curMod = filemtime($location.$file);
}
if($curMod > $lasMod) $lasMod = $curMod;
}
}
//echo($location." ".$lasMod."
");
closedir($all);
unset($all);
return intval($lasMod);
}
if(isset($apagar)) {
if(is_array($folderList)) {
while(list($key,$folder) = each($folderList)) {
echo("Removendo $folder ... "); RmdirR($folder); echo("OK
");
}
}
}
if(!isset($daysToSearch)) $daysToSearch = $default_days;
?>