Changeset - 62c4a09ec38f
[Not reviewed]
default
0 1 0
Ethan Zonca - 15 years ago 2010-12-23 21:30:01
ez@ethanzonca.com
Date-based deletion should now work (still in pretend mode)
1 file changed with 14 insertions and 6 deletions:
admin.php
14
6
0 comments (0 inline, 0 general)
admin.php
Show inline comments
 
@@ -37,8 +37,14 @@
 
    exit;
 
  }
 

	
 
  function isBeforeDate($first, $reference) {
 
   return true; 
 
  function isBeforeDate($toCheck, $reference) {
 
    $formatted = date("Y-m-d", $toCheck);
 
    $refUnix = strtotime($reference);
 

	
 
    if($toCheck < $refUnix) {
 
      return true;
 
    }
 
    return false; 
 
  }
 

	
 
  function emptySavedDir($todate = null) {
 
@@ -51,11 +57,13 @@
 
   
 
    // Do this the new fun php5 OO-way
 
    foreach(new DirectoryIterator($dir) as $file) {
 
      $isBeforeDate = isBeforeDate($file->getCTime, $todate);
 
      if(!$todate || $isBeforeDate) {
 
        if(is_numeric($file->getFilename())){
 
      if(is_numeric($file->getFilename())){
 
        $isBeforeDate = isBeforeDate($file->getCTime(), $todate);
 

	
 
        if(!$todate || $isBeforeDate) {
 
          // unlink($dir . '/' . $file->getFilename());
 
          echo "<p>Erased file: " . $dir . '/' . $file->getFilename() . "</p>";
 
          $date = date("Y-m-d",$file->getCTime());
 
          echo "<p>Erased file: " . $dir . '/' . $file->getFilename() . " ({$date})</p>";
 
        } 
 
      }
 
    }
0 comments (0 inline, 0 general)