public function backup_path($path)
 {
     $this->config->set_current_action(sprintf(__('Backing up WordPress path at (%s)', 'wpbtd'), $path));
     $processed_files = $this->config->get_processed_files();
     $file_list = new File_List();
     $next_check = 0;
     if (file_exists($path)) {
         $source = realpath($path);
         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
         foreach ($files as $file_info) {
             $file = $file_info->getPathname();
             if (time() > $next_check) {
                 if (!$this->config->in_progress()) {
                     return;
                 }
                 $this->config->add_processed_files($processed_files);
                 $next_check = time() + 5;
             }
             if ($file_list->is_excluded($file)) {
                 continue;
             }
             if (is_file($file)) {
                 if (File_List::in_ignore_list(basename($file))) {
                     continue;
                 }
                 if (in_array($file, $processed_files)) {
                     continue;
                 }
                 if (dirname($file) == $this->config->get_backup_dir() && !(substr(basename($file), -4, 4) == '.sql' || substr(basename($file), -8, 8) == '.sql.zip')) {
                     continue;
                 }
                 $this->output->out($source, $file);
                 $processed_files[] = $file;
             }
         }
         $this->output->end();
     }
 }
 if (isset($_POST['dir'])) {
     //Convert to the os' directiry separator
     $_POST['dir'] = str_replace('/', DIRECTORY_SEPARATOR, urldecode($_POST['dir']));
     if (file_exists($_POST['dir']) && is_readable($_POST['dir'])) {
         $files = scandir($_POST['dir']);
         natcasesort($files);
         if (count($files) > 2) {
             /* The 2 accounts for . and .. */
             echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
             // All dirs
             foreach ($files as $file) {
                 if ($file != '.' && $file != '..' && file_exists($_POST['dir'] . $file) && is_dir($_POST['dir'] . $file)) {
                     if (!is_readable($_POST['dir']) || $_POST['dir'] == dirname(get_sanitized_home_path()) && !strstr($file, basename(get_sanitized_home_path()))) {
                         continue;
                     }
                     if ($file_list->in_ignore_list($file)) {
                         continue;
                     }
                     $full_path = htmlentities($_POST['dir'] . $file);
                     $file = htmlentities($file);
                     $class = $file_list->get_checkbox_class($full_path);
                     echo "<li class='directory collapsed'>";
                     echo "<a href='#' rel='" . str_replace('\\', '/', $full_path) . '/' . "' class='tree'>{$file}</a>";
                     echo "<a href='#' rel='" . str_replace('\\', '/', $full_path) . '/' . "' class='checkbox directory {$class}'></a>";
                     echo "</li>";
                 }
             }
             // All files
             foreach ($files as $file) {
                 if ($file != '.' && $file != '..' && file_exists($_POST['dir'] . $file) && !is_dir($_POST['dir'] . $file)) {
                     if ($_POST['dir'] == dirname(get_sanitized_home_path()) && !strstr($file, basename(get_sanitized_home_path()))) {
 public function backup_path($path, $dropbox_path = null, $always_include = array())
 {
     if (!$this->config->get_option('in_progress')) {
         return;
     }
     if (!$dropbox_path) {
         $dropbox_path = get_sanitized_home_path();
     }
     $file_list = new File_List();
     $current_processed_files = $uploaded_files = array();
     $next_check = time() + 5;
     $total_files = $this->config->get_option('total_file_count');
     if ($total_files < 1800) {
         //I doub't very much a wp installation can get smaller then this
         $total_files = 1800;
     }
     $processed_files = new WP_Backup_Processed_Files();
     $processed_file_count = $processed_files->get_file_count();
     if (file_exists($path)) {
         $source = realpath($path);
         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
         foreach ($files as $file_info) {
             $file = $file_info->getPathname();
             if (time() > $next_check) {
                 $this->config->die_if_stopped();
                 $percent_done = round($processed_file_count / $total_files * 100, 0);
                 if ($percent_done > 99) {
                     $percent_done = 99;
                 }
                 if ($percent_done < 1) {
                     $percent_done = 1;
                 }
                 $processed_files->add_files($current_processed_files);
                 WP_Backup_Registry::logger()->log(sprintf(__('Approximately %s%% complete.', 'wpbtd'), $percent_done), $uploaded_files);
                 $next_check = time() + 5;
                 $uploaded_files = $current_processed_files = array();
             }
             if (!in_array($file, $always_include) && $file_list->is_excluded($file)) {
                 continue;
             }
             if ($file_list->in_ignore_list($file)) {
                 continue;
             }
             if (is_file($file)) {
                 $processed_file = $processed_files->get_file($file);
                 if ($processed_file && $processed_file->offset == 0) {
                     continue;
                 }
                 if (dirname($file) == $this->config->get_backup_dir() && !in_array($file, $always_include)) {
                     continue;
                 }
                 if ($this->output->out($dropbox_path, $file, $processed_file)) {
                     $uploaded_files[] = array('file' => str_replace($dropbox_path . DIRECTORY_SEPARATOR, '', Dropbox_Facade::remove_secret($file)), 'mtime' => filemtime($file));
                     if ($processed_file && $processed_file->offset > 0) {
                         $processed_files->file_complete($file);
                     }
                 }
                 $current_processed_files[] = $file;
                 $processed_file_count++;
             }
         }
         return $processed_file_count;
     }
 }