示例#1
0
if (isset($this->advanced_options['skip_files']) && $this->advanced_options['skip_files'] == 'true') {
    $this->status('message', 'Skipping file extraction based on advanced settings.');
    $result = true;
} else {
    // Set compatibility mode if defined in advanced options.
    $compatibility_mode = false;
    // Default to no compatibility mode.
    if (isset($this->advanced_options['force_compatibility_medium']) && $this->advanced_options['force_compatibility_medium'] == "true") {
        $compatibility_mode = 'ziparchive';
    } elseif (isset($this->advanced_options['force_compatibility_slow']) && $this->advanced_options['force_compatibility_slow'] == "true") {
        $compatibility_mode = 'pclzip';
    }
    // Zip & Unzip library setup.
    require_once $this->_pluginPath . '/lib/zipbuddy/zipbuddy.php';
    $_zipbuddy = new pluginbuddy_zipbuddy(ABSPATH, '', 'unzip');
    $_zipbuddy->set_status_callback(array(&$this, 'status'));
    $result = $_zipbuddy->unzip($backup_archive, $destination_directory, $compatibility_mode);
}
echo '<script type="text/javascript">jQuery("#pb_importbuddy_working").hide();</script>';
flush();
// Extract zip file & verify it worked.
if (true !== $result) {
    $this->status('error', 'Failed unzipping archive.');
    $this->alert('Failed unzipping archive.');
    $failed = true;
} else {
    // Reported success; verify extraction.
    if (!file_exists($destination_directory . 'wp-config.php')) {
        $this->status('error', 'Error #9004: Key files missing.', 'The unzip process reported success but the backup data file, backupbuddy_dat.php was not found in the extracted files. The unzip process either failed (most likely) or the zip file is not a proper BackupBuddy backup.');
        $this->alert('Error: Key files missing.', 'The unzip process reported success but the backup data file, backupbuddy_dat.php was not found in the extracted files. The unzip process either failed (most likely) or the zip file is not a proper BackupBuddy backup.', '9004');
        return false;
示例#2
0
 /**
  *	extract()
  *
  *	Extract backup zip file.
  *
  *	@return		array		True if the extraction was a success OR skipping of extraction is set.
  */
 function extract()
 {
     if (true === $this->_parent->_options['skip_files']) {
         // Option to skip all file updating / extracting.
         $this->_parent->status('message', 'Skipped extracting files based on debugging options.');
         return true;
     } else {
         $this->_parent->set_greedy_script_limits();
         $this->_parent->status('message', 'Unzipping into `' . ABSPATH . '`');
         $backup_archive = ABSPATH . $this->_parent->_options['file'];
         $destination_directory = ABSPATH;
         // Set compatibility mode if defined in advanced options.
         $compatibility_mode = false;
         // Default to no compatibility mode.
         if ($this->_parent->_options['force_compatibility_medium'] != false) {
             $compatibility_mode = 'ziparchive';
         } elseif ($this->_parent->_options['force_compatibility_slow'] != false) {
             $compatibility_mode = 'pclzip';
         }
         // Zip & Unzip library setup.
         require_once ABSPATH . 'importbuddy/lib/zipbuddy/zipbuddy.php';
         $_zipbuddy = new pluginbuddy_zipbuddy(ABSPATH, '', 'unzip');
         $_zipbuddy->set_status_callback(array(&$this->_parent, 'status'));
         // Extract zip file & verify it worked.
         if (true !== ($result = $_zipbuddy->unzip($backup_archive, $destination_directory, $compatibility_mode))) {
             $this->_parent->status('error', 'Failed unzipping archive.');
             $this->_parent->alert('Failed unzipping archive.');
             return false;
         } else {
             // Reported success; verify extraction.
             $this->_parent->_backupdata_file = ABSPATH . 'wp-content/uploads/temp_' . $this->_parent->_options['zip_id'] . '/backupbuddy_dat.php';
             // Full backup dat file location
             $this->_parent->_backupdata_file_dbonly = ABSPATH . 'backupbuddy_dat.php';
             // DB only dat file location
             $this->_parent->_backupdata_file_new = ABSPATH . 'wp-content/uploads/backupbuddy_temp/' . $this->_parent->_options['zip_id'] . '/backupbuddy_dat.php';
             // Full backup dat file location
             if (!file_exists($this->_parent->_backupdata_file) && !file_exists($this->_parent->_backupdata_file_dbonly) && !file_exists($this->_parent->_backupdata_file_new)) {
                 $this->_parent->status('error', 'Error #9004: Key files missing.', 'The unzip process reported success but the backup data file, backupbuddy_dat.php was not found in the extracted files. The unzip process either failed (most likely) or the zip file is not a proper BackupBuddy backup.');
                 $this->_parent->alert('Error: Key files missing.', 'The unzip process reported success but the backup data file, backupbuddy_dat.php was not found in the extracted files. The unzip process either failed (most likely) or the zip file is not a proper BackupBuddy backup.', '9004');
                 return false;
             }
             $this->_parent->status('details', 'Success extracting Zip File "' . ABSPATH . $this->_parent->_options['file'] . '" into "' . ABSPATH . '".');
             return true;
         }
     }
 }