$dir = opendir($directory); Read an entry from the
$dir = opendir($directory); Read an entry from the directory handle: while (($file = readdir($dir))) { If the read entry is a file, then delete the file if it has not been accessed in the last ten days: if (is_file($directory . “/” . $file)) { $accessTime = fileaTime($directory . “/” .$file); $time = time(); if (($time - $accessTime) > 10*24*60*60) { if (unlink($directory . “/” .$file)) { printf(”File %s is removed from %s directory
n”, $file, $directory); } } If the read entry is a directory, then call the function again with the read entry as its argument. Here, we use the recursive cleanTemporaryFiles() function. Note that we do not call the function again if the read entry is “.” or “..”: } else if (is_dir($directory . “/” .$file) && ($file != “.”) && ($file != “..”)) { cleanTemporaryFiles($directory . “/” . $file); } } Close the directory: closedir($dir); } cleanTemporaryFiles(”c:/temp”); ?>