Exemple #1
0
 /**
  * Retrieve a list with all the files contained in the main and subdirectories
  * of the folder specified. Some folders and files will be ignored depending
  * on some rules defined by the developer.
  *
  * @param  string $directory Parent directory where the filesystem scan will start.
  * @return array             List of files in the main and subdirectories of the folder specified.
  */
 public function get_directory_tree($directory = '')
 {
     if (file_exists($directory) && is_dir($directory)) {
         $tree = array();
         // Check whether the ignore scanning feature is enabled or not.
         if (SucuriScanFSScanner::will_ignore_scanning()) {
             $this->ignored_directories = SucuriScanFSScanner::get_ignored_directories();
         }
         switch ($this->scan_interface) {
             case 'spl':
                 if ($this->is_spl_available()) {
                     $tree = $this->get_directory_tree_with_spl($directory);
                 } else {
                     $this->scan_interface = 'opendir';
                     SucuriScanOption::update_option(':scan_interface', $this->scan_interface);
                     $tree = $this->get_directory_tree($directory);
                 }
                 break;
             case 'glob':
                 $tree = $this->get_directory_tree_with_glob($directory);
                 break;
             case 'opendir':
                 $tree = $this->get_directory_tree_with_opendir($directory);
                 break;
             default:
                 $this->scan_interface = 'spl';
                 $tree = $this->get_directory_tree($directory);
                 break;
         }
         return $tree;
     }
     return false;
 }