public function importexport_settings() { pb_backupbuddy::load(); pb_backupbuddy::$ui->ajax_header(); if (pb_backupbuddy::_POST('import_settings') != '') { $import = trim(stripslashes(pb_backupbuddy::_POST('import_data'))); $import = base64_decode($import); if ($import === false) { // decode failed. pb_backupbuddy::alert('Unable to decode settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // decode success. if (($import = maybe_unserialize($import)) === false) { // unserialize fail. pb_backupbuddy::alert('Unable to unserialize settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // unserialize success. if (!isset($import['data_version'])) { // missing expected content. pb_backupbuddy::alert('Unserialized settings data but it did not contain expected data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // contains expected content. pb_backupbuddy::$options = $import; require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php'; // Run data migration to upgrade if needed. pb_backupbuddy::save(); pb_backupbuddy::alert('Provided settings successfully imported. Prior settings overwritten.'); } } } } echo '<h2>Export BackupBuddy Settings</h2>'; echo 'Copy the encoded plugin settings below and paste it into the destination BackupBuddy Settings Import page.<br><br>'; echo '<textarea style="width: 100%; height: 100px;" wrap="on">'; echo base64_encode(serialize(pb_backupbuddy::$options)); echo '</textarea>'; echo '<br><br><br>'; echo '<h2>Import BackupBuddy Settings</h2>'; echo 'Paste encoded plugin settings below to import & replace current settings. If importing settings from an older version and errors are encountered please deactivate and reactivate the plugin.<br><br>'; echo '<form method="post" action="' . pb_backupbuddy::ajax_url('importexport_settings') . '">'; echo '<textarea style="width: 100%; height: 100px;" wrap="on" name="import_data"></textarea>'; echo '<br><br><input type="submit" name="import_settings" value="Import Settings" class="button button-primary">'; echo '</form>'; pb_backupbuddy::$ui->ajax_footer(); die; }
public static function reset_defaults() { if (isset(pb_backupbuddy::$_settings['default_options'])) { pb_backupbuddy::$options = pb_backupbuddy::$_settings['default_options']; pb_backupbuddy::save(); return true; } else { return false; } }
}); }); </script> <?php pb_backupbuddy::$ui->title(__('Settings', 'it-l10n-backupbuddy')); backupbuddy_core::versions_confirm(); pb_backupbuddy::disalert('profile_suggest', '<span class="pb_label" style="font-size: 12px; margin-left: 10px; position: relative;">Tip</span> You can create & customize multiple different backup types with profiles on the <a href="?page=pb_backupbuddy_backup">Backups</a> page by selecting the gear icon next to each profile.'); $data = array(); // To pass to view. // Reset settings to defaults. if (pb_backupbuddy::_POST('reset_defaults') != '') { pb_backupbuddy::verify_nonce(); $keepDestNote = ''; $remote_destinations = pb_backupbuddy::$options['remote_destinations']; pb_backupbuddy::$options = pb_backupbuddy::settings('default_options'); if ('1' == pb_backupbuddy::_POST('keep_destinations')) { pb_backupbuddy::$options['remote_destinations'] = $remote_destinations; $keepDestNote = ' ' . __('Remote destination settings were not reset.', 'it-l10n-backupbuddy'); } pb_backupbuddy::save(); backupbuddy_core::verify_directories($skipTempGeneration = true); // Re-verify directories such as backup dir, temp, etc. $resetNote = __('Plugin settings have been reset to defaults.', 'it-l10n-backupbuddy'); pb_backupbuddy::alert($resetNote . $keepDestNote); backupbuddy_core::addNotification('settings_reset', 'Plugin settings reset', $resetNote . $keepDestNote); } /* BEGIN VERIFYING BACKUP DIRECTORY */ if (isset($_POST['pb_backupbuddy_backup_directory'])) { $backup_directory = pb_backupbuddy::_POST('pb_backupbuddy_backup_directory'); if ('' == $backup_directory) {
} // ********** END 1.x -> 2.x DATA MIGRATION ********** // ********** BEGIN 2.x -> 3.x DATA MIGRATION ********** // Attempt to get 2.x options. $options = get_site_option('pluginbuddy_backupbuddy'); //Try to read site-specific settings in if (is_multisite()) { $multisite_option = get_option('pluginbuddy_backupbuddy'); if ($multisite_option) { $options = $multisite_option; } unset($multisite_option); } // If options is not false then we need to upgrade. if ($options !== false) { pb_backupbuddy::$options = array_merge((array) pb_backupbuddy::settings('default_options'), (array) $options); // Merge defaults. unset($options); if (isset(pb_backupbuddy::$options['temporary_options']['experimental_zip'])) { pb_backupbuddy::$options['alternative_zip'] = pb_backupbuddy::$options['temporary_options']['experimental_zip']; } if (isset(pb_backupbuddy::$options['import_password'])) { // Migrate import password to just hash. pb_backupbuddy::$options['importbuddy_pass_length'] = strlen(pb_backupbuddy::$options['import_password']); pb_backupbuddy::$options['importbuddy_pass_hash'] = md5(pb_backupbuddy::$options['import_password']); unset(pb_backupbuddy::$options['import_password']); } // Migrate email_notify_scheduled -> email_notify_scheduled_complete pb_backupbuddy::$options['email_notify_scheduled_complete'] = pb_backupbuddy::$options['email_notify_scheduled']; // Migrate log file. $old_log_file = ABSPATH . '/wp-content/uploads/pluginbuddy_backupbuddy' . '-' . pb_backupbuddy::$options['log_serial'] . '.txt';
if ($import === false) { // decode failed. pb_backupbuddy::alert('Unable to decode settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // decode success. if (($import = maybe_unserialize($import)) === false) { // unserialize fail. pb_backupbuddy::alert('Unable to unserialize settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // unserialize success. if (!isset($import['data_version'])) { // missing expected content. pb_backupbuddy::alert('Unserialized settings data but it did not contain expected data. Import aborted. Insure that you fully copied the settings and did not change any of the text.'); } else { // contains expected content. pb_backupbuddy::$options = $import; require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php'; // Run data migration to upgrade if needed. pb_backupbuddy::save(); pb_backupbuddy::alert('Provided settings successfully imported. Prior settings overwritten.'); } } } } echo '<h2>Export BackupBuddy Settings</h2>'; echo 'Copy the encoded plugin settings below and paste it into the destination BackupBuddy Settings Import page.<br><br>'; echo '<textarea style="width: 100%; height: 100px;" wrap="on">'; echo base64_encode(serialize(pb_backupbuddy::$options)); echo '</textarea>'; echo '<br><br><br>'; echo '<h2>Import BackupBuddy Settings</h2>';