本文整理汇总了PHP中backupbuddy_core::getZipMeta方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::getZipMeta方法的具体用法?PHP backupbuddy_core::getZipMeta怎么用?PHP backupbuddy_core::getZipMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::getZipMeta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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.');
//.........这里部分代码省略.........
示例2: array
} else {
$status_text = '<span class="pb_label pb_label-important">Fail</span>';
}
$tests[] = array($test['test'], $status_text);
}
}
}
$columns = array(__('Integrity Test', 'it-l10n-backupbuddy'), __('Status', 'it-l10n-backupbuddy'));
pb_backupbuddy::$ui->list_table($tests, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;'));
}
// end $integrity['status_details'] is an array.
echo '<br><br>';
//***** END TESTS AND RESULTS.
// Output meta info table (if any).
$metaInfo = array();
if (isset($integrity['file']) && false === ($metaInfo = backupbuddy_core::getZipMeta(backupbuddy_core::getBackupDirectory() . $integrity['file']))) {
// $backup_options->options['archive_file']
echo '<i>No meta data found in zip comment. Skipping meta information display.</i>';
} else {
pb_backupbuddy::$ui->list_table($metaInfo, array('columns' => array('Backup Details', 'Value'), 'css' => 'width: 100%; min-width: 200px;'));
}
echo '<br><br>';
//***** BEGIN STEPS.
$steps = array();
$steps[] = array('Start Time', $start_time, '');
if (isset($backup_options->options['steps'])) {
foreach ($backup_options->options['steps'] as $step) {
if (isset($step['finish_time']) && $step['finish_time'] != 0) {
// Step name.
if ($step['function'] == 'backup_create_database_dump') {
if (count($step['args'][0]) == 1) {
示例3: integrity_status
public function integrity_status()
{
$serial = pb_backupbuddy::_GET('serial');
$serial = str_replace('/\\', '', $serial);
pb_backupbuddy::load();
pb_backupbuddy::$ui->ajax_header();
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::alert(__('Unable to access fileoptions data file.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
die;
}
$integrity = $backup_options->options['integrity'];
//echo '<p><b>' . __( 'Backup File', 'it-l10n-backupbuddy' ) . '</b>: ' . $integrity['file'] . '</p>';
$start_time = 'Unknown';
$finish_time = 'Unknown';
if (isset($backup_options->options['start_time'])) {
$start_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['start_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($backup_options->options['finish_time']) . ' ago)</span>';
if ($backup_options->options['finish_time'] > 0) {
$finish_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['finish_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($backup_options->options['finish_time']) . ' ago)</span>';
} else {
// unfinished.
$finish_time = '<i>Unfinished</i>';
}
}
//***** BEGIN TESTS AND RESULTS.
if (isset($integrity['status_details'])) {
// $integrity['status_details'] is NOT array (old, pre-3.1.9).
echo '<h3>Integrity Technical Details</h3>';
echo '<textarea style="width: 100%; height: 175px;" wrap="off">';
foreach ($integrity as $item_name => $item_value) {
$item_value = str_replace('<br />', '<br>', $item_value);
$item_value = str_replace('<br><br>', '<br>', $item_value);
$item_value = str_replace('<br>', "\n ", $item_value);
echo $item_name . ' => ' . $item_value . "\n";
}
echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.';
} else {
// $integrity['status_details'] is array.
echo '<br>';
if (isset($integrity['status_details'])) {
// PRE-v4.0 Tests.
function pb_pretty_results($value)
{
if ($value === true) {
return '<span class="pb_label pb_label-success">Pass</span>';
} else {
return '<span class="pb_label pb_label-important">Fail</span>';
}
}
// The tests & their status..
$tests = array();
$tests[] = array('BackupBackup data file exists', pb_pretty_results($integrity['status_details']['found_dat']));
$tests[] = array('Database SQL file exists', pb_pretty_results($integrity['status_details']['found_sql']));
if ($integrity['detected_type'] == 'full') {
// Full backup.
$tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig']));
} elseif ($integrity['detected_type'] == 'files') {
// Files only backup.
$tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig']));
} else {
// DB only.
$tests[] = array('WordPress wp-config.php exists (full/files backups only)', '<span class="pb_label pb_label-success">N/A</span>');
}
} else {
// 4.0+ Tests.
$tests = array();
foreach ((array) $integrity['tests'] as $test) {
if (true === $test['pass']) {
$status_text = '<span class="pb_label pb_label-success">Pass</span>';
} else {
$status_text = '<span class="pb_label pb_label-important">Fail</span>';
}
$tests[] = array($test['test'], $status_text);
}
}
$columns = array(__('Integrity Test', 'it-l10n-backupbuddy'), __('Status', 'it-l10n-backupbuddy'));
pb_backupbuddy::$ui->list_table($tests, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;'));
}
// end $integrity['status_details'] is an array.
echo '<br><br>';
//***** END TESTS AND RESULTS.
// Output meta info table (if any).
if (false === ($metaInfo = backupbuddy_core::getZipMeta(backupbuddy_core::getBackupDirectory() . $integrity['file']))) {
// $backup_options->options['archive_file']
echo '<i>No meta data found in zip comment. Skipping meta information display.</i>';
} else {
pb_backupbuddy::$ui->list_table($metaInfo, array('columns' => array('Backup Details', 'Value'), 'css' => 'width: 100%; min-width: 200px;'));
}
echo '<br><br>';
//***** BEGIN STEPS.
$steps = array();
$steps[] = array('Start Time', $start_time, '');
if (isset($backup_options->options['steps'])) {
foreach ($backup_options->options['steps'] as $step) {
if (isset($step['finish_time']) && $step['finish_time'] != 0) {
// Step name.
if ($step['function'] == 'backup_create_database_dump') {
if (count($step['args'][0]) == 1) {
$step_name = 'Database dump (breakout: ' . $step['args'][0][0] . ')';
//.........这里部分代码省略.........
示例4: 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;
}