<?php $path = каталог; $age_days = кол-во дней считать старыми; function delete_old_files($path, $age_days) { if ($handle = opendir($path)) { while (false !== ($fil = readdir($handle))) { if ($fil != "." && $fil != "..") { clearstatcache(); $fn = $path."/".$fil; if (is_dir($fn)) continue; $diff = floor((time()-filemtime($fn))/(24*3600)); if ($diff>=$age_days) { @unlink($fn); } } } closedir($handle); } } ?>