Пример #1
1
 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
0
 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
0
 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
0
     $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
0
<?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>&nbsp; <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
0
     $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(), 'Upload Base + BackupBuddy');
 $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';
Пример #7
0
<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.
?>
Пример #8
0
 public static function test($settings)
 {
     $settings = self::_normalizeSettings($settings);
     if (false === ($settings = self::_connect($settings))) {
         $error = 'Unable to connect with Google Drive. See log for details.';
         echo $error;
         pb_backupbuddy::status('error', $error);
         return false;
     }
     pb_backupbuddy::status('details', 'Testing Google Drive destination. Sending ImportBuddy.php.');
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     $importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
     // Full path & filename to temporary importbuddy
     backupbuddy_core::importbuddy($importbuddy_temp);
     // Create temporary importbuddy.
     $files = array($importbuddy_temp);
     $results = self::send($settings, $files, '', $delete_remote_after = true);
     @unlink($importbuddy_temp);
     if (true === $results) {
         echo 'Success sending test file to Google Drive. ';
         return true;
     } else {
         global $pb_backupbuddy_destination_errors;
         echo 'Failure sending test file to Google Drive. Details: `' . implode(', ', $pb_backupbuddy_destination_errors) . '`.';
         return false;
     }
 }
Пример #9
0
 function pre_backup($serial, $archiveFile, $profile, $trigger, $pre_backup = array(), $post_backup = array(), $schedule_title = '', $export_plugins = array(), $deployDirection, $deployDestinationSettings)
 {
     pb_backupbuddy::status('startFunction', json_encode(array('function' => 'pre_backup', 'title' => 'Getting ready to backup')));
     $type = $profile['type'];
     // Log some status information.
     pb_backupbuddy::status('details', __('Performing pre-backup procedures.', 'it-l10n-backupbuddy'));
     if ($type == 'full') {
         pb_backupbuddy::status('message', __('Full backup mode.', 'it-l10n-backupbuddy'));
     } elseif ($type == 'db') {
         pb_backupbuddy::status('message', __('Database only backup mode.', 'it-l10n-backupbuddy'));
     } elseif ($type == 'files') {
         pb_backupbuddy::status('message', __('Files only backup mode.', 'it-l10n-backupbuddy'));
         //$profile['skip_database_dump'] = '1';
     } elseif ($type == 'export') {
         pb_backupbuddy::status('message', __('Multisite subsite export mode.', 'it-l10n-backupbuddy'));
     } else {
         pb_backupbuddy::status('error', 'Error #8587383: Unknown backup mode `' . htmlentities($type) . '`.');
     }
     if ('' != $deployDirection) {
         pb_backupbuddy::status('details', 'Deployment direction: `' . $deployDirection . '`.');
     }
     if ('1' == pb_backupbuddy::$options['prevent_flush']) {
         pb_backupbuddy::status('details', 'Flushing will be skipped based on advanced settings.');
     } else {
         pb_backupbuddy::status('details', 'Flushing will not be skipped (default).');
     }
     // Schedule daily housekeeping.
     if (false === wp_next_scheduled(pb_backupbuddy::cron_tag('housekeeping'))) {
         // if schedule does not exist...
         backupbuddy_core::schedule_event(time() + 60 * 60 * 2, 'daily', pb_backupbuddy::cron_tag('housekeeping'), array());
         // Add schedule.
     }
     // Verify directories.
     pb_backupbuddy::status('details', 'Verifying directories ...');
     if (false === backupbuddy_core::verify_directories()) {
         pb_backupbuddy::status('error', 'Error #18573. Error verifying directories. See details above. Backup halted.');
         pb_backupbuddy::status('haltScript', '');
         // Halt JS on page.
         die;
     } else {
         pb_backupbuddy::status('details', 'Directories verified.');
     }
     // Delete all backup archives if this troubleshooting option is enabled.
     if (pb_backupbuddy::$options['delete_archives_pre_backup'] == '1') {
         pb_backupbuddy::status('message', 'Deleting all existing backups prior to backup as configured on the settings page.');
         $file_list = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
         if (is_array($file_list) && !empty($file_list)) {
             foreach ($file_list as $file) {
                 if (@unlink($file) === true) {
                     pb_backupbuddy::status('details', 'Deleted backup archive `' . basename($file) . '` based on settings to delete all backups.');
                 } else {
                     pb_backupbuddy::status('details', 'Unable to delete backup archive `' . basename($file) . '` based on settings to delete all backups. Verify permissions.');
                 }
             }
         }
     }
     // Generate unique serial ID.
     pb_backupbuddy::status('details', 'Backup serial generated: `' . $serial . '`.');
     pb_backupbuddy::status('details', 'About to load fileoptions data in create mode.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #40.');
     $this->_backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
     if (true !== ($result = $this->_backup_options->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034 A. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         pb_backupbuddy::status('haltScript', '');
         // Halt JS on page.
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $this->_backup =& $this->_backup_options->options;
     // Set reference.
     // Cleanup internal stats. Deployments should not impact stats.
     if ('' == $deployDirection) {
         pb_backupbuddy::status('details', 'Updating statistics for last backup start.');
         pb_backupbuddy::$options['last_backup_start'] = time();
         // Reset time since last backup.
         pb_backupbuddy::$options['last_backup_serial'] = $serial;
         pb_backupbuddy::save();
     }
     // Output active plugins list for debugging...
     $activePlugins = get_option('active_plugins');
     pb_backupbuddy::status('details', 'Active WordPress plugins: `' . implode('; ', $activePlugins) . '`.');
     pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'wp_plugins_found', 'title' => 'Found ' . count($activePlugins) . ' active WordPress plugins.')));
     unset($activePlugins);
     // Compression to bool.
     /*
     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);
     // removes duplicates.
     unset($additional_includes);
     unset($additional_excludes);
     /********* Begin setting up steps array. *********/
     if ($type == 'export') {
         pb_backupbuddy::status('details', 'Setting up export-specific steps.');
         $this->_backup['steps'][] = array('function' => 'ms_download_extract_wordpress', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_create_wp_config', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_copy_plugins', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_copy_themes', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_copy_media', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         $this->_backup['steps'][] = array('function' => 'ms_copy_users_table', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     }
     if ('pull' != $deployDirection && '1' != $profile['skip_database_dump'] && $profile['type'] != 'files') {
         // Backup database if not skipping AND not a files only backup.
         global $wpdb;
         // Default tables to backup.
         if ($type == 'export') {
             // Multisite Subsite export only dumps tables specific to this subsite prefix.
             $base_dump_mode = 'prefix';
         } else {
             // Non-multisite export so use profile to determine tables to backup.
             if ($profile['backup_nonwp_tables'] == '1') {
                 // Backup all tables.
                 $base_dump_mode = 'all';
             } elseif ($profile['backup_nonwp_tables'] == '2') {
                 // Backup no tables by default. Relies on listed additional tables.
                 $base_dump_mode = 'none';
             } else {
                 // Only backup matching prefix.
                 $base_dump_mode = 'prefix';
             }
         }
         $additional_tables = $this->_backup['additional_table_includes'];
         if ($type == 'export') {
             global $wpdb;
             array_push($additional_tables, $wpdb->prefix . "users");
             array_push($additional_tables, $wpdb->prefix . "usermeta");
         }
         // Warn if excluding key WP tables.
         $tableExcludes = backupbuddy_core::alert_core_table_excludes($this->_backup['additional_table_excludes']);
         foreach ($tableExcludes as $tableExcludeId => $tableExclude) {
             pb_backupbuddy::status('warning', $tableExclude);
         }
         // Calculate tables to dump based on the provided information. $tables will be an array of tables.
         $tables = $this->_calculate_tables($base_dump_mode, $additional_tables, $this->_backup['additional_table_excludes']);
         pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'calculate_tables', 'title' => 'Found ' . count($tables) . ' tables to backup based on settings.', 'more' => 'Tables: ' . implode(', ', $tables))));
         // If calculations show NO database tables should be backed up then change mode to skip database dump.
         if (0 == count($tables)) {
             pb_backupbuddy::status('warning', 'WARNING #857272: No database tables will be backed up based on current settings. This will not be a complete backup. Adjust settings if this is not intended and use with caution. Skipping database dump step.');
             $profile['skip_database_dump'] = '1';
             $this->_backup['profile']['skip_database_dump'] = '1';
         } else {
             // One or more tables set to backup.
             // Obtain tables sizes. Surround each table name by a single quote and implode with commas for SQL query to get sizes.
             $tables_formatted = $tables;
             foreach ($tables_formatted as &$table_formatted) {
                 $table_formatted = "'{$table_formatted}'";
             }
             $tables_formatted = implode(',', $tables_formatted);
             $sql = "SHOW TABLE STATUS WHERE Name IN({$tables_formatted});";
             $rows = $wpdb->get_results($sql, ARRAY_A);
             if (false === $rows) {
                 pb_backupbuddy::alert('Error #85473474: Unable to retrieve table status. Query: `' . $sql . '`.', true);
                 return false;
             }
             $totalDatabaseSize = 0;
             foreach ($rows as $row) {
                 $this->_backup['table_sizes'][$row['Name']] = $row['Data_length'] + $row['Index_length'];
                 $totalDatabaseSize += $this->_backup['table_sizes'][$row['Name']];
             }
             unset($rows);
             unset($tables_formatted);
             $databaseSize = pb_backupbuddy::$format->file_size($totalDatabaseSize);
             pb_backupbuddy::status('details', 'Total calculated database size: `' . $databaseSize . '`.');
             // Step through tables we want to break out and figure out which ones were indeed set to be backed up and break them out.
             if (pb_backupbuddy::$options['breakout_tables'] == '0') {
                 // Breaking out DISABLED.
                 pb_backupbuddy::status('details', 'Breaking out tables DISABLED based on settings.');
             } else {
                 // Breaking out ENABLED.
                 // Tables we will try to break out into standalone steps if possible.
                 $breakout_tables_defaults = array($wpdb->prefix . 'posts', $wpdb->prefix . 'postmeta');
                 pb_backupbuddy::status('details', 'Breaking out tables ENABLED based on settings. Tables to be broken out into individual steps: `' . implode(', ', $breakout_tables_defaults) . '`.');
                 foreach ((array) $breakout_tables_defaults as $breakout_tables_default) {
                     if (in_array($breakout_tables_default, $tables)) {
                         $this->_backup['breakout_tables'][] = $breakout_tables_default;
                         $tables = array_diff($tables, array($breakout_tables_default));
                         // Remove from main table backup list.
                     }
                 }
                 unset($breakout_tables_defaults);
                 // No longer needed.
             }
             $this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array($tables), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
             // Set up backup steps for additional broken out tables.
             foreach ((array) $this->_backup['breakout_tables'] as $breakout_table) {
                 $this->_backup['steps'][] = array('function' => 'backup_create_database_dump', 'args' => array(array($breakout_table)), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
             }
         }
         // end there being tables to backup.
     } else {
         pb_backupbuddy::status('message', __('Skipping database dump based on settings / profile type.', 'it-l10n-backupbuddy') . ' Backup type: `' . $type . '`.');
     }
     if ('pull' != $deployDirection) {
         $this->_backup['steps'][] = array('function' => 'backup_zip_files', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         if ($type == 'export') {
             $this->_backup['steps'][] = array('function' => 'ms_cleanup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         }
         if ($profile['integrity_check'] == '1') {
             pb_backupbuddy::status('details', __('Integrity check will be performed based on settings for this profile.', 'it-l10n-backupbuddy'));
             $this->_backup['steps'][] = array('function' => 'integrity_check', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
         } else {
             pb_backupbuddy::status('details', __('Skipping integrity check step based on settings for this profile.', 'it-l10n-backupbuddy'));
         }
     }
     $this->_backup['steps'][] = array('function' => 'post_backup', 'args' => array(), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0);
     // Prepend and append pre backup and post backup steps.
     $this->_backup['steps'] = array_merge($pre_backup, $this->_backup['steps'], $post_backup);
     /********* End setting up steps array. *********/
     // Save what we have so far so that any errors below will end up displayed to user.
     $this->_backup_options->save();
     /********* Begin directory creation and security. *********/
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory());
     // Prepare temporary directory for holding SQL and data file.
     if (backupbuddy_core::getTempDirectory() == '') {
         pb_backupbuddy::status('error', 'Error #54534344. Temp directory blank. Please deactivate then reactivate plugin to reset.');
         return false;
     }
     if (!file_exists($this->_backup['temp_directory'])) {
         if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temp_directory']) === false) {
             pb_backupbuddy::status('error', 'Error #9002b. Unable to create temporary storage directory (' . $this->_backup['temp_directory'] . ')');
             return false;
         }
     }
     if (!is_writable($this->_backup['temp_directory'])) {
         pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temp_directory'] . ')');
         return false;
     }
     pb_backupbuddy::anti_directory_browsing(ABSPATH . 'wp-content/uploads/backupbuddy_temp/');
     // Prepare temporary directory for holding ZIP file while it is being generated.
     $this->_backup['temporary_zip_directory'] = backupbuddy_core::getBackupDirectory() . 'temp_zip_' . $this->_backup['serial'] . '/';
     if (!file_exists($this->_backup['temporary_zip_directory'])) {
         if (pb_backupbuddy::$filesystem->mkdir($this->_backup['temporary_zip_directory']) === false) {
             pb_backupbuddy::status('details', 'Error #9002c. Unable to create temporary ZIP storage directory (' . $this->_backup['temporary_zip_directory'] . ')');
             return false;
         }
     }
     if (!is_writable($this->_backup['temporary_zip_directory'])) {
         pb_backupbuddy::status('error', 'Error #9015. Temp data directory is not writable. Check your permissions. (' . $this->_backup['temporary_zip_directory'] . ')');
         return false;
     }
     /********* End directory creation and security *********/
     // Generate backup DAT (data) file containing details about the backup.
     if ($this->backup_create_dat_file($trigger) !== true) {
         pb_backupbuddy::status('details', __('Problem creating DAT file.', 'it-l10n-backupbuddy'));
         return false;
     }
     // Generating ImportBuddy file to include in the backup for FULL BACKUPS ONLY currently. Cannot put in DB because it would be in root and be excluded or conflict on extraction.
     if ($type == 'full') {
         if (pb_backupbuddy::$options['include_importbuddy'] == '1') {
             pb_backupbuddy::status('details', 'Generating ImportBuddy tool to include in backup archive: `' . $this->_backup['temp_directory'] . 'importbuddy.php`.');
             pb_backupbuddy::status('startAction', 'importbuddyCreation');
             backupbuddy_core::importbuddy($this->_backup['temp_directory'] . 'importbuddy.php');
             pb_backupbuddy::status('finishAction', 'importbuddyCreation');
             pb_backupbuddy::status('details', 'ImportBuddy generation complete.');
         } else {
             // dont include importbuddy.
             pb_backupbuddy::status('details', 'ImportBuddy tool inclusion in ZIP backup archive skipped based on settings or backup type.');
         }
     }
     // Save all of this.
     $this->_backup['init_complete'] = true;
     // pre_backup() completed.
     $this->_backup_options->save();
     pb_backupbuddy::status('details', __('Finished pre-backup procedures.', 'it-l10n-backupbuddy'));
     pb_backupbuddy::status('milestone', 'finish_settings');
     pb_backupbuddy::status('finishFunction', json_encode(array('function' => 'pre_backup')));
     return true;
 }
