public function extractDatabase() { $this->_before(__FUNCTION__); die(' ERROR #348437843784: DEPRECATED FUNCTION CALL! '); $this->_priorRollbackCleanup(); pb_backupbuddy::status('details', 'Loading zipbuddy.'); require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; $zipbuddy = new pluginbuddy_zipbuddy(dirname($this->_state['archive'])); pb_backupbuddy::status('details', 'Zipbuddy loaded.'); // Find SQL file location in archive. pb_backupbuddy::status('details', 'Calculating possible SQL file locations.'); $detectedSQLLocation = ''; $possibleSQLLocations = array(); $possibleSQLLocations[] = trim(rtrim(str_replace('backupbuddy_dat.php', '', $this->_state['datLocation']), '\\/') . '/db_1.sql', '\\/'); // SQL file most likely is in the same spot the dat file was. $possibleSQLLocations[] = 'db_1.sql'; // DB backup. v2.x+ $possibleSQLLocations[] = 'wp-content/uploads/backupbuddy_temp/' . $this->_state['serial'] . '/db_1.sql'; // Full backup. $possibleSQLLocations[] = 'db.sql'; // DB backup. v1.x $possibleSQLLocations[] = 'wp-content/uploads/backupbuddy_temp/' . $this->_state['serial'] . '/db.sql'; // Full backup v1.x. pb_backupbuddy::status('details', 'Possible SQL file locations: `' . implode(';', $possibleSQLLocations) . '`.'); $possibleSQLLocations = array_unique($possibleSQLLocations); foreach ($possibleSQLLocations as $possibleSQLLocation) { if (true === $zipbuddy->file_exists($this->_state['archive'], $possibleSQLLocation, $leave_open = true)) { $detectedSQLLocation = $possibleSQLLocation; break; } } // end foreach. if ('' == $detectedSQLLocation) { $this->_error('Error #8483783: Unable to find SQL file(s) location.'); return false; } pb_backupbuddy::status('details', 'Confirmed SQL file location: `' . $detectedSQLLocation . '`.'); $this->_state['databaseSettings']['sqlFile'] = $detectedSQLLocation; // Get SQL file. $files = array($detectedSQLLocation => 'db_1.sql'); pb_backupbuddy::$filesystem->unlink_recursive($this->_state['tempPath']); // Remove if already exists. mkdir($this->_state['tempPath']); // Make empty directory. require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; // Extract SQL file. pb_backupbuddy::status('details', 'Extracting SQL file(s).'); if (false === backupbuddy_restore_files::restore($this->_state['archive'], $files, $this->_state['tempPath'], $zipbuddy)) { $this->_error('Error #85384: Unable to restore one or more database files.'); return false; } pb_backupbuddy::status('details', 'Finished database extraction function.'); return true; }
if( jQuery( '#' + target_id ).length == 0 ) { // No status box yet so suppress. return; } jQuery( '#' + target_id ).append( "\n" + message ); textareaelem = document.getElementById( target_id ); textareaelem.scrollTop = textareaelem.scrollHeight; } function backupbuddy_hourpad(n) { return ("0" + n).slice(-2); } </script> <?php $success = false; global $pb_backupbuddy_js_status; $pb_backupbuddy_js_status = true; echo pb_backupbuddy::status_box('Restoring . . .'); echo '<div id="pb_backupbuddy_working" style="width: 100px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>'; pb_backupbuddy::set_status_serial('restore'); global $wp_version; pb_backupbuddy::status('details', 'BackupBuddy v' . pb_backupbuddy::settings('version') . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.'); $archive_file = pb_backupbuddy::_GET('archive'); // archive to extract from. require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; $result = backupbuddy_restore_files::restore(backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH); echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>'; pb_backupbuddy::flush(); if (false === $result) { } else { } pb_backupbuddy::$ui->ajax_footer(); pb_backupbuddy::$ui->ajax_footer(); die;
public function restore_file_restore() { $files = pb_backupbuddy::_GET('files'); // file to extract. $files_array = explode(',', $files); $files = array(); foreach ($files_array as $file) { if (substr($file, -1) == '/') { // If directory then add wildcard. $file = $file . '*'; } $files[$file] = $file; } unset($files_array); pb_backupbuddy::$ui->ajax_header(true, false); // js, no padding ?> <script type="text/javascript"> function pb_status_append( status_string ) { target_id = 'pb_backupbuddy_status'; // importbuddy_status or pb_backupbuddy_status if( jQuery( '#' + target_id ).length == 0 ) { // No status box yet so suppress. return; } jQuery( '#' + target_id ).append( "\n" + status_string ); textareaelem = document.getElementById( target_id ); textareaelem.scrollTop = textareaelem.scrollHeight; } </script> <?php $success = false; global $pb_backupbuddy_js_status; $pb_backupbuddy_js_status = true; echo pb_backupbuddy::status_box('Restoring . . .'); echo '<div id="pb_backupbuddy_working" style="width: 100px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>'; pb_backupbuddy::set_status_serial('restore'); global $wp_version; pb_backupbuddy::status('details', 'BackupBuddy v' . pb_backupbuddy::settings('version') . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.'); $archive_file = pb_backupbuddy::_GET('archive'); // archive to extract from. require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; $result = backupbuddy_restore_files::restore(backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH); echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>'; pb_backupbuddy::flush(); if (false === $result) { } else { } pb_backupbuddy::$ui->ajax_footer(); pb_backupbuddy::$ui->ajax_footer(); die; }