本文整理汇总了PHP中backupbuddy_core::get_serial_from_file方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::get_serial_from_file方法的具体用法?PHP backupbuddy_core::get_serial_from_file怎么用?PHP backupbuddy_core::get_serial_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::get_serial_from_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_options
/**
* parse_options()
*
* Parses various submitted options and settings from step 1.
*
* @return null
*/
function parse_options()
{
// Set advanced debug options if user set any.
if (isset($_POST['skip_files']) && $_POST['skip_files'] == 'on') {
pb_backupbuddy::$options['skip_files'] = true;
} else {
pb_backupbuddy::$options['skip_files'] = false;
}
if (isset($_POST['skip_htaccess']) && $_POST['skip_htaccess'] == 'on') {
pb_backupbuddy::$options['skip_htaccess'] = true;
} else {
pb_backupbuddy::$options['skip_htaccess'] = false;
}
if (isset($_POST['force_compatibility_medium']) && $_POST['force_compatibility_medium'] == 'on') {
pb_backupbuddy::$options['force_compatibility_medium'] = true;
} else {
pb_backupbuddy::$options['force_compatibility_medium'] = false;
}
if (isset($_POST['force_compatibility_slow']) && $_POST['force_compatibility_slow'] == 'on') {
pb_backupbuddy::$options['force_compatibility_slow'] = true;
} else {
pb_backupbuddy::$options['force_compatibility_slow'] = false;
}
if (isset($_POST['force_high_security']) && $_POST['force_high_security'] == 'on') {
pb_backupbuddy::$options['force_high_security'] = true;
} else {
pb_backupbuddy::$options['force_high_security'] = false;
}
if (isset($_POST['show_php_warnings']) && $_POST['show_php_warnings'] == 'on') {
pb_backupbuddy::$options['show_php_warnings'] = true;
} else {
pb_backupbuddy::$options['show_php_warnings'] = false;
}
if (isset($_POST['file']) && $_POST['file'] != '') {
pb_backupbuddy::$options['file'] = $_POST['file'];
} else {
pb_backupbuddy::$options['file'] = '';
}
if (isset($_POST['log_level']) && $_POST['log_level'] != '') {
pb_backupbuddy::$options['log_level'] = $_POST['log_level'];
} else {
pb_backupbuddy::$options['log_level'] = '';
}
// Set ZIP id (aka serial).
if (!isset(pb_backupbuddy::$options['file'])) {
die('No backup zip file specified to process. Go back and make sure you selected a ZIP file to extract and restore on Step 1.');
}
pb_backupbuddy::$options['zip_id'] = backupbuddy_core::get_serial_from_file(pb_backupbuddy::$options['file']);
}
示例2: _verb_renderImportBuddy
private static function _verb_renderImportBuddy()
{
$backupFile = pb_backupbuddy::_POST('backupFile');
$password = md5(md5(pb_backupbuddy::_POST('backupbuddy_api_key')));
// Store this serial in settings to cleanup any temp db tables in the future with this serial with periodic cleanup.
$backupSerial = backupbuddy_core::get_serial_from_file($backupFile);
pb_backupbuddy::$options['rollback_cleanups'][$backupSerial] = time();
pb_backupbuddy::save();
$importFileSerial = backupbuddy_core::deploymentImportBuddy($password, backupbuddy_core::getBackupDirectory() . $backupFile);
if (is_array($importFileSerial)) {
die(json_encode(array('success' => false, 'error' => $importFileSerial[1])));
} else {
die(json_encode(array('success' => true, 'importFileSerial' => $importFileSerial)));
}
}
示例3: restore_file_view
function restore_file_view()
{
pb_backupbuddy::$ui->ajax_header(true, false);
// js, no padding
$archive_file = pb_backupbuddy::_GET('archive');
// archive to extract from.
$file = pb_backupbuddy::_GET('file');
// file to extract.
$serial = backupbuddy_core::get_serial_from_file($archive_file);
// serial of archive.
$temp_file = uniqid();
// temp filename to extract into.
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
$zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
// Calculate temp directory & lock it down.
$temp_dir = get_temp_dir();
$destination = $temp_dir . 'backupbuddy-' . $serial;
if (!file_exists($destination) && false === mkdir($destination)) {
$error = 'Error #458485945: Unable to create temporary location.';
pb_backupbuddy::status('error', $error);
die($error);
}
// If temp directory is within webroot then lock it down.
$temp_dir = str_replace('\\', '/', $temp_dir);
// Normalize for Windows.
$temp_dir = rtrim($temp_dir, '/\\') . '/';
// Enforce single trailing slash.
if (FALSE !== stristr($temp_dir, ABSPATH)) {
// Temp dir is within webroot.
pb_backupbuddy::anti_directory_browsing($destination);
}
unset($temp_dir);
$message = 'Extracting "' . $file . '" from archive "' . $archive_file . '" into temporary file "' . $destination . '". ';
echo '<!-- ';
pb_backupbuddy::status('details', $message);
echo $message;
$extractions = array($file => $temp_file);
$extract_result = $zipbuddy->extract(backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $extractions);
if (false === $extract_result) {
// failed.
echo ' -->';
$error = 'Error #584984458. Unable to extract.';
pb_backupbuddy::status('error', $error);
die($error);
} else {
// success.
_e('Success.', 'it-l10n-backupbuddy');
echo ' -->';
?>
<textarea readonly="readonly" wrap="off" style="width: 100%; min-height: 175px; height: 100%; margin: 0;"><?php
echo file_get_contents($destination . '/' . $temp_file);
?>
</textarea>
<?php
//unlink( $destination . '/' . $temp_file );
}
// Try to cleanup.
if (file_exists($destination)) {
if (false === pb_backupbuddy::$filesystem->unlink_recursive($destination)) {
pb_backupbuddy::status('details', 'Unable to delete temporary holding directory `' . $destination . '`.');
} else {
pb_backupbuddy::status('details', 'Cleaned up temporary files.');
}
}
pb_backupbuddy::$ui->ajax_footer();
die;
}
示例4: fclose
?>
);
}, 2000);
</script>
<?php
}
// Load footer.
pb_backupbuddy::load_view('_iframe_footer');
// Deployment proceed.
if ('true' == pb_backupbuddy::_GET('deploy')) {
$nextStepNum = 4;
echo '<!-- AUTOPROCEED TO STEP ' . $nextStepNum . ' -->';
//echo '<script>console.log( "' . print_r( $restore->_state, true ) . '" );</script>';
// Write default state overrides.
global $importbuddy_file;
$importFileSerial = backupbuddy_core::get_serial_from_file($importbuddy_file);
$state_file = ABSPATH . 'importbuddy-' . $importFileSerial . '-state.php';
pb_backupbuddy::status('details', 'Writing to state file `' . $state_file . '`.');
if (false === ($file_handle = @fopen($state_file, 'w'))) {
pb_backupbuddy::status('error', 'Error #328937: Temp state file is not creatable/writable. Check your permissions. (' . $state_file . ')');
return false;
}
if (false === fwrite($file_handle, "<?php die('Access Denied.'); // <!-- ?>\n" . base64_encode(serialize($restore->_state)))) {
pb_backupbuddy::status('error', 'Error #2389373: Unable to write to state file.');
} else {
pb_backupbuddy::status('details', 'Wrote to state file.');
}
fclose($file_handle);
?>
<form method="post" action="?ajax=<?php
echo $nextStepNum;
示例5: __
$parent_class_test['status'] = __('OK', 'it-l10n-backupbuddy');
array_push($tests, $parent_class_test);
// Database size WITH EXCLUSIONS accounted for.
$parent_class_test = array('title' => 'Database Size (Default Exclusions applied)', 'suggestion' => 'n/a', 'value' => '<span id="pb_stats_refresh_database_size_excluded">' . pb_backupbuddy::$format->file_size(pb_backupbuddy::$options['stats']['db_size_excluded']) . '</span> <a class="pb_backupbuddy_refresh_stats" rel="refresh_database_size_excluded" alt="' . pb_backupbuddy::ajax_url('refresh_database_size_excluded') . '" title="' . __('Refresh', 'it-l10n-backupbuddy') . '"><img src="' . pb_backupbuddy::plugin_url() . '/images/refresh_gray.gif" style="vertical-align: -1px;"> <span class="pb_backupbuddy_loading" style="display: none; margin-left: 10px;"><img src="' . pb_backupbuddy::plugin_url() . '/images/loading.gif" alt="' . __('Loading...', 'it-l10n-backupbuddy') . '" title="' . __('Loading...', 'it-l10n-backupbuddy') . '" width="16" height="16" style="vertical-align: -3px;" /></span></a>', 'tip' => __('Total size of your database EXCLUDING any tables you have marked for exclusion.', 'it-l10n-backupbuddy'));
$parent_class_test['status'] = __('OK', 'it-l10n-backupbuddy');
array_push($tests, $parent_class_test);
/***** BEGIN AVERAGE WRITE SPEED *****/
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$write_speed_samples = 0;
$write_speed_sum = 0;
$backups = glob(backupbuddy_core::getBackupDirectory() . '*.zip');
if (!is_array($backups)) {
$backups = array();
}
foreach ($backups as $backup) {
$serial = backupbuddy_core::get_serial_from_file($backup);
pb_backupbuddy::status('details', 'Fileoptions instance #22.');
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('warning', 'Unable to open fileoptions file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`. Details: `' . $result . '`.');
}
if (isset($backup_options->options['integrity']) && isset($backup_options->options['integrity']['size'])) {
$write_speed_samples++;
$size = $backup_options->options['integrity']['size'];
$time_taken = 0;
if (isset($backup_options->options['steps'])) {
foreach ($backup_options->options['steps'] as $step) {
if ($step['function'] == 'backup_zip_files') {
$time_taken = $step['finish_time'] - $step['start_time'];
break;
}
示例6: send
//.........这里部分代码省略.........
}
if (is_array($result)) {
// Send is multipart.
pb_backupbuddy::status('details', 'Multipart chunk mode completed a pass of the send function. Resuming will be needed. Result: `' . print_r($result, true) . '`.');
if ('' != $send_id) {
//pb_backupbuddy::status( 'details', 'About to load fileoptions data.' );
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
//pb_backupbuddy::status( 'details', 'Fileoptions instance #17.' );
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
if (true !== ($fileoptions_result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034.387462. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $fileoptions_result);
return false;
}
//pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' );
$fileoptions =& $fileoptions_obj->options;
$fileoptions['_multipart_status'] = $result[1];
$fileoptions['updated_time'] = time();
pb_backupbuddy::status('details', 'Destination debugging details: `' . print_r($fileoptions, true) . '`.');
$fileoptions_obj->save();
unset($fileoptions_obj);
pb_backupbuddy::status('details', 'Next multipart chunk will be processed shortly. Now waiting on its cron...');
}
} else {
// Single all-at-once send.
if (false === $result) {
pb_backupbuddy::status('details', 'Completed send function. Failure. Post-send deletion will be skipped if enabled.');
} elseif (true === $result) {
pb_backupbuddy::status('details', 'Completed send function. Success.');
} else {
pb_backupbuddy::status('warning', 'Completed send function. Unknown result: `' . $result . '`.');
}
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #16.');
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
if (true !== ($fileoptions_result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Error #9034.387462. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $fileoptions_result);
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['updated_time'] = time();
unset($fileoptions_obj);
}
// File transfer completely finished successfully.
if (true === $result) {
$fileSize = filesize($file);
$serial = backupbuddy_core::get_serial_from_file($file);
// Handle deletion of send file if enabled.
if (true === $delete_after && false !== $result) {
pb_backupbuddy::status('details', __('Post-send deletion enabled.', 'it-l10n-backupbuddy'));
if (false === $result) {
pb_backupbuddy::status('details', 'Skipping post-send deletion since transfer failed.');
} else {
pb_backupbuddy::status('details', 'Performing post-send deletion since transfer succeeded.');
pb_backupbuddy::status('details', 'Deleting local file `' . $file . '`.');
// Handle post-send deletion on success.
if (file_exists($file)) {
$unlink_result = @unlink($file);
if (true !== $unlink_result) {
pb_backupbuddy::status('error', 'Unable to unlink local file `' . $file . '`.');
}
}
if (file_exists($file)) {
// File still exists.
pb_backupbuddy::status('details', __('Error. Unable to delete local file `' . $file . '` after send as set in settings.', 'it-l10n-backupbuddy'));
backupbuddy_core::mail_error('BackupBuddy was unable to delete local file `' . $file . '` after successful remove transfer though post-remote send deletion is enabled. You may want to delete it manually. This can be caused by permission problems or improper server configuration.');
} else {
// Deleted.
pb_backupbuddy::status('details', __('Deleted local archive after successful remote destination send based on settings.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('archiveDeleted', '');
}
}
} else {
pb_backupbuddy::status('details', 'Post-send deletion not enabled.');
}
// Send email notification if enabled.
if ('' != pb_backupbuddy::$options['email_notify_send_finish']) {
pb_backupbuddy::status('details', __('Sending finished destination send email notification.', 'it-l10n-backupbuddy'));
$extraReplacements = array();
$extraReplacements = array('{backup_file}' => $file, '{backup_size}' => $fileSize, '{backup_serial}' => $serial);
backupbuddy_core::mail_notify_scheduled($serial, 'destinationComplete', __('Destination send complete to', 'it-l10n-backupbuddy') . ' ' . backupbuddy_core::pretty_destination_type($destination_settings['type']), $extraReplacements);
} else {
pb_backupbuddy::status('details', __('Finished sending email NOT enabled. Skipping.', 'it-l10n-backupbuddy'));
}
// Save notification of final results.
$data = array();
$data['serial'] = $serial;
$data['file'] = $file;
$data['size'] = $fileSize;
$data['pretty_size'] = pb_backupbuddy::$format->file_size($fileSize);
backupbuddy_core::addNotification('remote_send_success', 'Remote file transfer completed', 'A file has successfully completed sending to a remote location.', $data);
}
// NOTE: Call this before removing status serial so it shows in log.
pb_backupbuddy::status('details', 'Ending send() function pass.');
// Return logging to normal file.
if ('' != $send_id) {
pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
}
return $result;
}
示例7: start
public function start($backupFile, $skipUnzip = false)
{
$this->_before(__FUNCTION__);
if (!file_exists($backupFile)) {
return $this->_error('Unable to access backup file `' . $backupFile . '`. Verify it still exists and has proper read permissions.');
}
$this->_state['archive'] = $backupFile;
$serial = backupbuddy_core::get_serial_from_file(basename($backupFile));
$this->_state['serial'] = $serial;
unset($backupFile);
unset($serial);
if (defined('PB_STANDALONE') && true === PB_STANDALONE) {
$mysql_9010_log = ABSPATH . 'importbuddy/mysql_9010_log-' . pb_backupbuddy::$options['log_serial'] . '.txt';
if (file_exists($mysql_9010_log)) {
@unlink($mysql_9010_log);
}
}
if (true !== $skipUnzip) {
// Get zip meta information.
$customTitle = 'Backup Details';
pb_backupbuddy::status('details', 'Attempting to retrieve zip meta data from comment.');
if (false !== ($metaInfo = backupbuddy_core::getZipMeta($this->_state['archive']))) {
pb_backupbuddy::status('details', 'Found zip meta data.');
} else {
pb_backupbuddy::status('details', 'Did not find zip meta data.');
}
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 DAT file.
pb_backupbuddy::status('details', 'Calculating possible DAT file locations.');
$detectedDatLocation = '';
$possibleDatLocations = array();
if (isset($metaInfo['dat_path'])) {
$possibleDatLocations[] = $metaInfo['dat_path'][1];
// DAT file location encoded in meta info. Should always be valid.
}
$possibleDatLocations[] = 'wp-content/uploads/backupbuddy_temp/' . $this->_state['serial'] . '/backupbuddy_dat.php';
// Full backup.
$possibleDatLocations[] = 'backupbuddy_dat.php';
// DB backup. (look for this second in case user left an old dat file in root).
pb_backupbuddy::status('details', 'Possible DAT file locations: `' . implode(';', $possibleDatLocations) . '`.');
$possibleDatLocations = array_unique($possibleDatLocations);
if (true === $skipUnzip) {
// Only look for DAT file in filesystem. Zip should be pre-extracted, eg by the user manually.
pb_backupbuddy::status('details', 'Looking for DAT file in local filesystem (instead of in zip) since advanced skip unzip option set.');
foreach ($possibleDatLocations as $possibleDatLocation) {
// Look for DAT file in filesystem.
pb_backupbuddy::status('details', 'Does `' . ABSPATH . $possibleDatLocation . '` exist?');
if (true === file_exists(ABSPATH . $possibleDatLocation)) {
pb_backupbuddy::status('details', 'Yes, exists.');
$detectedDatLocation = $possibleDatLocation;
break;
} else {
pb_backupbuddy::status('details', 'No, does not exist.');
}
}
if ('' == $detectedDatLocation) {
$message = 'Unable to find the DAT file for this backup archive pre-extracted in the filesystem. Make sure you have already unzipped this backup into the same directory as importbuddy.php.';
return $this->_error($message);
}
} else {
// Look for DAT file inside of zip archive.
pb_backupbuddy::status('details', 'Looking for DAT file in zip archive itself.');
foreach ($possibleDatLocations as $possibleDatLocation) {
// Look for DAT file in zip.
if (true === $zipbuddy->file_exists($this->_state['archive'], $possibleDatLocation, $leave_open = true)) {
$detectedDatLocation = $possibleDatLocation;
break;
}
}
// end foreach.
}
if ('' == $detectedDatLocation) {
return $this->_error('Unable to determine DAT file location. It may be missing OR the backup zip file may be incomplete or corrupted. Verify the backup zip has fully uploaded or re-upload it. You can try manually unzipping then selecting the advanced option to skip unzip.');
}
pb_backupbuddy::status('details', 'Confirmed DAT file location: `' . $detectedDatLocation . '`.');
$this->_state['datLocation'] = $detectedDatLocation;
unset($metaInfo);
// No longer need anything from the meta information.
if (true !== $skipUnzip) {
function mkdir_recursive($path)
{
if (empty($path)) {
// prevent infinite loop on bad path
return;
}
is_dir(dirname($path)) || mkdir_recursive(dirname($path));
return is_dir($path) || mkdir($path);
}
// Load DAT file contents.
pb_backupbuddy::status('details', 'Creating temporary file directory `' . $this->_state['tempPath'] . '`.');
pb_backupbuddy::$filesystem->unlink_recursive($this->_state['tempPath']);
// Remove if already exists.
mkdir_recursive($this->_state['tempPath']);
// Make empty directory.
// Restore DAT file.
pb_backupbuddy::status('details', 'Extracting DAT file.');
//.........这里部分代码省略.........
示例8: die
if (!is_admin()) {
die('Access denied.');
}
// File viewer (view content only) in the file restore page.
/* restore_file_view()
*
* View contents of a file (text) that is inside a zip archive.
*
*/
pb_backupbuddy::$ui->ajax_header(true, false);
// js, no padding
$archive_file = pb_backupbuddy::_GET('archive');
// archive to extract from.
$file = pb_backupbuddy::_GET('file');
// file to extract.
$serial = backupbuddy_core::get_serial_from_file($archive_file);
// serial of archive.
$temp_file = uniqid();
// temp filename to extract into.
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
$zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
// Calculate temp directory & lock it down.
$temp_dir = get_temp_dir();
$destination = $temp_dir . 'backupbuddy-' . $serial;
if (!file_exists($destination) && false === mkdir($destination)) {
$error = 'Error #458485945b: Unable to create temporary location.';
pb_backupbuddy::status('error', $error);
die($error);
}
// If temp directory is within webroot then lock it down.
$temp_dir = str_replace('\\', '/', $temp_dir);
示例9: glob
$old_backup_dir = backupbuddy_core::getBackupDirectory();
$new_backup_dir = $backup_directory;
// Move all files from old backup to new.
$old_backups_moved = 0;
$old_backups = glob($old_backup_dir . 'backup*.zip');
if (!is_array($old_backups) || empty($old_backups)) {
// On failure glob() returns false or an empty array depending on server settings so normalize here.
$old_backups = array();
}
foreach ($old_backups as $old_backup) {
if (false === rename($old_backup, $new_backup_dir . basename($old_backup))) {
pb_backupbuddy::alert('ERROR: Unable to move backup "' . basename($old_backup) . '" to new storage directory. Manually move it or delete it for security and to prevent it from being backed up within backups.');
} else {
// rename success.
$old_backups_moved++;
$serial = backupbuddy_core::get_serial_from_file(basename($old_backup));
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptions_files = glob(backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt');
if (!is_array($fileoptions_files)) {
$fileoptions_files = array();
}
foreach ($fileoptions_files as $fileoptions_file) {
pb_backupbuddy::status('details', 'Fileoptions instance #21.');
$backup_options = new pb_backupbuddy_fileoptions($fileoptions_file);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', __('Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
continue;
}
if (isset($backup_options->options[$serial])) {
if (isset($backup_options->options['archive_file'])) {
$backup_options->options['archive_file'] = str_replace($old_backup_dir, $new_backup_dir, $backup_options->options['archive_file']);
示例10: restore_file_restore
public function restore_file_restore()
{
$success = false;
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
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.
$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);
$serial = backupbuddy_core::get_serial_from_file($archive_file);
// serial of archive.
foreach ($files as $file) {
$file = str_replace('*', '', $file);
// Remove any wildcard.
if (file_exists(ABSPATH . $file) && is_dir(ABSPATH . $file)) {
if (($file_count = @scandir(ABSPATH . $file)) && count($file_count) > 2) {
pb_backupbuddy::status('error', __('Error #9036. The destination directory being restored already exists and is NOT empty. The directory will not be restored to prevent inadvertently losing files within the existing directory. Delete existing directory first if you wish to proceed or restore individual files.', 'it-l10n-backupbuddy') . ' Existing directory: `' . ABSPATH . $file . '`.');
echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
pb_backupbuddy::flush();
pb_backupbuddy::$ui->ajax_footer();
die;
}
}
}
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
$zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
// Calculate temp directory & lock it down.
$temp_dir = get_temp_dir();
$destination = $temp_dir . 'backupbuddy-' . $serial;
if (!file_exists($destination) && false === mkdir($destination, 0777, true)) {
$error = 'Error #458485945: Unable to create temporary location.';
pb_backupbuddy::status('error', $error);
echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
pb_backupbuddy::flush();
pb_backupbuddy::$ui->ajax_footer();
die;
}
// If temp directory is within webroot then lock it down.
$temp_dir = str_replace('\\', '/', $temp_dir);
// Normalize for Windows.
$temp_dir = rtrim($temp_dir, '/\\') . '/';
// Enforce single trailing slash.
if (FALSE !== stristr($temp_dir, ABSPATH)) {
// Temp dir is within webroot.
pb_backupbuddy::anti_directory_browsing($destination);
}
unset($temp_dir);
pb_backupbuddy::status('details', 'Extracting into temporary directory "' . $destination . '".');
pb_backupbuddy::status('details', 'Files to extract: `' . htmlentities(pb_backupbuddy::_GET('files')) . '`.');
// Make sure temp subdirectories exist.
/*
foreach( $files as $file => $null ) {
mkdir( $destination . '/' . basename( $file ), 0777, true );
}
*/
pb_backupbuddy::flush();
$extract_success = true;
$extract_result = $zipbuddy->extract(backupbuddy_core::getBackupDirectory() . $archive_file, $destination, $files);
if (false === $extract_result) {
// failed.
pb_backupbuddy::status('error', 'Error #584984458b. Unable to extract.');
$extract_success = false;
} else {
// success.
// Verify all files/directories to be extracted exist in temp destination directory. If any missing then delete everything and bail out.
foreach ($files as &$file) {
$file = str_replace('*', '', $file);
// Remove any wildcard.
if (!file_exists($destination . '/' . $file)) {
// Cleanup.
//.........这里部分代码省略.........
示例11: start
public function start($backupFile)
{
$this->_before(__FUNCTION__);
$this->_state['archive'] = $backupFile;
$serial = backupbuddy_core::get_serial_from_file(basename($backupFile));
$this->_state['serial'] = $serial;
$this->_state['tempPath'] = backupbuddy_core::getTempDirectory() . $this->_state['type'] . '_' . $this->_state['serial'] . '/';
unset($backupFile);
unset($serial);
// Get zip meta information.
$customTitle = 'Backup Details';
pb_backupbuddy::status('details', 'Attempting to retrieve zip meta data from comment.');
if (false !== ($metaInfo = backupbuddy_core::getZipMeta($this->_state['archive']))) {
pb_backupbuddy::status('details', 'Found zip meta data.');
} else {
pb_backupbuddy::status('details', 'Did not find zip meta data.');
}
//$this->_state['meta'] = $metaInfo;
pb_backupbuddy::status('details', 'Loading zipbuddy.');
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
$zipbuddy = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
pb_backupbuddy::status('details', 'Zipbuddy loaded.');
// Find DAT file.
pb_backupbuddy::status('details', 'Calculating possible DAT file locations.');
$possibleDatLocations = array();
if (isset($metaInfo['dat_path'])) {
$possibleDatLocations[] = $metaInfo['dat_path'][1];
// DAT file location encoded in meta info. Should always be valid.
}
$possibleDatLocations[] = 'backupbuddy_dat.php';
// DB backup.
$possibleDatLocations[] = 'wp-content/uploads/backupbuddy_temp/' . $this->_state['serial'] . '/backupbuddy_dat.php';
// Full backup.
pb_backupbuddy::status('details', 'Possible DAT file locations: `' . implode(';', $possibleDatLocations) . '`.');
$possibleDatLocations = array_unique($possibleDatLocations);
foreach ($possibleDatLocations as $possibleDatLocation) {
if (true === $zipbuddy->file_exists($this->_state['archive'], $possibleDatLocation, $leave_open = true)) {
$detectedDatLocation = $possibleDatLocation;
break;
}
}
// end foreach.
pb_backupbuddy::status('details', 'Confirmed DAT file location: `' . $detectedDatLocation . '`.');
$this->_state['datLocation'] = $detectedDatLocation;
unset($metaInfo);
// No longer need anything from the meta information.
// Load DAT file contents.
pb_backupbuddy::status('details', 'Creating temporary file directory `' . $this->_state['tempPath'] . '`.');
pb_backupbuddy::$filesystem->unlink_recursive($this->_state['tempPath']);
// Remove if already exists.
mkdir($this->_state['tempPath']);
// Make empty directory.
// Restore DAT file.
pb_backupbuddy::status('details', 'Extracting DAT file.');
$files = array($detectedDatLocation => 'backupbuddy_dat.php');
require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php';
$result = backupbuddy_restore_files::restore($this->_state['archive'], $files, $this->_state['tempPath'], $zipbuddy);
echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
pb_backupbuddy::flush();
if (false === $result) {
$this->_error('Error #85484: Unable to retrieve DAT file. This is a fatal error.');
return false;
}
if (false === ($datData = backupbuddy_core::get_dat_file_array($this->_state['tempPath'] . 'backupbuddy_dat.php'))) {
$this->_error('Error #4839484: Unable to retrieve DAT file. The backup may have failed opening due to lack of memory, permissions issues, or other reason. Use ImportBuddy to restore or check the Advanced Log above for details.');
return false;
}
$this->_state['dat'] = $datData;
pb_backupbuddy::status('details', 'DAT file extracted.');
if (site_url() != $this->_state['dat']['siteurl']) {
$this->_error(__('Error #5849843: Site URL does not match. You cannot roll back the database if the URL has changed or for backups or another site. Use importbuddy.php to restore or migrate instead.', 'it-l10n-backupbuddy'));
return false;
}
global $wpdb;
if ($this->_state['dat']['db_prefix'] != $wpdb->prefix) {
$this->_error(__('Error #2389394: Database prefix does not match. You cannot roll back the database if the database prefix has changed or for backups or another site. Use importbuddy.php to restore or migrate instead.', 'it-l10n-backupbuddy'));
return false;
}
// Store this serial in the db for future cleanup.
if ('rollback' == $this->_state['type']) {
pb_backupbuddy::$options['rollback_cleanups'][$this->_state['serial']] = time();
pb_backupbuddy::save();
// Generate UNDO script.
pb_backupbuddy::status('details', 'Generating undo script.');
$this->_state['undoFile'] = 'backupbuddy_rollback_undo-' . $this->_state['serial'] . '.php';
$undoURL = rtrim(site_url(), '/\\') . '/' . $this->_state['undoFile'];
if (false === copy(dirname(__FILE__) . '/_rollback_undo.php', ABSPATH . $this->_state['undoFile'])) {
$this->_error(__('Warning: Unable to create undo script in site root. You will not be able to automated undoing the rollback if something fails so BackupBuddy will not continue.', 'it-l10n-backupbuddy'));
return false;
}
$this->_state['undoURL'] = $undoURL;
}
pb_backupbuddy::status('details', 'Finished starting function.');
return true;
}
示例12: send
public static function send($destination_settings, $files, $send_id = '', $delete_after = false)
{
if ('' != $send_id) {
pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
pb_backupbuddy::status('details', '----- Initiating master send function. Post-send deletion: ' . $delete_after);
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
if (!file_exists($fileoptions_file)) {
//pb_backupbuddy::status( 'details', 'Fileoptions file `' . $fileoptions_file . '` does not exist yet; creating.' );
//pb_backupbuddy::status( 'details', 'Fileoptions instance #19.' );
$fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = true, $create_file = true);
} else {
//pb_backupbuddy::status( 'details', 'Fileoptions file exists; loading.' );
//pb_backupbuddy::status( 'details', 'Fileoptions instance #18.' );
$fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = false, $create_file = false);
}
if (true !== ($result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
//pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' );
$fileoptions =& $fileoptions_obj->options;
if ('' == $fileoptions) {
$fileoptions = backupbuddy_core::get_remote_send_defaults();
$fileoptions['type'] = $destination_settings['type'];
if (!is_array($files)) {
$fileoptions['file'] = $files;
} else {
$fileoptions['file'] = $files[0];
}
$fileoptions_obj->save();
}
if (isset($fileoptions['status']) && 'aborted' == $fileoptions['status']) {
pb_backupbuddy::status('warning', 'Destination send triggered on an ABORTED transfer. Ending send function.');
return false;
}
unset($fileoptions_obj);
}
if (false === ($destination = self::_init_destination($destination_settings))) {
echo '{Error #546893498a. Destination configuration file missing.}';
if ('' != $send_id) {
pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
}
return false;
}
$destination_settings = $destination['settings'];
// Settings with defaults applied, normalized, etc.
//$destination_info = $destination['info'];
if (!is_array($files)) {
$files = array($files);
}
$originalFiles = $files;
$files_with_sizes = '';
foreach ($files as $index => $file) {
if ('' == $file) {
unset($files[$index]);
continue;
// Not actually a file to send.
}
if (!file_exists($file)) {
pb_backupbuddy::status('error', 'Error #58459458743. The file that was attempted to be sent to a remote destination, `' . $file . '`, was not found. It either does not exist or permissions prevent accessing it.');
if ('' != $send_id) {
pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
}
return false;
}
$files_with_sizes .= $file . ' (' . pb_backupbuddy::$format->file_size(filesize($file)) . '); ';
}
//pb_backupbuddy::status( 'details', 'Sending files `' . $files_with_sizes . '` to destination type `' . $destination_settings['type'] . '` titled `' . $destination_settings['title'] . '`.' );
unset($files_with_sizes);
if (!method_exists($destination['class'], 'send')) {
pb_backupbuddy::status('error', 'Destination class `' . $destination['class'] . '` does not support send operation -- missing function.');
if ('' != $send_id) {
pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
}
return false;
}
//pb_backupbuddy::status( 'details', 'Calling send function.' );
//$result = $destination_class::send( $destination_settings, $files );
global $pb_backupbuddy_destination_errors;
$pb_backupbuddy_destination_errors = array();
$result = call_user_func_array("{$destination['class']}::send", array($destination_settings, $files, $send_id, $delete_after));
if ($result === false) {
$error_details = implode('; ', $pb_backupbuddy_destination_errors);
if ('' != $error_details) {
$error_details = ' Details: ' . $error_details;
}
$log_directory = backupbuddy_core::getLogDirectory();
$preError = 'There was an error sending to the remote destination. One or more files may have not been fully transferred. Please see error details for additional information. If the error persists, enable full error logging and try again for full details and troubleshooting. Details: ' . "\n\n";
$logFile = $log_directory . 'status-remote_send-' . $send_id . '_' . backupbuddy_core::get_serial_from_file($file) . '.txt';
pb_backupbuddy::status('details', 'Looking for remote send log file `' . $logFile . '`.');
if (!file_exists($logFile)) {
pb_backupbuddy::status('details', 'Remote send log file not found.');
backupbuddy_core::mail_error($preError . $error_details);
} else {
// Log exists. Attach.
pb_backupbuddy::status('details', 'Remote send log file found. Attaching to error email.');
backupbuddy_core::mail_error($preError . $error_details . "\n\nSee the attached log for details.", '', array($logFile));
}
// Save error details into fileoptions for this send.
//.........这里部分代码省略.........
示例13: backups_list
public static function backups_list($type = 'default', $subsite_mode = false)
{
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup' && is_array(pb_backupbuddy::_POST('items'))) {
$needs_save = false;
pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
// Security check to prevent unauthorized deletions by posting from a remote place.
$deleted_files = array();
foreach (pb_backupbuddy::_POST('items') as $item) {
if (file_exists(backupbuddy_core::getBackupDirectory() . $item)) {
if (@unlink(backupbuddy_core::getBackupDirectory() . $item) === true) {
$deleted_files[] = $item;
// Cleanup any related fileoptions files.
$serial = backupbuddy_core::get_serial_from_file($item);
$backup_files = glob(backupbuddy_core::getBackupDirectory() . '*.zip');
if (!is_array($backup_files)) {
$backup_files = array();
}
if (count($backup_files) > 5) {
// Keep a minimum number of backups in array for stats.
$this_serial = self::get_serial_from_file($item);
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt';
if (file_exists($fileoptions_file)) {
@unlink($fileoptions_file);
}
if (file_exists($fileoptions_file . '.lock')) {
@unlink($fileoptions_file . '.lock');
}
$needs_save = true;
}
} else {
pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
}
}
// End if file exists.
}
// End foreach.
if ($needs_save === true) {
pb_backupbuddy::save();
}
pb_backupbuddy::alert(__('Deleted:', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
}
// End if deleting backup(s).
$backups = array();
$backup_sort_dates = array();
$files = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
if (is_array($files) && !empty($files)) {
// For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
$backup_prefix = self::backup_prefix();
// Backup prefix for this site. Used for MS checking that this user can see this backup.
foreach ($files as $file_id => $file) {
if ($subsite_mode === true && is_multisite()) {
// If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
// Only allow viewing of their own backups.
if (!strstr($file, $backup_prefix)) {
unset($files[$file_id]);
// Remove this backup from the list. This user does not have access to it.
continue;
// Skip processing to next file.
}
}
$serial = backupbuddy_core::get_serial_from_file($file);
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
// Will create file to hold integrity data if nothing exists.
$backup_integrity = backupbuddy_core::backup_integrity_check($file, $backup_options);
// Backup status.
$pretty_status = array(true => '<span class="pb_label pb_label-success">Good</span>', 'pass' => '<span class="pb_label pb_label-success">Good</span>', false => '<span class="pb_label pb_label-important">Bad</span>', 'fail' => '<span class="pb_label pb_label-important">Bad</span>');
// Backup type.
$pretty_type = array('full' => 'Full', 'db' => 'Database', 'files' => 'Files');
// Defaults...
$detected_type = '';
$file_size = '';
$modified = '';
$modified_time = 0;
$integrity = '';
if (is_array($backup_options->options)) {
// Data intact... put it all together.
// Calculate time ago.
$time_ago = '';
if (isset($backup_options->options['integrity']) && isset($backup_options->options['integrity']['modified'])) {
$time_ago = pb_backupbuddy::$format->time_ago($backup_options->options['integrity']['modified']) . ' ago';
}
$detected_type = pb_backupbuddy::$format->prettify($backup_options->options['integrity']['detected_type'], $pretty_type);
if ($detected_type == '') {
$detected_type = 'Unknown';
} else {
if (isset($backup_options->options['profile'])) {
$detected_type = '
<div>
<span style="color: #AAA; float: left;">' . $detected_type . '</span>
<span style="display: inline-block; float: left; height: 15px; border-right: 1px solid #EBEBEB; margin-left: 6px; margin-right: 6px;"></span>
' . htmlentities($backup_options->options['profile']['title']) . '
</div>
';
}
}
$file_size = pb_backupbuddy::$format->file_size($backup_options->options['integrity']['size']);
$modified = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['integrity']['modified']), 'l, F j, Y - g:i:s a');
$modified_time = $backup_options->options['integrity']['modified'];
if (isset($backup_options->options['integrity']['status'])) {
//.........这里部分代码省略.........
示例14: 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;
}
示例15: getBackupTypeFromFile
public static function getBackupTypeFromFile($file, $quiet = false)
{
if (false === $quiet) {
pb_backupbuddy::status('details', 'Detecting backup type if possible.');
}
// Try to figure out type via filename.
if (stristr($file, '-db-') !== false) {
$type = 'db';
} elseif (stristr($file, '-full-') !== false) {
$type = 'full';
} elseif (stristr($file, '-files-') !== false) {
$type = 'files';
}
if (isset($type)) {
if (false === $quiet) {
pb_backupbuddy::status('details', 'Detected backup type as `' . $type . '` via filename.');
}
return $type;
}
// See if we can get backup type from fileoptions data.
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . backupbuddy_core::get_serial_from_file($file) . '.txt';
$backup_options = new pb_backupbuddy_fileoptions($fileoptionsFile, $read_only = true, $ignore_lock = true);
if (true !== ($result = $backup_options->is_ok())) {
//pb_backupbuddy::status( 'warning', 'Warning only: Unable to open fileoptions file `' . $fileoptionsFile . '`. This may be normal.' );
} else {
if (isset($backup_options->options['integrity']['detected_type'])) {
if (false === $quiet) {
pb_backupbuddy::status('details', 'Detected backup type as `' . $backup_options->options['integrity']['detected_type'] . '` via integrity check data.');
}
return $backup_options->options['integrity']['detected_type'];
}
}
return '';
// Type unknown.
}