Пример #10
0
 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);
 }
Пример #11
0
 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);
 }
Пример #12
0
 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;
 }
Пример #13
0
 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)));
 }
Пример #14
0
 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;
     }
 }
Пример #15
0
	});
});
</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) {
Пример #16
0
 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;
 }
Пример #17
0
				} else {
					jQuery( '#pb_backupbuddy_profiles__<?php 
echo $profile_id;
?>
__excludes' ).val( file + "\n" + jQuery( '#pb_backupbuddy_profiles__<?php 
echo $profile_id;
?>
__excludes' ).val() );
				}
			},
			function(directory) {
				if ( ( directory == '/wp-content/' ) || ( directory == '/wp-content/uploads/' ) || ( directory == '<?php 
echo '/' . str_replace(ABSPATH, '', backupbuddy_core::getBackupDirectory());
?>
' ) || ( directory == '<?php 
echo '/' . str_replace(ABSPATH, '', backupbuddy_core::getTempDirectory());
?>
' ) ) {
					alert( "<?php 
_e('You cannot exclude /wp-content/, /wp-content/uploads/, or BackupBuddy directories.  However, you may exclude subdirectories within these. BackupBuddy directories such as backupbuddy_backups are automatically excluded and cannot be added to exclusion list.', 'it-l10n-backupbuddy');
?>
" );
				} else {
					jQuery( '#pb_backupbuddy_profiles__<?php 
echo $profile_id;
?>
__excludes' ).val( directory + "\n" + jQuery( '#pb_backupbuddy_profiles__<?php 
echo $profile_id;
?>
__excludes' ).val() );
				}
Пример #18
0
if (!isset(pb_backupbuddy::$options)) {
    pb_backupbuddy::load();
}
// Validate that all internal schedules are properly registered in the WordPress cron
backupbuddy_core::validateSchedules();
// Clean up any old rollback undo files hanging around.
$files = (array) glob(ABSPATH . 'backupbuddy_rollback*');
foreach ($files as $file) {
    $file_stats = stat($file);
    if (time() - $file_stats['mtime'] > backupbuddy_constants::CLEANUP_MAX_STATUS_LOG_AGE) {
        @unlink($file);
    }
}
// If temp directory exists (should only be transient but just in case it is hanging around) make sure it's secured. BB will try to delete this directory but if it can't it will at least be checked to be secure.
if (file_exists(backupbuddy_core::getTempDirectory())) {
    pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
}
// Clean up any old cron file transfer locks.
$files = (array) glob(backupbuddy_core::getLogDirectory() . 'cronSend-*');
foreach ($files as $file) {
    $file_stats = stat($file);
    if (time() - $file_stats['mtime'] > backupbuddy_constants::CLEANUP_MAX_STATUS_LOG_AGE) {
        @unlink($file);
    }
}
// Alert user if no new backups FINISHED within X number of days if enabled. Max 1 email notification per 24 hours period.
if (pb_backupbuddy::$options['no_new_backups_error_days'] > 0) {
    if (pb_backupbuddy::$options['last_backup_finish'] > 0) {
        $time_since_last = time() - pb_backupbuddy::$options['last_backup_finish'];
        $days_since_last = $time_since_last / 60 / 60 / 24;
        if ($days_since_last > pb_backupbuddy::$options['no_new_backups_error_days']) {
 private static function _getFilePathByType($type)
 {
     if ('backup' == $type) {
         $rootDir = backupbuddy_core::getBackupDirectory();
         // Include trailing slash.
         pb_backupbuddy::anti_directory_browsing($rootDir, $die = false);
     } elseif ('media' == $type) {
         $wp_upload_dir = wp_upload_dir();
         $rootDir = $wp_upload_dir['basedir'] . '/';
         unset($wp_upload_dir);
     } elseif ('plugin' == $type) {
         $rootDir = wp_normalize_path(WP_PLUGIN_DIR) . '/';
     } elseif ('theme' == $type) {
         $rootDir = get_template_directory() . '/';
     } elseif ('childTheme' == $type) {
         $rootDir = get_stylesheet_directory() . '/';
     } elseif ('test' == $type) {
         $rootDir = backupbuddy_core::getTempDirectory();
     } else {
         $error = 'Error #84934984. You must specify a sendfile type: Unknown file type `' . htmlentities($type) . '`.';
         pb_backupbuddy::status('error', $error);
         error_log('BackupBuddy API error: ' . $error);
         die(json_encode(array('success' => false, 'error' => $message)));
     }
     return $rootDir;
 }
 function load_backup_dat()
 {
     pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     $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);
 }
Пример #21
0
_debugtoggle_div").slideToggle();
			});
		});
	</script>
	<?php 
}
// end plugin_information().
// User forced cleanup.
if ('' != pb_backupbuddy::_GET('cleanup_now')) {
    pb_backupbuddy::alert('Performing cleanup procedures now trimming old files and data.');
    backupbuddy_core::periodic_cleanup(0);
    // clean up everything.
}
// Delete temporary files directory.
if ('' != pb_backupbuddy::_GET('delete_tempfiles_now')) {
    $tempDir = backupbuddy_core::getTempDirectory();
    $logDir = backupbuddy_core::getLogDirectory();
    pb_backupbuddy::alert('Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.');
    pb_backupbuddy::$filesystem->unlink_recursive($tempDir);
    pb_backupbuddy::$filesystem->unlink_recursive($logDir);
    pb_backupbuddy::anti_directory_browsing($logDir, $die = false);
    // Put log dir back in place.
}
// Reset log.
if (pb_backupbuddy::_GET('reset_log') != '') {
    if (file_exists($log_file)) {
        @unlink($log_file);
    }
    if (file_exists($log_file)) {
        // Didnt unlink.
        pb_backupbuddy::alert('Unable to clear log file. Please verify permissions on file `' . $log_file . '`.');
Пример #22
0
<br><?php 
$tests = array();
$uploads_dirs = wp_upload_dir();
$directories = array(ABSPATH . '', ABSPATH . 'wp-includes/', ABSPATH . 'wp-admin/', ABSPATH . 'wp-content/themes/', ABSPATH . 'wp-content/plugins/', ABSPATH . 'wp-content/', rtrim($uploads_dirs['basedir'], '\\/') . '/', ABSPATH . 'wp-includes/', backupbuddy_core::getBackupDirectory(), backupbuddy_core::getTempDirectory(), backupbuddy_core::getLogDirectory());
foreach ($directories as $directory) {
    $mode_octal_four = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
    $owner = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
    $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.
?>

<table class="widefat">
	<thead>
		<tr class="thead">
			<?php 
echo '<th>', __('Relative Path', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Suggestion', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Value', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Owner (UID:GID)', 'it-l10n-backupbuddy'), '</th>', '<th style="width: 60px;">', __('Status', 'it-l10n-backupbuddy'), '</th>';
?>
		</tr>
	</thead>
Пример #23
0
 public static function verify_directories($skipTempGeneration = false)
 {
     $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 (true !== $skipTempGeneration) {
         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;
         }
     }
     // If temp directory exists (should only be transient but just in case it is hanging around) make sure it's secured. BB will try to delete this directory but if it can't it will at least be checked to be secure.
     if (file_exists(backupbuddy_core::getTempDirectory())) {
         pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
     }
     global $pb_backupbuddy_directory_verification;
     $pb_backupbuddy_directory_verification = $success;
     return $success;
 }
Пример #24
0
<br><?php 
$tests = array();
$directories = array(ABSPATH . '', ABSPATH . 'wp-includes/', ABSPATH . 'wp-admin/', ABSPATH . 'wp-content/themes/', ABSPATH . 'wp-content/plugins/', ABSPATH . 'wp-content/', ABSPATH . 'wp-content/uploads/', ABSPATH . 'wp-includes/', backupbuddy_core::getBackupDirectory(), backupbuddy_core::getTempDirectory(), backupbuddy_core::getLogDirectory());
foreach ($directories as $directory) {
    $mode_octal_four = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
    $owner = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
    $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.
?>

<table class="widefat">
	<thead>
		<tr class="thead">
			<?php 
echo '<th>', __('Relative Path', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Suggestion', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Value', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Owner (UID:GID)', 'it-l10n-backupbuddy'), '</th>', '<th style="width: 60px;">', __('Status', 'it-l10n-backupbuddy'), '</th>';
?>
		</tr>
	</thead>
	<tfoot>