本文整理汇总了PHP中backupbuddy_core::getTempDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::getTempDirectory方法的具体用法?PHP backupbuddy_core::getTempDirectory怎么用?PHP backupbuddy_core::getTempDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::getTempDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($type, $existingState = '')
{
pb_backupbuddy::status('details', 'Constructing rollback class.');
if ('rollback' != $type && 'restore' != $type) {
$this->_error('Invalid restore type `' . htmlentities($type) . '`.');
return false;
}
register_shutdown_function(array(&$this, 'shutdown_function'));
pb_backupbuddy::status('details', 'Setting restore state defaults.');
$this->_state = array('type' => $type, 'archive' => '', 'serial' => '', 'tempPath' => '', 'data' => array(), 'undoURL' => '', 'forceMysqlMethods' => array(), 'autoAdvance' => true, 'maxExecutionTime' => backupbuddy_core::detectMaxExecutionTime(), 'dbImportPoint' => 0, 'zipMethodStrategy' => 'all', 'restoreFiles' => true, 'restoreDatabase' => true, 'migrateHtaccess' => true, 'databaseSettings' => array('server' => '', 'database' => '', 'username' => '', 'password' => '', 'prefix' => '', 'tempPrefix' => '', 'wipePrefix' => false, 'renamePrefix' => false, 'wipeDatabase' => false, 'ignoreSqlErrors' => false, 'sqlFiles' => array(), 'sqlFilesLocation' => '', 'databaseMethodStrategy' => 'php', 'importResumePoint' => '', 'importedResumeRows' => 0, 'importedResumeFails' => 0, 'importedResumeTime' => 0, 'migrateDatabase' => true, 'migrateDatabaseBruteForce' => true, 'migrateResumeSteps' => '', 'migrateResumePoint' => ''), 'cleanup' => array('deleteArchive' => true, 'deleteTempFiles' => true, 'deleteImportBuddy' => true, 'deleteImportLog' => true), 'potentialProblems' => array(), 'stepHistory' => array());
// Restore-specific default options.
if ('restore' == $type) {
$this->_state['skipUnzip'] = false;
$this->_state['restoreFiles'] = true;
$this->_state['restoreDatabase'] = true;
$this->_state['migrateHtaccess'] = true;
$this->_state['tempPath'] = ABSPATH . 'importbuddy/temp_' . pb_backupbuddy::$options['log_serial'] . '/';
} elseif ('rollback' == $type) {
$this->_state['tempPath'] = backupbuddy_core::getTempDirectory() . $this->_state['type'] . '_' . $this->_state['serial'] . '/';
}
if (is_array($existingState)) {
// User passed along an existing state to resume.
pb_backupbuddy::status('details', 'Using provided restore state data.');
$this->_state = $this->_array_replace_recursive($this->_state, $existingState);
}
// Check if a default state override exists. Used by automated restoring.
/*
if ( isset( pb_backupbuddy::$options['default_state_overrides'] ) && ( count( pb_backupbuddy::$options['default_state_overrides'] ) > 0 ) ) { // Default state overrides exist. Apply them.
$this->_state = array_merge( $this->_state, pb_backupbuddy::$options['default_state_overrides'] );
}
*/
pb_backupbuddy::status('details', 'Restore class constructed in `' . $type . '` mode.');
pb_backupbuddy::set_greedy_script_limits();
// Just always assume we need this during restores/rollback...
}
示例2: 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;
}
}
示例3: destination_send
public function destination_send($destination_settings, $files, $send_id = '', $delete_after = false, $identifier = '', $isRetry = false)
{
pb_backupbuddy::status('details', 'Beginning cron destination_send. Unique ID: `' . $identifier . '`.');
if ('' != $identifier) {
$lockFile = backupbuddy_core::getLogDirectory() . 'cronSend-' . $identifier . '.lock';
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
if (@file_exists($lockFile)) {
// Lock exists already. Duplicate run?
$attempts = @file_get_contents($lockFile);
$attempts++;
pb_backupbuddy::status('warning', 'Lock file exists and now shows ' . $attempts . ' attempts.');
$attempts = @file_get_contents($lockFile, $attempts);
return;
} else {
// No lock yet.
if (false === @file_put_contents($lockFile, '1')) {
pb_backupbuddy::status('warning', 'Unable to create destination send lock file `' . $lockFile . '`.');
} else {
pb_backupbuddy::status('details', 'Create destination send lock file `' . $lockFile . '`.');
}
}
}
pb_backupbuddy::status('details', 'Launching destination send via cron.');
if (!class_exists('backupbuddy_core')) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
if (true === backupbuddy_core::destination_send($destination_settings, $files, $send_id, $delete_after, $isRetry)) {
// completely finished, go ahead and clean up lock file.
/* DO not delete here as we need to keep this locked down a little longer...
if ( '' != $identifier ) {
if ( true === @unlink( $lockFile ) ) {
pb_backupbuddy::status( 'details', 'Removed destination lock file.' );
} else {
pb_backupbuddy::status( 'warning', 'Unable to remove destination lock file `' . $lockFile . '`.' );
}
}
*/
}
}
示例4: array
$wp_settings[] = array('Upload Base URL', $wp_upload_dir['baseurl'], 'wp_upload_dir()');
}
if (isset($wp_upload_dir['basedir'])) {
$wp_settings[] = array('Upload Base Directory', $wp_upload_dir['basedir'], 'wp_upload_dir()');
}
$wp_settings[] = array('Site URL', site_url(), 'site_url()');
$wp_settings[] = array('Home URL', home_url(), 'home_url()');
$wp_settings[] = array('WordPress Root Path', ABSPATH, 'ABSPATH');
// Multisite extras:
$wp_settings_multisite = array();
if (is_multisite()) {
$wp_settings[] = array('Network Site URL', network_site_url(), 'network_site_url()');
$wp_settings[] = array('Network Home URL', network_home_url(), 'network_home_url()');
}
$wp_settings[] = array('BackupBuddy local storage', backupbuddy_core::getBackupDirectory(), 'BackupBuddy Settings');
$wp_settings[] = array('BackupBuddy temporary files', backupbuddy_core::getTempDirectory(), 'ABSPATH + Hardcoded location');
$wp_settings[] = array('BackupBuddy logs', backupbuddy_core::getLogDirectory(), 'Upload Base + BackupBuddy');
// Display WP settings..
pb_backupbuddy::$ui->list_table($wp_settings, array('action' => pb_backupbuddy::page_url(), 'columns' => array(__('URLs & Paths', 'it-l10n-backupbuddy'), __('Value', 'it-l10n-backupbuddy'), __('Obtained via', 'it-l10n-backupbuddy')), 'css' => 'width: 100%;'));
pb_backupbuddy::$ui->end_tab();
// This page can take a bit to run.
// Runs AFTER server information is displayed so we can view the default limits for the server.
pb_backupbuddy::set_greedy_script_limits();
pb_backupbuddy::$ui->start_tab('database');
require_once 'server_info/database.php';
echo '<br><br><a name="database_replace"></a>';
echo '<div class="pb_htitle">' . 'Advanced: ' . __('Database Mass Text Replacement', 'it-l10n-backupbuddy') . '</div><br>';
pb_backupbuddy::load_view('_server_tools-database_replace');
pb_backupbuddy::$ui->end_tab();
pb_backupbuddy::$ui->start_tab('files');
require_once 'server_info/site_size.php';
示例5: die
<?php
if (!is_admin()) {
die('Access Denied.');
}
$settings_form = new pb_backupbuddy_settings('advanced_settings', '', 'tab=1', 320);
$settings_form->add_setting(array('type' => 'title', 'name' => 'title_basic', 'title' => __('Basic Operation', 'it-l10n-backupbuddy')));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'backup_reminders', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Enable backup reminders for edits', 'it-l10n-backupbuddy'), 'tip' => __('[Default: enabled] - When enabled links will be displayed upon post or page edits and during WordPress upgrades to remind and allow rapid backing up after modifications or before upgrading.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'archive_name_format', 'options' => array('unchecked' => 'date', 'checked' => 'datetime'), 'title' => __('Add time in backup file name', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled (date only)] - When enabled your backup filename will display the time the backup was created in addition to the default date. This is useful when making multiple backups in a one day period.', 'it-l10n-backupbuddy'), 'css' => '', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'lock_archives_directory', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Lock archive directory (high security)', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled] - When enabled all downloads of archives via the web will be prevented under all circumstances via .htaccess file. If your server permits it, they will only be unlocked temporarily on click to download. If your server does not support this unlocking then you will have to access the archives via the server (such as by FTP).', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('May prevent downloading backups within WordPress on incompatible servers', 'it-l10n-backupbuddy'), 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'include_importbuddy', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Include ImportBuddy in full backup archive', 'it-l10n-backupbuddy'), 'tip' => __('[Default: enabled] - When enabled, the importbuddy.php (restoration tool) file will be included within the backup archive ZIP file in the location `/' . str_replace(ABSPATH, '', backupbuddy_core::getTempDirectory()) . ' xxxxxxxxxx/ importbuddy.php` where the x\'s match the unique random string in the backup ZIP filename.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => ' <span style="white-space: nowrap;"><span class="description">' . __('Located in backup', 'it-l10n-backupbuddy') . ':</span> <span class="code" style="white-space: normal; background: #EAEAEA;"">/' . str_replace(ABSPATH, '', backupbuddy_core::getTempDirectory()) . 'xxxxxxxxxx/importbuddy.php</span>', 'rules' => 'required'));
$log_file = backupbuddy_core::getLogDirectory() . 'log-' . pb_backupbuddy::$options['log_serial'] . '.txt';
$settings_form->add_setting(array('type' => 'select', 'name' => 'log_level', 'title' => __('Logging Level', 'it-l10n-backupbuddy'), 'options' => array('0' => __('None', 'it-l10n-backupbuddy'), '1' => __('Errors Only', 'it-l10n-backupbuddy'), '2' => __('Errors & Warnings', 'it-l10n-backupbuddy'), '3' => __('Everything (troubleshooting mode)', 'it-l10n-backupbuddy')), 'tip' => sprintf(__('[Default: Errors Only] - This option controls how much activity is logged for records or troubleshooting. Logs may be viewed from the Logs / Other tab on the Settings page. Additionally when in Everything / Troubleshooting mode error emails will contain encrypted troubleshooting data for support. Log file: %s', 'it-l10n-backupbuddy'), $log_file), 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'select', 'name' => 'default_backup_tab', 'title' => __('Default backup tab', 'it-l10n-backupbuddy'), 'options' => array('0' => __('Overview', 'it-l10n-backupbuddy'), '1' => __('Status Log', 'it-l10n-backupbuddy')), 'tip' => sprintf(__('[Default: Overview] - The default tab open during a backup is the overview tab. A more technical view is available in the Status tab.', 'it-l10n-backupbuddy')), 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'text', 'name' => 'max_site_log_size', 'title' => __('Maximum log file size', 'it-l10n-backupbuddy'), 'tip' => __('[Default: 10 MB] - If the log file exceeds this size then it will be cleared to prevent it from using too much space.'), 'rules' => 'required|int', 'css' => 'width: 50px;', 'after' => ' MB'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'disable_localization', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Disable language localization', 'it-l10n-backupbuddy'), 'tip' => __('[Default: Unchecked] When checked language localization support will be disabled. BackupBuddy will revert to full English language mode. Use this to display logs in English for support.', 'it-l10n-backupbuddy') . '</span>', 'css' => '', 'after' => '<span class="description"> ' . __('Check to run BackupBuddy in English. This is useful for support.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'title', 'name' => 'title_advanced', 'title' => __('Technical & Server Compatibility', 'it-l10n-backupbuddy')));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'delete_archives_pre_backup', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Delete all backup archives prior to backups', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled] - When enabled all local backup archives will be deleted prior to each backup. This is useful if in compatibilty mode to prevent backing up existing files.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Use is exclusions are malfunctioning or for special purposes.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'disable_https_local_ssl_verify', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Disable local SSL certificate verification', 'it-l10n-backupbuddy'), 'tip' => __('[Default: Disabled] When checked, WordPress will skip local https SSL verification.', 'it-l10n-backupbuddy') . '</span>', 'css' => '', 'after' => '<span class="description"> ' . __('Workaround if local SSL verification fails (ie. for loopback & local CA cert issues).', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'prevent_flush', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Prevent Flushing', 'it-l10n-backupbuddy'), 'tip' => __('[Default: not prevented (unchecked)] - Rarely some servers die unexpectedly when flush() or ob_flush() are called multiple times during the same PHP process. Checking this prevents these from ever being called during backups.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Check if directed by support.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'save_comment_meta', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Save meta data in comment', 'it-l10n-backupbuddy'), 'tip' => __('[Default: Enabled] When enabled, BackupBuddy will store general backup information in the ZIP comment header such as Site URL, backup type & time, serial, etc. during backup creation.', 'it-l10n-backupbuddy') . '</span>', 'css' => '', 'after' => '<span class="description"> ' . __('If backups hang when saving meta data disabling skips this process.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'profiles#0#integrity_check', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Perform integrity check on backup files', 'it-l10n-backupbuddy'), 'tip' => __('[Default: enabled] - By default each backup file is checked for integrity and completion the first time it is viewed on the Backup page. On some server configurations this may cause memory problems as the integrity checking process is intensive. If you are experiencing out of memory errors on the Backup file listing, you can uncheck this to disable this feature.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Disable if the backup page will not load or backups hang on integrity check.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'backup_cron_rescheduling', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Reschedule missing crons in manual backups', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled] - To proceed to subsequent steps during backups BackupBuddy schedules the next step with the WordPress cron system. If this cron goes missing the backup cannot proceed. This feature instructs BackupBuddy to attempt to re-schedule this cron as it occurs.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Check if directed by support.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'select', 'name' => 'backup_mode', 'title' => __('Default global backup mode', 'it-l10n-backupbuddy'), 'options' => array('1' => __('Classic (v1.x) - Entire backup in single PHP page load', 'it-l10n-backupbuddy'), '2' => __('Modern (v2.x+) - Split across page loads via WP cron', 'it-l10n-backupbuddy')), 'tip' => __('[Default: Modern] - If you are encountering difficulty backing up due to WordPress cron, HTTP Loopbacks, or other features specific to version 2.x you can try classic mode which runs like BackupBuddy v1.x did.', 'it-l10n-backupbuddy'), 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'title', 'name' => 'title_database', 'title' => __('Database', 'it-l10n-backupbuddy')));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'profiles#0#skip_database_dump', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Skip database dump on backup', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled] - (WARNING: This prevents BackupBuddy from backing up the database during any kind of backup. This is for troubleshooting / advanced usage only to work around being unable to backup the database.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Completely bypass backing up database for all database types. Use caution.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required', 'orientation' => 'vertical'));
$settings_form->add_setting(array('type' => 'select', 'name' => 'database_method_strategy', 'title' => __('Database method strategy', 'it-l10n-backupbuddy'), 'options' => array('php' => __('PHP-based: Supports automated chunked resuming - default', 'it-l10n-backupbuddy'), 'commandline' => __('Commandline: Fast but does not support resuming', 'it-l10n-backupbuddy'), 'all' => __('All Available: ( PHP [chunking] > Commandline via exec() )', 'it-l10n-backupbuddy')), 'tip' => __('[Default: PHP-based] - Normally use PHP-based which supports chunking (as of BackupBuddy v5) to support larger databases. Commandline-based database dumps use mysqldump which is very fast and efficient but cannot be broken up into smaller steps if it is too large which could result in timeouts on larger servers.', 'it-l10n-backupbuddy'), 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'breakout_tables', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Break out big table dumps into steps', 'it-l10n-backupbuddy'), 'tip' => __('[Default: enabled] When enabled, BackupBuddy will dump some of the commonly larger tables in separate steps. Note this only applies to command-line based dumps as PHP-based dumps automatically support chunking with resume on table and/or row as needed.', 'it-l10n-backupbuddy') . '</span>', 'css' => '', 'after' => '<span class="description"> ' . __('Commandline method: Break up dumping of big tables (chunking)', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
$settings_form->add_setting(array('type' => 'text', 'name' => 'phpmysqldump_maxrows', 'title' => __('Compatibility mode max rows per select', 'it-l10n-backupbuddy'), 'tip' => __('[Default: *blank*] - When BackupBuddy is using compatibility mdoe mysql dumping (via PHP), BackupBuddy selects data from the database. Reducing this number has BackupBuddy grab smaller portions from the database at a time. Leave blank to use built in default (around 2000 rows per select).', 'it-l10n-backupbuddy'), 'css' => 'width: 50px;', 'after' => ' rows. <span class="description"> ' . __('Blank for default.', 'it-l10n-backupbuddy') . ' (~1000 rows/select)</span>', 'rules' => 'int'));
$settings_form->add_setting(array('type' => 'text', 'name' => 'max_execution_time', 'title' => __('Maximum time per chunk', 'it-l10n-backupbuddy'), 'tip' => __('[Default: *blank*] - The maximum amount of time BackupBuddy should allow a database import chunk to run. BackupBuddy by default limits each chunk to your Maximum PHP runtime when using the default PHP-based method. If your database dump step is timing out then lowering this value will instruct the script to limit each `chunk` to allow it to finish within this time period. Raising this value above your servers limits will not increase or override server settings.', 'it-l10n-backupbuddy'), 'css' => 'width: 50px;', 'after' => ' sec. <span class="description"> ' . __('Blank for detected default.', 'it-l10n-backupbuddy') . ' (' . backupbuddy_core::detectMaxExecutionTime() . ' sec)</span>', 'rules' => 'int'));
$settings_form->add_setting(array('type' => 'checkbox', 'name' => 'ignore_command_length_check', 'options' => array('unchecked' => '0', 'checked' => '1'), 'title' => __('Ignore command line length check results', 'it-l10n-backupbuddy'), 'tip' => __('[Default: disabled] - WARNING: BackupBuddy attempts to determine your system\'s maximum command line length to insure that database operation commands do not get inadvertantly cut off. On some systems it is not possible to reliably detect this information which could result infalling back into compatibility mode even though the system is capable of running in normal operational modes. This option instructs BackupBuddy to ignore the results of the command line length check.', 'it-l10n-backupbuddy'), 'css' => '', 'after' => '<span class="description"> ' . __('Check if directed by support.', 'it-l10n-backupbuddy') . '</span>', 'rules' => 'required'));
示例6: array
<br><?php
$tests = array();
$uploads_dirs = wp_upload_dir();
$directories = array(ABSPATH . '', ABSPATH . 'wp-includes/', ABSPATH . 'wp-admin/', WP_CONTENT_DIR . '/themes/', WP_CONTENT_DIR . '/plugins/', WP_CONTENT_DIR . '/', rtrim($uploads_dirs['basedir'], '\\/') . '/', ABSPATH . 'wp-includes/', backupbuddy_core::getBackupDirectory(), backupbuddy_core::getLogDirectory());
if (@file_exists(backupbuddy_core::getTempDirectory())) {
// This dir is usually transient so may not exist.
$directories[] = backupbuddy_core::getTempDirectory();
}
foreach ($directories as $directory) {
$mode_octal_four = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
$owner = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
if (!file_exists($directory)) {
$mode_octal_four = 'Directory does\'t exist';
$owner = 'n/a';
}
$stats = pluginbuddy_stat::stat($directory);
if (false !== $stats) {
$mode_octal_four = $stats['mode_octal_four'];
$owner = $stats['uid'] . ':' . $stats['gid'];
}
$this_test = array('title' => '/' . str_replace(ABSPATH, '', $directory), 'suggestion' => '<= 755', 'value' => $mode_octal_four, 'owner' => $owner);
if (false === $stats || $mode_octal_four > 755) {
$this_test['status'] = __('WARNING', 'it-l10n-backupbuddy');
} else {
$this_test['status'] = __('OK', 'it-l10n-backupbuddy');
}
array_push($tests, $this_test);
}
// end foreach.
?>
示例7: 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;
}
}
示例8: pre_backup
//.........这里部分代码省略.........
/*
if ( $profile['compression'] == '1' ) {
$profile['compression'] = true;
} else {
$profile['compression'] = false;
}
*/
if (pb_backupbuddy::$options['compression'] == '1') {
$compression = true;
} else {
$compression = false;
}
$archiveURL = '';
$abspath = str_replace('\\', '/', ABSPATH);
// Change slashes to handle Windows as we store backup_directory with Linux-style slashes even on Windows.
$backup_dir = str_replace('\\', '/', backupbuddy_core::getBackupDirectory());
if (FALSE !== stristr($backup_dir, $abspath)) {
// Make sure file to download is in a publicly accessible location (beneath WP web root technically).
$sitepath = str_replace($abspath, '', $backup_dir);
$archiveURL = rtrim(site_url(), '/\\') . '/' . trim($sitepath, '/\\') . '/' . basename($archiveFile);
}
$forceSingleDatabaseFile = false;
if ('1' == pb_backupbuddy::$options['force_single_db_file']) {
$forceSingleDatabaseFile = true;
}
// Set up the backup data.
$this->_backup = array('data_version' => 1, 'backupbuddy_version' => pb_backupbuddy::settings('version'), 'serial' => $serial, 'init_complete' => false, 'backup_mode' => $profile['backup_mode'], 'type' => $type, 'profile' => $profile, 'default_profile' => pb_backupbuddy::$options['profiles'][0], 'start_time' => time(), 'finish_time' => 0, 'updated_time' => time(), 'status' => array(), 'max_execution_time' => backupbuddy_core::adjustedMaxExecutionTime(), 'archive_size' => 0, 'schedule_title' => $schedule_title, 'backup_directory' => backupbuddy_core::getBackupDirectory(), 'archive_file' => $archiveFile, 'archive_url' => $archiveURL, 'trigger' => $trigger, 'zip_method_strategy' => pb_backupbuddy::$options['zip_method_strategy'], 'compression' => $compression, 'ignore_zip_warnings' => pb_backupbuddy::$options['ignore_zip_warnings'], 'ignore_zip_symlinks' => pb_backupbuddy::$options['ignore_zip_symlinks'], 'steps' => array(), 'integrity' => array(), 'temp_directory' => '', 'backup_root' => '', 'export_plugins' => array(), 'additional_table_includes' => array(), 'additional_table_excludes' => array(), 'directory_exclusions' => backupbuddy_core::get_directory_exclusions($profile, false, $serial), 'table_sizes' => array(), 'breakout_tables' => array(), 'force_single_db_file' => $forceSingleDatabaseFile, 'deployment_log' => '', 'deployment_direction' => $deployDirection, 'deployment_destination' => $deployDestinationSettings, 'runnerUID' => get_current_user_id());
pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'file_excludes', 'title' => 'Found ' . count($this->_backup['directory_exclusions']) . ' file or directory exclusions.')));
// Warn if excluding key paths.
$alertFileExcludes = backupbuddy_core::alert_core_file_excludes($this->_backup['directory_exclusions']);
foreach ($alertFileExcludes as $alertFileExcludeId => $alertFileExclude) {
pb_backupbuddy::status('warning', $alertFileExclude);
}
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
// Figure out paths.
if ($this->_backup['type'] == 'full' || $this->_backup['type'] == 'files') {
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/';
$this->_backup['backup_root'] = ABSPATH;
// ABSPATH contains trailing slash.
} elseif ($this->_backup['type'] == 'db') {
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/';
$this->_backup['backup_root'] = $this->_backup['temp_directory'];
} elseif ($this->_backup['type'] == 'export') {
// WordPress unzips into wordpress subdirectory by default so must include that in path.
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/wordpress/wp-content/uploads/backupbuddy_temp/' . $serial . '/';
// We store temp data for export within the temporary WordPress installation within the temp directory. A bit confusing; sorry about that.
$this->_backup['backup_root'] = backupbuddy_core::getTempDirectory() . $serial . '/wordpress/';
} else {
pb_backupbuddy::status('error', __('Backup FAILED. Unknown backup type.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
}
pb_backupbuddy::status('details', 'Temp directory: `' . $this->_backup['temp_directory'] . '`.');
pb_backupbuddy::status('details', 'Backup root: `' . $this->_backup['backup_root'] . '`.');
// Plugins to export (only for MS exports).
if (count($export_plugins) > 0) {
$this->_backup['export_plugins'] = $export_plugins;
}
// Calculate additional database table inclusion/exclusion.
$additional_includes = explode("\n", $profile['mysqldump_additional_includes']);
array_walk($additional_includes, create_function('&$val', '$val = trim($val);'));
$this->_backup['additional_table_includes'] = array_unique($additional_includes);
// removes duplicates.
$additional_excludes = explode("\n", $profile['mysqldump_additional_excludes']);
array_walk($additional_excludes, create_function('&$val', '$val = trim($val);'));
$this->_backup['additional_table_excludes'] = array_unique($additional_excludes);
示例9: load_backup_dat
function load_backup_dat()
{
$dat_file = $this->import_options['extract_to'] . '/' . str_replace(ABSPATH, '', backupbuddy_core::getTempDirectory()) . $this->import_options['zip_id'] . '/backupbuddy_dat.php';
$this->_backupdata = $this->get_backup_dat($dat_file);
}
示例10: cleanTempDir
public static function cleanTempDir($backup_age_limit = 172800)
{
// Remove any old temporary directories in wp-content/uploads/backupbuddy_temp/. Logs any directories it cannot delete.
pb_backupbuddy::status('details', 'Cleaning up any old temporary zip directories in: wp-content/uploads/backupbuddy_temp/. If no recent backups then the temp directory will also be purged.');
$recentBackupFound = false;
$temp_directory = backupbuddy_core::getTempDirectory();
$files = glob($temp_directory . '*');
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.
foreach ($files as $file) {
if (strpos($file, 'index.') !== false || strpos($file, '.htaccess') !== false) {
// Index file or htaccess dont get deleted so go to next file.
continue;
}
$file_stats = stat($file);
if (0 == $backup_age_limit || time() - $file_stats['mtime'] > $backup_age_limit) {
// If older than 12 hours, delete the log.
if (@pb_backupbuddy::$filesystem->unlink_recursive($file) === false) {
pb_backupbuddy::status('error', 'Unable to clean up (delete) temporary directory/file: `' . $file . '`. You should manually delete it or check permissions.');
}
} else {
// Not very old.
$recentBackupFound = true;
}
}
if (false === $recentBackupFound) {
pb_backupbuddy::$filesystem->unlink_recursive($temp_directory);
// Delete temp directory (as of BB v5.0). This is not critical but nice. The backup cleanup step should purge these so if all is going well this probably will not find anything.
}
}
unset($recentBackupFound);
}
示例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: _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)));
}
示例13: 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);
$files = array(dirname(dirname(__FILE__)) . '/remote-send-test.php');
$results = self::send($settings, $files, '', $delete_local = false, $delete_remote_after = true);
@unlink($importbuddy_temp);
if (true === $results) {
echo 'Success sending test file to Google Drive. ';
return true;
} else {
echo 'Failure sending test file to Google Drive.';
// Detailed errors are send via remote_test.php response.
return false;
}
}
示例14:
});
});
</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) {
示例15: verify_directories
public static function verify_directories()
{
$success = true;
// Update backup directory if unable to write to the defined one.
if (!@is_writable(backupbuddy_core::getBackupDirectory())) {
pb_backupbuddy::status('details', 'Backup directory invalid. Updating from `' . backupbuddy_core::getBackupDirectory() . '` to default.');
pb_backupbuddy::$options['backup_directory'] = '';
// Reset to default (blank).
pb_backupbuddy::save();
}
$response = pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory(), $die = false);
if (false === $response) {
$success = false;
}
// Update log directory if unable to write to the defined one.
if (!@is_writable(backupbuddy_core::getLogDirectory())) {
pb_backupbuddy::status('details', 'Log directory invalid. Updating from `' . backupbuddy_core::getLogDirectory() . '` to default.');
pb_backupbuddy::$options['log_directory'] = '';
// Reset to default (blank).
pb_backupbuddy::save();
}
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getLogDirectory(), $die = false);
if (false === $response) {
$success = false;
}
// Update temp directory if unable to write to the defined one.
if (!@is_writable(backupbuddy_core::getTempDirectory())) {
pb_backupbuddy::status('details', 'Temporary directory invalid. Updating from `' . backupbuddy_core::getTempDirectory() . '` to default.');
pb_backupbuddy::$options['temp_directory'] = '';
pb_backupbuddy::save();
}
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
if (false === $response) {
$success = false;
}
global $pb_backupbuddy_directory_verification;
$pb_backupbuddy_directory_verification = $success;
return $success;
}