本文整理汇总了PHP中backupbuddy_core::importbuddy方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::importbuddy方法的具体用法?PHP backupbuddy_core::importbuddy怎么用?PHP backupbuddy_core::importbuddy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::importbuddy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public static function test($settings)
{
$email = $settings['address'];
pb_backupbuddy::status('details', 'Testing email destination. Sending ImportBuddy.php.');
$importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
// Full path & filename to temporary importbuddy
backupbuddy_core::importbuddy($importbuddy_temp);
// Create temporary importbuddy.
$files = array($importbuddy_temp);
if (pb_backupbuddy::$options['email_return'] != '') {
$email_return = pb_backupbuddy::$options['email_return'];
} else {
$email_return = get_option('admin_email');
}
$headers = 'From: BackupBuddy <' . $email_return . '>' . "\r\n";
$wp_mail_result = wp_mail($email, 'BackupBuddy Test', 'BackupBuddy destination test for ' . site_url(), $headers, $files);
pb_backupbuddy::status('details', 'Sent test email.');
@unlink($importbuddy_temp);
if ($wp_mail_result === true) {
// WP sent. Hopefully it makes it!
return true;
} else {
// WP couldn't try to send.
echo 'WordPress was unable to attempt to send email. Check your WordPress & server settings.';
return false;
}
}
示例2: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
if ('' == $arguments['password']) {
// no password send in arguments.
if (!isset(pb_backupbuddy::$options)) {
pb_backupbuddy::load();
}
if ('' == pb_backupbuddy::$options['importbuddy_pass_hash']) {
// no default password is set on Settings page.
return array('api' => '0', 'status' => 'error', 'message' => 'No ImportBuddy password was entered and no default has been set on the Settings page.');
} else {
// Use default.
$importbuddy_pass_hash = pb_backupbuddy::$options['importbuddy_pass_hash'];
}
} else {
// Password passed in arguments.
$importbuddy_pass_hash = md5($arguments['password']);
}
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
return array('api' => '4', 'status' => 'ok', 'message' => 'ImportBuddy retrieved.', 'importbuddy' => base64_encode(backupbuddy_core::importbuddy('', $importbuddy_pass_hash, $returnNotEcho = true)));
}
示例3: deploymentImportBuddy
public static function deploymentImportBuddy($password, $backupFile, $additionalStateInfo = '')
{
if (!file_exists($backupFile)) {
$error = 'Error #43848378: Backup file `' . $backupFile . '` not found uploaded.';
pb_backupbuddy::status('error', $error);
return array(false, $error);
}
$backupSerial = backupbuddy_core::get_serial_from_file($backupFile);
$importFileSerial = pb_backupbuddy::random_string(15);
$importFilename = 'importbuddy-' . $importFileSerial . '.php';
backupbuddy_core::importbuddy(ABSPATH . $importFilename, $password);
// Render default config file overrides. Overrrides default restore.php state data.
$state = array();
global $wpdb;
$state['type'] = 'deploy';
$state['archive'] = $backupFile;
$state['siteurl'] = preg_replace('|/*$|', '', site_url());
// Strip trailing slashes.
$state['homeurl'] = preg_replace('|/*$|', '', home_url());
// Strip trailing slashes.
$state['restoreFiles'] = false;
$state['migrateHtaccess'] = false;
$state['remote_api'] = pb_backupbuddy::$options['remote_api'];
// For use by importbuddy api auth. Enables remote api in this importbuddy.
$state['databaseSettings']['server'] = DB_HOST;
$state['databaseSettings']['database'] = DB_NAME;
$state['databaseSettings']['username'] = DB_USER;
$state['databaseSettings']['password'] = DB_PASSWORD;
$state['databaseSettings']['prefix'] = $wpdb->prefix;
$state['databaseSettings']['renamePrefix'] = true;
$state['cleanup']['deleteImportBuddy'] = true;
$state['cleanup']['deleteImportLog'] = true;
if (is_array($additionalStateInfo)) {
$state = array_merge($state, $additionalStateInfo);
}
// Write default state overrides.
$state_file = ABSPATH . 'importbuddy-' . $importFileSerial . '-state.php';
if (false === ($file_handle = @fopen($state_file, 'w'))) {
$error = 'Error #8384784: Temp state file is not creatable/writable. Check your permissions. (' . $state_file . ')';
pb_backupbuddy::status('error', $error);
return array(false, $error);
}
fwrite($file_handle, "<?php die('Access Denied.'); // <!-- ?>\n" . base64_encode(serialize($state)));
fclose($file_handle);
$undoFile = 'backupbuddy_deploy_undo-' . $backupSerial . '.php';
//$undoURL = rtrim( site_url(), '/\\' ) . '/' . $undoFile;
if (false === copy(pb_backupbuddy::plugin_path() . '/classes/_rollback_undo.php', ABSPATH . $undoFile)) {
$error = 'Error #3289447: Unable to write undo file `' . ABSPATH . $undoFile . '`. Check permissions on directory.';
pb_backupbuddy::status('error', $error);
return array(false, $error);
}
return $importFileSerial;
}
示例4: importbuddy
public function importbuddy()
{
$pass_hash = '';
$password = stripslashes(pb_backupbuddy::_GET('p'));
if ($password != '') {
$pass_hash = md5($password);
if (pb_backupbuddy::$options['importbuddy_pass_hash'] == '') {
// if no default pass is set then we set this as default.
pb_backupbuddy::$options['importbuddy_pass_hash'] = $pass_hash;
pb_backupbuddy::$options['importbuddy_pass_length'] = strlen($password);
// length of pass pre-hash.
pb_backupbuddy::save();
}
}
backupbuddy_core::importbuddy('', $pass_hash);
// Outputs importbuddy to browser for download.
die;
}
示例5: pre_backup
//.........这里部分代码省略.........
// Breaking out ENABLED.
// Tables we will try to break out into standalone steps if possible.
$breakout_tables_defaults = array($wpdb->prefix . 'posts', $wpdb->prefix . 'postmeta');
pb_backupbuddy::status('details', 'Breaking out tables ENABLED based on settings. Tables to be broken out into individual steps: `' . implode(', ', $breakout_tables_defaults) . '`.');
foreach ((array) $breakout_tables_defaults as $breakout_tables_default) {
if (in_array($breakout_tables_default, $tables)) {
$this->_backup['breakout_tables'][] = $breakout_tables_default;
$tables = array_diff($tables, array($breakout_tables_default));
// Remove from main table backup list.
}
}
unset($breakout_tables_defaults);
// No longer needed.
}
$this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array($tables), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
// Set up backup steps for additional broken out tables.
foreach ((array) $this->_backup['breakout_tables'] as $breakout_table) {
$this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array(array($breakout_table)), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
}
}
// end there being tables to backup.
} else {
pb_backupbuddy::status('message', __('Skipping database dump based on settings / profile type.', 'it-l10n-backupbuddy') . ' Backup type: `' . $type . '`.');
}
if ('pull' != $deployDirection) {
$this->_backup['steps'][] = array('function' => 'backup_zip_files', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
if ($type == 'export') {
$this->_backup['steps'][] = array('function' => 'ms_cleanup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
}
if ($profile['integrity_check'] == '1') {
pb_backupbuddy::status('details', __('Integrity check will be performed based on settings for this profile.', 'it-l10n-backupbuddy'));
$this->_backup['steps'][] = array('function' => 'integrity_check', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
} else {
pb_backupbuddy::status('details', __('Skipping integrity check step based on settings for this profile.', 'it-l10n-backupbuddy'));
}
}
$this->_backup['steps'][] = array('function' => 'post_backup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
// Prepend and append pre backup and post backup steps.
$this->_backup['steps'] = array_merge($pre_backup, $this->_backup['steps'], $post_backup);
/********* End setting up steps array. *********/
// Save what we have so far so that any errors below will end up displayed to user.
$this->_backup_options->save();
/********* Begin directory creation and security. *********/
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory());
// Prepare temporary directory for holding SQL and data file.
if (backupbuddy_core::getTempDirectory() == '') {
pb_backupbuddy::status('error', 'Error #54534344. Temp directory blank. Please deactivate then reactivate plugin to reset.');
return false;
}
if (!file_exists($this->_backup['temp_directory'])) {
if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temp_directory']) === false) {
pb_backupbuddy::status('error', 'Error #9002b. Unable to create temporary storage directory (' . $this->_backup['temp_directory'] . ')');
return false;
}
}
if (!is_writable($this->_backup['temp_directory'])) {
pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temp_directory'] . ')');
return false;
}
pb_backupbuddy::anti_directory_browsing(ABSPATH . 'wp-content/uploads/backupbuddy_temp/');
// Prepare temporary directory for holding ZIP file while it is being generated.
$this->_backup['temporary_zip_directory'] = backupbuddy_core::getBackupDirectory() . 'temp_zip_' . $this->_backup['serial'] . '/';
if (!file_exists($this->_backup['temporary_zip_directory'])) {
if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temporary_zip_directory']) === false) {
pb_backupbuddy::status('details', 'Error #9002c. Unable to create temporary ZIP storage directory (' . $this->_backup['temporary_zip_directory'] . ')');
return false;
}
}
if (!is_writable($this->_backup['temporary_zip_directory'])) {
pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temporary_zip_directory'] . ')');
return false;
}
/********* End directory creation and security *********/
// Generate backup DAT (data) file containing details about the backup.
if ($this->backup_create_dat_file($trigger) !== true) {
pb_backupbuddy::status('details', __('Problem creating DAT file.', 'it-l10n-backupbuddy'));
return false;
}
// Generating ImportBuddy file to include in the backup for FULL BACKUPS ONLY currently. Cannot put in DB because it would be in root and be excluded or conflict on extraction.
if ($type == 'full') {
if (pb_backupbuddy::$options['include_importbuddy'] == '1') {
pb_backupbuddy::status('details', 'Generating ImportBuddy tool to include in backup archive: `' . $this->_backup['temp_directory'] . 'importbuddy.php`.');
pb_backupbuddy::status('startAction', 'importbuddyCreation');
backupbuddy_core::importbuddy($this->_backup['temp_directory'] . 'importbuddy.php');
pb_backupbuddy::status('finishAction', 'importbuddyCreation');
pb_backupbuddy::status('details', 'ImportBuddy generation complete.');
} else {
// dont include importbuddy.
pb_backupbuddy::status('details', 'ImportBuddy tool inclusion in ZIP backup archive skipped based on settings or backup type.');
}
}
// Save all of this.
$this->_backup['init_complete'] = true;
// pre_backup() completed.
$this->_backup_options->save();
pb_backupbuddy::status('details', __('Finished pre-backup procedures.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('milestone', 'finish_settings');
pb_backupbuddy::status('finishFunction', json_encode(array('function' => 'pre_backup')));
return true;
}
示例6: _verb_renderImportBuddy
private static function _verb_renderImportBuddy()
{
$tempDir = backupbuddy_core::getTempDirectory();
$tempFile = $tempDir . str_replace(array('\\', '/'), '', pb_backupbuddy::_POST('backupFile'));
if (!file_exists($tempFile)) {
die(json_encode(array('success' => false, 'error' => 'Error #43848378: Backup file `' . $tempFile . '` not found uploaded.')));
}
$importFileSerial = pb_backupbuddy::random_string(15);
$importFilename = 'importbuddy-' . $importFileSerial . '.php';
backupbuddy_core::importbuddy(ABSPATH . $importFilename, $password = md5(md5(pb_backupbuddy::_POST('backupbuddy_api_key'))));
// Render default config file overrides. Overrrides default restore.php state data.
$state = array();
global $wpdb;
$state['type'] = 'deploy';
$state['archive'] = $tempDir . pb_backupbuddy::_POST('backupFile');
$state['siteurl'] = site_url();
$state['homeurl'] = home_url();
$state['restoreFiles'] = false;
$state['migrateHtaccess'] = false;
$state['remote_api'] = pb_backupbuddy::$options['remote_api'];
// For use by importbuddy api auth. Enables remote api in this importbuddy.
$state['databaseSettings']['server'] = DB_HOST;
$state['databaseSettings']['database'] = DB_NAME;
$state['databaseSettings']['username'] = DB_USER;
$state['databaseSettings']['password'] = DB_PASSWORD;
$state['databaseSettings']['prefix'] = $wpdb->prefix;
$state['databaseSettings']['renamePrefix'] = true;
// Write default state overrides.
$state_file = ABSPATH . 'importbuddy-' . $importFileSerial . '-state.php';
if (false === ($file_handle = @fopen($state_file, 'w'))) {
pb_backupbuddy::status('error', 'Error #8384784: Temp state file is not creatable/writable. Check your permissions. (' . $state_file . ')');
return false;
}
fwrite($file_handle, "<?php die('Access Denied.'); // <!-- ?>\n" . base64_encode(serialize($state)));
fclose($file_handle);
die(json_encode(array('success' => true, 'importFileSerial' => $importFileSerial)));
}
示例7:
</script>
<?php
// END TOUR.
// Check if performing an actual migration now. If so then load file and skip the rest of this page.
if (pb_backupbuddy::_GET('callback_data') != '' && pb_backupbuddy::_GET('callback_data') != 'importbuddy.php') {
require_once '_migrate.php';
return;
}
// Handle remote sending ImportBuddy.
if (pb_backupbuddy::_GET('callback_data') == 'importbuddy.php') {
pb_backupbuddy::alert('<span id="pb_backupbuddy_ib_sent">Sending ImportBuddy file. This may take several seconds. Please wait ...</span>');
pb_backupbuddy::flush();
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
$importbuddy_file = backupbuddy_core::getTempDirectory() . 'importbuddy.php';
// Render ImportBuddy to temp location.
backupbuddy_core::importbuddy($importbuddy_file);
if (file_exists($importbuddy_file)) {
$response = backupbuddy_core::send_remote_destination($_GET['destination'], $importbuddy_file, $trigger = 'manual');
} else {
pb_backupbuddy::alert('Error #4589: Local importbuddy.php file not found for sending. Check directory permissions and / or manually migrating by downloading importbuddy.php.');
$response = false;
}
if (file_exists($importbuddy_file)) {
if (false === unlink($importbuddy_file)) {
// Delete temporary ImportBuddy file.
pb_backupbuddy::alert('Unable to delete file. For security please manually delete it: `' . $importbuddy_file . '`.');
}
}
if ($response === true) {
?>
<script type="text/javascript">
示例8: test
public static function test($settings)
{
$settings = self::_normalizeSettings($settings);
if (false === ($settings = self::_connect($settings))) {
$error = 'Unable to connect with Google Drive. See log for details.';
echo $error;
pb_backupbuddy::status('error', $error);
return false;
}
pb_backupbuddy::status('details', 'Testing Google Drive destination. Sending ImportBuddy.php.');
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
$importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
// Full path & filename to temporary importbuddy
backupbuddy_core::importbuddy($importbuddy_temp);
// Create temporary importbuddy.
$files = array($importbuddy_temp);
$results = self::send($settings, $files, '', $delete_remote_after = true);
@unlink($importbuddy_temp);
if (true === $results) {
echo 'Success sending test file to Google Drive. ';
return true;
} else {
global $pb_backupbuddy_destination_errors;
echo 'Failure sending test file to Google Drive. Details: `' . implode(', ', $pb_backupbuddy_destination_errors) . '`.';
return false;
}
}
示例9: stripslashes
<?php
backupbuddy_core::verifyAjaxAccess();
$pass_hash = '';
$password = stripslashes(pb_backupbuddy::_GET('p'));
if ($password != '') {
$pass_hash = md5($password);
if (pb_backupbuddy::$options['importbuddy_pass_hash'] == '') {
// if no default pass is set then we set this as default.
pb_backupbuddy::$options['importbuddy_pass_hash'] = $pass_hash;
pb_backupbuddy::$options['importbuddy_pass_length'] = strlen($password);
// length of pass pre-hash.
pb_backupbuddy::save();
}
}
backupbuddy_core::importbuddy('', $pass_hash);
// Outputs importbuddy to browser for download.
die;
示例10: _step_send_pending_db_snapshots
private static function _step_send_pending_db_snapshots($startAt = 0)
{
// Load state into self::$_state & fileoptions object into self::$_stateObj.
if (false === self::_load_state()) {
return false;
}
if (false === self::_load_tables()) {
return false;
}
if (0 != $startAt) {
pb_backupbuddy::status('details', 'Resuming snapshot send at point `' . $startAt . '`.');
}
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
backupbuddy_live::update_db_live_activity_time();
// On first pass create and send backupbuddy_dat.php and importbuddy.php.
if (0 == $startAt) {
// Render backupbuddy_dat.php
$dat_file = backupbuddy_live::getLiveDatabaseSnapshotDir() . 'backupbuddy_dat.php';
// Make sure directory exists.
if (!file_exists(dirname($dat_file))) {
if (false === pb_backupbuddy_filesystem::mkdir(dirname($dat_file))) {
pb_backupbuddy::status('warning', 'Warning #34893498434: Unable to mkdir("' . $dat_file . '").');
}
}
$tableSizes = array();
foreach (self::$_tables as $tableName => $table) {
$tableSizes[$tableName] = $table['s'];
}
$table_results = backupbuddy_live::_calculate_table_includes_excludes_basedump();
$dat_settings = array('backup_type' => 'live', 'profile' => array(), 'serial' => '', 'breakout_tables' => backupbuddy_live::calculateTables(), 'table_sizes' => $tableSizes, 'force_single_db_file' => false, 'trigger' => 'live', 'db_excludes' => $table_results[1], 'db_includes' => $table_results[0]);
pb_backupbuddy::status('details', 'Rendering DAT file to `' . $dat_file . '`.');
if (!is_array(backupbuddy_core::render_dat_contents($dat_settings, $dat_file))) {
$error = 'Error #47949743: Since DAT file could not be written aborting. Check permissions writing to `' . $dat_file . '`.';
pb_backupbuddy::status('error', $error);
return $error;
}
// Render importbuddy.php
$importbuddy_file = backupbuddy_live::getLiveDatabaseSnapshotDir() . 'importbuddy.php';
pb_backupbuddy::status('details', 'Rendering importbuddy file to `' . $importbuddy_file . '`.');
if (false === backupbuddy_core::importbuddy($importbuddy_file, $pass = NULL)) {
// NULL pass leaves #PASSWORD# placeholder in place.
pb_backupbuddy::status('warning', 'Warning #348438345: Unable to render importbuddy. Not backing up importbuddy.php.');
}
// Load destination settings.
$destination_settings = self::get_destination_settings();
// Send DAT file.
$send_id = 'live_' . md5($dat_file) . '-' . pb_backupbuddy::random_string(6);
$destination_settings['_database_table'] = 'backupbuddy_dat.php';
if (false === pb_backupbuddy_destinations::send($destination_settings, $dat_file, $send_id, $delete_after = true, $isRetry = false, $trigger = 'live_periodic', $destination_id = backupbuddy_live::getLiveID())) {
$error = 'Error #389398: Unable to send DAT file to Live servers. See error log above for details.';
pb_backupbuddy::status('error', $error);
backupbuddy_core::addNotification('live_error', 'BackupBuddy Stash Live Error', $error);
}
// Send importbuddy.
$send_id = 'live_' . md5($importbuddy_file) . '-' . pb_backupbuddy::random_string(6);
$destination_settings['_database_table'] = 'importbuddy.php';
if (false === pb_backupbuddy_destinations::send($destination_settings, $importbuddy_file, $send_id, $delete_after = true, $isRetry = false, $trigger = 'live_periodic', $destination_id = backupbuddy_live::getLiveID())) {
pb_backupbuddy::status('error', 'Error #329327: Unable to send importbuddy file to Live servers. See error log above for details.');
}
}
// Loop through files in the catalog.
$loopCount = 0;
$checkCount = 0;
$sendTimeSum = 0;
$sendSizeSum = 0;
$sendsStarted = 0;
$sendsSucceeded = 0;
$sendsMultiparted = 0;
$sendsFailed = 0;
$alreadyBackedUp = 0;
$tooManySendFails = 0;
$lastSendThisPass = false;
$sendMoreRemain = false;
foreach (self::$_tables as $table => &$tableDetails) {
$loopCount++;
if (0 != $startAt) {
// Resuming...
if ($loopCount < $startAt) {
continue;
}
}
$checkCount++;
// If backed up after modified time then it's up to date. Skip.
if ($tableDetails['b'] > $tableDetails['m']) {
pb_backupbuddy::status('details', 'Skipping send of table `' . $table . '` because it has already been sent since SQL file was made.');
$alreadyBackedUp++;
continue;
}
// Calculate table file.
$tableFile = backupbuddy_live::getLiveDatabaseSnapshotDir() . $table . '.sql';
// If too many attempts have passed then skip.
if ($tableDetails['t'] >= self::MAX_SEND_ATTEMPTS) {
pb_backupbuddy::status('error', 'Error #389328: This database file has failed transfer too many times. Skipping until next restart of periodic proces. File: `' . $tableFile . '`. Size: `' . pb_backupbuddy::$format->file_size(filesize($tableFile)) . '`.');
$tooManySendFails++;
continue;
}
// Load destination settings.
$destination_settings = self::get_destination_settings();
// If too many remote sends have failed today then give up for now since something is likely wrong.
if (self::$_state['stats']['recent_send_fails'] > $destination_settings['max_daily_failures']) {
//.........这里部分代码省略.........