Пример #1
0
 /**
  * @param null|string $directory
  * @return array|bool
  */
 public function getFilesList($directory = null)
 {
     if ($directory === null) {
         $directory = realpath(ABSPATH);
     }
     if (!$this->isExcluded('upready')) {
         $this->setExcludedDirectories(array('upready', 'ready-backup', 'ready-backup-pro'));
     }
     /* Setup excluded folders */
     $excluded = array();
     $options = $this->getConfig(array('themes_dir', 'plugins_dir', 'uploads_dir'));
     foreach ($options as $key => $value) {
         if (!$value) {
             $excluded[] = str_replace('_dir', '', $key);
         }
     }
     if (false === $this->getConfig('any_dir')) {
         foreach (glob(realpath(WP_CONTENT_DIR) . '/*') as $node) {
             if (is_dir($node) && !in_array($node, array('plugins', 'themes', 'uploads'))) {
                 $excluded[] = basename($node);
             }
         }
     }
     $this->setExcludedDirectories($excluded);
     return $this->filesystem->getFilesList($directory, $this->getExcludedDirectories());
 }
Пример #2
0
 public function getFilesList($optionsModel = false)
 {
     $excluded = $this->getDefaultExcludedFolders();
     $options = !$optionsModel ? frameBup::_()->getModule('options') : $optionsModel;
     // Where we are need to look for files.
     $directory = trailingslashit(realpath(ABSPATH)) . BUP_WP_CONTENT_DIR;
     // Default folders inside wp-content
     $defaults = array('themes', 'plugins', 'uploads');
     // Excluded folder by user.
     $dbexcluded = $options->get('exclude');
     // Folder that contains backups.
     $warehouseDir = $options->get('warehouse_ignore');
     $excluded = array_merge($excluded, array_map('trim', explode(',', $dbexcluded)));
     // Exclude plugin's "warehouse".
     if (!in_array($warehouseDir, $excluded)) {
         $excluded[] = $warehouseDir;
     }
     // If any directory inside "wp-content" isn't selected, then exclude all nodes from it.
     if (0 == $options->get('any_directories')) {
         $nodes = glob(untrailingslashit(WP_CONTENT_DIR) . '/*');
         if (is_array($nodes) && !empty($nodes)) {
             foreach ($nodes as $node) {
                 if (!in_array($nodeName = basename($node), $defaults)) {
                     $excluded[] = $nodeName;
                 }
             }
         }
     }
     // What about plugins, themes and uploads?
     if (0 == $options->get('plugins')) {
         $excluded[] = 'plugins';
     }
     if (0 == $options->get('themes')) {
         $excluded[] = 'themes';
     }
     if (0 == $options->get('uploads')) {
         $excluded[] = 'uploads';
     }
     $fileList = $this->filesystem->getFilesList($directory, $excluded);
     if (1 == $options->get('wp_core')) {
         $directory = realpath(ABSPATH);
         $excluded = $this->getDefaultExcludedFolders();
         $excluded = array_merge($excluded, array_map('trim', explode(',', $dbexcluded)));
         if (is_array($excluded)) {
             $excluded[] = BUP_WP_CONTENT_DIR;
         } else {
             $excluded = array(BUP_WP_CONTENT_DIR);
         }
         $wpCoreFileList = $this->filesystem->getFilesList($directory, $excluded);
         $fileList = array_merge($fileList, $wpCoreFileList);
     }
     $maxFileSizeInBackup = frameBup::_()->getModule('options')->get('max_file_size_in_stack_mb') * 1024 * 1024;
     $files = array();
     $files[0] = array();
     $i = 0;
     $size = 0;
     $stackSize = 2097152;
     foreach ($fileList as $f) {
         $fileSize = @filesize(ABSPATH . $f);
         if ($maxFileSizeInBackup == 0 || $fileSize <= $maxFileSizeInBackup) {
             $filePath = ABSPATH . $f;
             $f_size = @filesize($filePath);
             $files[$i][] = $f;
             $size += $f_size;
             if ($size > $stackSize) {
                 $i++;
                 $size = 0;
                 $files[$i] = array();
             }
         }
     }
     unset($fileList);
     return $files;
 }