rendered paste body<?php /*** NovaKing Code ***/ // EZTV Image Pruner $cache_folder = "/path/to/folder"; $comparedate = time(); //I run the function here to start the search. directory_tree( $cache_folder, $comparedate ); //This is the function which is doing the search... function directory_tree( $address, $comparedate ) { @$dir = opendir( $address ); if( !$dir ) return 0; while( $entry = readdir( $dir ) ) { if( is_dir( "$address/$entry" ) && ( $entry != ".." && $entry != "." ) ) { // Recursive search (should never trigger) directory_tree( "$address/$entry", $comparedate ); } else { if( $entry != ".." && $entry != "." ) { $fulldir = $address . "/" . $entry; $last_modified = filemtime( $fulldir ); // Cache file for 30 days only then delete if( ( $comparedate - $last_modified ) > 2592000 ) unlink( $fulldir ); } } } }?>