1<?
2$days = 1;
3$dir = dirname ( __FILE__ );
4
5$nofiles = 0;
6
7 if ($handle = opendir($dir)) {
8 while (( $file = readdir($handle)) !== false ) {
9 if ( $file == '.' || $file == '..' || is_dir($dir.'/'.$file) ) {
10 continue;
11 }
12
13 if ((time() - filemtime($dir.'/'.$file)) > ($days *86400)) {
14 $nofiles++;
15 unlink($dir.'/'.$file);
16 }
17 }
18 closedir($handle);
19 echo "Total files deleted: $nofiles \n";
20}
21?>