本文整理汇总了PHP中backupbuddy_core::get_dat_file_array方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::get_dat_file_array方法的具体用法?PHP backupbuddy_core::get_dat_file_array怎么用?PHP backupbuddy_core::get_dat_file_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::get_dat_file_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
//.........这里部分代码省略.........
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.');
$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;
}
$datFile = $this->_state['tempPath'] . 'backupbuddy_dat.php';
} else {
$datFile = $this->_state['datLocation'];
}
if (false === ($datData = backupbuddy_core::get_dat_file_array($datFile))) {
$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 (defined('PB_STANDALONE') && true === PB_STANDALONE) {
$simpleVersion = substr(pb_backupbuddy::$options['bb_version'], 0, strpos(pb_backupbuddy::$options['bb_version'], ' '));
if (isset($this->_state['dat']['backupbuddy_version']) && version_compare($this->_state['dat']['backupbuddy_version'], $simpleVersion, '>')) {
pb_backupbuddy::status('error', 'Warning: You are attempting to restore an archive which was created with a newer version of BackupBuddy (' . $this->_state['dat']['backupbuddy_version'] . ') than this ImportBuddy (' . $simpleVersion . '). For best results use an ImportBuddy that is as least as up to date as the BackupBuddy which created the archive.');
}
}
if ('rollback' == $this->_state['type']) {
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;
}
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;
}
示例2: 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;
}
示例3: get_backup_dat
function get_backup_dat($dat_file)
{
require_once pb_backupbuddy::plugin_path() . '/classes/import.php';
$import = new pb_backupbuddy_import();
return backupbuddy_core::get_dat_file_array($dat_file);
}
示例4: extract_files
/**
* extract()
*
* Extract backup zip file.
*
* @return array True if the extraction was a success OR skipping of extraction is set.
*/
function extract_files()
{
// Zip & Unzip library setup.
require_once ABSPATH . 'importbuddy/lib/zipbuddy/zipbuddy.php';
pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(ABSPATH, array(), 'unzip');
$backup_archive = ABSPATH . pb_backupbuddy::$options['file'];
if (true === pb_backupbuddy::$options['skip_files']) {
// Option to skip all file updating / extracting.
pb_backupbuddy::status('message', 'Skipped extracting files based on debugging options.');
} else {
pb_backupbuddy::set_greedy_script_limits();
pb_backupbuddy::status('message', 'Unzipping into `' . ABSPATH . '`');
$destination_directory = ABSPATH;
// Set compatibility mode if defined in advanced options.
$compatibility_mode = false;
// Default to no compatibility mode.
if (pb_backupbuddy::$options['force_compatibility_medium'] != false) {
$compatibility_mode = 'ziparchive';
} elseif (pb_backupbuddy::$options['force_compatibility_slow'] != false) {
$compatibility_mode = 'pclzip';
}
// Extract zip file & verify it worked.
if (true !== ($result = pb_backupbuddy::$classes['zipbuddy']->unzip($backup_archive, $destination_directory, $compatibility_mode))) {
pb_backupbuddy::status('error', 'Failed unzipping archive.');
pb_backupbuddy::alert('Failed unzipping archive.', true);
return false;
}
pb_backupbuddy::status('details', 'Success extracting Zip File "' . ABSPATH . pb_backupbuddy::$options['file'] . '" into "' . ABSPATH . '".');
}
// End extraction not skipped.
// Made it here so zip returned true OR skipped unzip step.
// Handle meta data in comment.
pb_backupbuddy::status('details', 'Retrieving meta data from ZIP file (if any).');
$comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_archive);
$comment = backupbuddy_core::normalize_comment_data($comment);
$comment_text = print_r($comment, true);
$comment_text = str_replace(array("\n", "\r"), '; ', $comment_text);
pb_backupbuddy::status('details', 'Backup meta data: `' . $comment_text . '`.');
// Use meta to find DAT file (if possible). BB v3.3+.
$dat_file = '';
if ('' != $comment['dat_path']) {
// Specific DAT location is known.
pb_backupbuddy::status('details', 'Checking for DAT file as reported by meta data as file `' . ABSPATH . $comment['dat_path'] . '`.');
if (file_exists(ABSPATH . $comment['dat_path'])) {
$dat_file = ABSPATH . $comment['dat_path'];
pb_backupbuddy::status('details', 'DAT file found based on meta path.');
} else {
pb_backupbuddy::status('warning', 'DAT file was not found as reported by meta data. This is unusual but may not be fatal. Commencing search for file...');
}
}
// Deduce DAT file location based on backup filename. BB < v3.3.
if ('' == $dat_file) {
pb_backupbuddy::status('details', 'Scanning for DAT file based on backup file name.');
$dat_file_locations = array(ABSPATH . 'wp-content/uploads/temp_' . pb_backupbuddy::$options['zip_id'] . '/backupbuddy_dat.php', ABSPATH . 'wp-content/uploads/backupbuddy_temp/' . pb_backupbuddy::$options['zip_id'] . '/backupbuddy_dat.php', ABSPATH . 'backupbuddy_dat.php');
$dat_file = '';
foreach ($dat_file_locations as $dat_file_location) {
if (file_exists($dat_file_location)) {
$dat_file = $dat_file_location;
break;
}
}
if ('' == $dat_file) {
// DAT not found.
$error_message = 'Error #9004: Key files missing. Backup data file, backupbuddy_dat.php was not found in the extracted files in any expected location. The unzip process either failed to fully complete, you renamed the backup ZIP file (rename it back to correct this), or the zip file is not a proper BackupBuddy backup.';
pb_backupbuddy::status('error', $error_message);
pb_backupbuddy::alert($error_message, true, '9004');
return false;
}
pb_backupbuddy::status('details', 'Successfully found DAT file based on backup file name: `' . $dat_file . '`.');
}
// Get DAT file contents & save into options..
if (false === (pb_backupbuddy::$options['dat_file'] = backupbuddy_core::get_dat_file_array($dat_file))) {
die('Error #43784334: Fatal error getting DAT file. Import halted.');
}
pb_backupbuddy::$options['temp_serial_directory'] = basename($dat_file);
pb_backupbuddy::save();
return true;
}