Location: PHPKode > projects > HAE > hae/admin/verifycache.php
<?php
/*
	Copyright 2007 Hugo Wood

    This file is part of HAE.

    HAE is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    HAE is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/.
*/
?>

<?php
$i = 0;
$rec = '../../';
verifycache('../cache/24/', '', $rec);
echo "<br /><br />24px cache checked!<br /><br /><br />\n";
verifycache('../cache/64/', '', $rec);
echo "<br /><br />64px cache checked!<br /><br /><br />\n";
verifycache('../cache/128/', '', $rec);
echo "<br /><br />128px cache checked!<br /><br /><br />\n";
verifycache('../cache/192/', '', $rec);
echo "<br /><br />192px cache checked!<br /><br /><br />\n";

function verifycache($dir, $path2, $rec) {
  global $i;
  $path1 = $dir;
  $dir = opendir($dir);
  while($f = readdir($dir)) {
    if($f==".") {
    }
    elseif($f=="..") {
    }
    elseif(is_dir($path1.$f)) {
      echo 'XX) Folder : ',$path1,$f,"/<br />\n";
      if(is_dir($rec.$path2.$f)==false) {
        if(rmdir($path1.$f)==true){
          echo 'Folder ',$rec,$path2,$f," was not found, its cache equivalent was deleted<br /><br />\n";
        }
        else {
          //echo 'dossier : ',$rec,$path2,$f," inexistant, le dossier du cache n'a pas pu etre supprimé il n'est pas vide<br /><br />\n";
          deletedir($path1.$f.'/');
        }
      }
      else {
        verifycache($path1.$f.'/', $path2.$f.'/', $rec);
      }
    }
    elseif(is_file($path1.$f)) {
      echo $i.") ".$path1.$f,"<br />\n";
      $i++;
      $f = substr($f, 0, count($f)-5);
      if (file_exists($rec.$path2.$f)==false) {
        unlink($path1.$f.'.png');
        echo "File ".$rec.$path2.$f," was not found, thumbnail deleted<br /><br />\n";
      }
    }
  }
  closedir($dir);
}

function deletedir($dir) {
  $path1 = $dir;
  $dir = opendir($dir);
  while($f = readdir($dir)) {
    if($f==".") {
    }
    elseif($f=="..") {
    
    }
    elseif(is_dir($path1.$f)) {
      if(rmdir($path1.$f)==false){
        deletedir($path1.$f.'/');
      }
    }
    elseif(is_file($path1.$f)) {
      unlink($path1.$f);
    }
  }
}
?>
Return current item: HAE