View Single Post
Old 10-21-2009, 01:54 PM  
AIbenjamink
Confirmed User
 
AIbenjamink's Avatar
 
Industry Role:
Join Date: Jan 2009
Posts: 420
Here you go. Hasn't been tested:

PHP Code:
$dir '/www/';
$Files=array();

if (
$handle opendir($dir)) {

  while (
false !== ($file readdir($handle))) {
    if (
$file[0] == '.' || is_dir("$dir/$file")) {
      continue;
    }
    if ((
time() - filemtime($file)) > ($days *86400)) { //7 days
      //unlink("$dir/$file");
      
$Files[$dir/$file]=filemtime($file);
    }
  }
  
closedir($handle);

  
//Sort the array by file modified times, reverse sort
  
arsort($Files);

  
//Remove the newest 3 files from the array
  
$Files=array_slice($Files3);

  
//Remove the remainder of files
  
foreach($Files as $FilePath=>$ModifiedTime)
  {
      
unlink($FilePath);
  }

__________________
Benjamin : [email protected] : 405-243-447 : www.AdultInterface.com

AIbenjamink is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote