[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_handlers/ -> file_class.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_handlers/file_class.php,v $
  14  |     $Revision: 1.13 $
  15  |     $Date: 2006/10/26 23:36:27 $
  16  |     $Author: e107coders $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  if (!defined('e107_INIT')) { exit; }
  21  
  22  class e_file
  23  {
  24  	function get_files($path, $fmask = '', $omit='standard', $recurse_level = 0, $current_level = 0)
  25      {
  26          $ret = array();
  27          if($recurse_level != 0 && $current_level > $recurse_level)
  28          {
  29              return $ret;
  30          }
  31          if(substr($path,-1) == '/')
  32          {
  33              $path = substr($path, 0, -1);
  34          }
  35  
  36          if(!$handle = opendir($path))
  37          {
  38              return $ret;
  39          }
  40          if($omit == 'standard')
  41          {
  42              $rejectArray = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','^\.htaccess$','index\.html','null\.txt');
  43          }
  44          else
  45          {
  46              if(is_array($omit))
  47              {
  48                  $rejectArray = $omit;
  49              }
  50              else
  51              {
  52                  $rejectArray = array($omit);
  53              }
  54          }
  55          while (false !== ($file = readdir($handle)))
  56          {
  57              if(is_dir($path.'/'.$file))
  58              {
  59                  if($file != '.' && $file != '..' && $file != 'CVS' && $recurse_level > 0 && $current_level < $recurse_level)
  60                  {
  61                      $xx = $this->get_files($path.'/'.$file, $fmask, $omit, $recurse_level, $current_level+1);
  62                      $ret = array_merge($ret,$xx);
  63                  }
  64              }
  65              elseif ($fmask == '' || preg_match("#".$fmask."#", $file))
  66              {
  67                  $rejected = FALSE;
  68  
  69                  foreach($rejectArray as $rmask)
  70                  {
  71                      if(preg_match("#".$rmask."#", $file))
  72                      {
  73                          $rejected = TRUE;
  74                          break;
  75                      }
  76                  }
  77                  if($rejected == FALSE)
  78                  {
  79                      $finfo['path'] = $path."/";  // important: leave this slash here and update other file instead.
  80                      $finfo['fname'] = $file;
  81                      $ret[] = $finfo;
  82                  }
  83              }
  84          }
  85          return $ret;
  86      }
  87  
  88  	function get_dirs($path, $fmask = '', $omit='standard')
  89      {
  90          $ret = array();
  91          if(substr($path,-1) == '/')
  92          {
  93              $path = substr($path, 0, -1);
  94          }
  95  
  96          if(!$handle = opendir($path))
  97          {
  98              return $ret;
  99          }
 100          if($omit == 'standard')
 101          {
 102              $rejectArray = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$');
 103          }
 104          else
 105          {
 106              if(is_array($omit))
 107              {
 108                  $rejectArray = $omit;
 109              }
 110              else
 111              {
 112                  $rejectArray = array($omit);
 113              }
 114          }
 115          while (false !== ($file = readdir($handle)))
 116          {
 117              if(is_dir($path.'/'.$file) && ($fmask == '' || preg_match("#".$fmask."#", $file)))
 118              {
 119                  $rejected = FALSE;
 120                  foreach($rejectArray as $rmask)
 121                  {
 122                      if(preg_match("#".$rmask."#", $file))
 123                      {
 124                          $rejected = TRUE;
 125                          break;
 126                      }
 127                  }
 128                  if($rejected == FALSE)
 129                  {
 130                      $ret[] = $file;
 131                  }
 132              }
 133          }
 134          return $ret;
 135      }
 136  
 137  	function rmtree($dir)
 138      {
 139          if (substr($dir, strlen($dir)-1, 1) != '/')
 140          {
 141              $dir .= '/';
 142          }
 143          if ($handle = opendir($dir))
 144          {
 145              while ($obj = readdir($handle))
 146              {
 147                  if ($obj != '.' && $obj != '..')
 148                  {
 149                      if (is_dir($dir.$obj))
 150                      {
 151                          if (!$this->rmtree($dir.$obj))
 152                          {
 153                              return false;
 154                          }
 155                      }
 156                      elseif (is_file($dir.$obj))
 157                      {
 158                          if (!unlink($dir.$obj))
 159                          {
 160                              return false;
 161                          }
 162                      }
 163                  }
 164              }
 165  
 166              closedir($handle);
 167  
 168              if (!@rmdir($dir))
 169              {
 170                  return false;
 171              }
 172              return true;
 173          }
 174          return false;
 175      }
 176  
 177  }
 178  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7