Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Destroy old files from selected dir
- ///$dir — directory to process
- ///$old — time of life for one file, in seconds
- function destroy($dir, $old) {
- $mydir = opendir($dir);
- while($file = readdir($mydir)) {
- if($file != "." && $file != "..") {
- chmod($dir.$file, 0777);
- if(is_dir($dir.$file)) {
- chdir('.');
- while($dir.$file) {
- if(date("U",filectime($file) >= time() - $old)
- {
- unlink($dir.$file)
- }
- }
- }
- else
- unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
- }
- }
- closedir($mydir);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement