Пример #1
0
// Register BackupBuddy API. As of BackupBuddy v5.0. Access credentials will be checked within callback.
add_action('wp_ajax_backupbuddy_api', array(pb_backupbuddy::$_ajax, 'api'));
add_action('wp_ajax_nopriv_backupbuddy_api', array(pb_backupbuddy::$_ajax, 'api'));
/********** DASHBOARD (admin) **********/
// Display stats in Dashboard.
//if ( pb_backupbuddy::$options['dashboard_stats'] == '1' ) {
if (!is_multisite() || is_multisite() && is_network_admin()) {
    // Only show if standalon OR in main network admin.
    pb_backupbuddy::add_dashboard_widget('stats', 'BackupBuddy v' . pb_backupbuddy::settings('version'), 'godmode');
}
//}
/********** FILTERS (admin) **********/
pb_backupbuddy::add_filter('plugin_row_meta', 10, 2);
/********** PAGES (admin) **********/
$icon = '';
if (is_multisite() && backupbuddy_core::is_network_activated() && !defined('PB_DEMO_MODE')) {
    // Multisite installation.
    if (defined('PB_BACKUPBUDDY_MULTISITE_EXPERIMENT') && PB_BACKUPBUDDY_MULTISITE_EXPERIMENT == TRUE) {
        // comparing with bool but loose so string is acceptable.
        if (is_network_admin()) {
            // Network Admin pages
            pb_backupbuddy::add_page('', 'backup', array(pb_backupbuddy::settings('name'), __('Backup', 'it-l10n-backupbuddy')), 'manage_network', $icon);
            pb_backupbuddy::add_page('backup', 'migrate_restore', __('Migrate, Restore', 'it-l10n-backupbuddy'), 'manage_network');
            pb_backupbuddy::add_page('backup', 'destinations', __('Remote Destinations', 'it-l10n-backupbuddy'), pb_backupbuddy::$options['role_access']);
            pb_backupbuddy::add_page('backup', 'multisite_import', __('MS Import (beta)', 'it-l10n-backupbuddy'), 'manage_network');
            pb_backupbuddy::add_page('backup', 'server_tools', __('Server Tools', 'it-l10n-backupbuddy'), 'manage_network');
            pb_backupbuddy::add_page('backup', 'malware_scan', __('Malware Scan', 'it-l10n-backupbuddy'), 'manage_network');
            pb_backupbuddy::add_page('backup', 'scheduling', __('Schedules', 'it-l10n-backupbuddy'), 'manage_network');
            pb_backupbuddy::add_page('backup', 'settings', __('Settings', 'it-l10n-backupbuddy'), 'manage_network');
        } else {
            // Subsite pages.
Пример #2
0
 public static function preflight_check()
 {
     $tests = array();
     // MULTISITE BETA WARNING.
     if (is_multisite() && backupbuddy_core::is_network_activated() && !defined('PB_DEMO_MODE')) {
         // Multisite installation.
         $tests[] = array('test' => 'multisite_beta', 'success' => false, 'message' => 'WARNING: BackupBuddy Multisite functionality is EXPERIMENTAL and NOT officially supported. Multiple issues are known. Usage of it is at your own risk and should not be relied upon. Standalone WordPress sites are suggested. You may use the "Export" feature to export your subsites into standalone WordPress sites. To enable experimental BackupBuddy Multisite functionality you must add the following line to your wp-config.php file: <b>define( \'PB_BACKUPBUDDY_MULTISITE_EXPERIMENT\', true );</b>');
     }
     // end network-activated multisite.
     // LOOPBACKS TEST.
     if (($loopback_response = self::loopback_test()) === true) {
         $success = true;
         $message = '';
     } else {
         // failed
         $success = false;
         if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON == true) {
             $message = __('Running in Alternate WordPress Cron mode. HTTP Loopback Connections are not enabled on this server but you have overridden this in the wp-config.php file (this is a good thing).', 'it-l10n-backupbuddy') . ' <a href="http://ithemes.com/codex/page/BackupBuddy:_Frequent_Support_Issues#HTTP_Loopback_Connections_Disabled" target="_blank">' . __('Additional Information Here', 'it-l10n-backupbuddy') . '</a>.';
         } else {
             $message = __('HTTP Loopback Connections are not enabled on this server or are not functioning properly. You may encounter stalled, significantly delayed backups, or other difficulties. See details in the box below. This may be caused by a conflicting plugin such as a caching plugin.', 'it-l10n-backupbuddy') . ' <a href="http://ithemes.com/codex/page/BackupBuddy:_Frequent_Support_Issues#HTTP_Loopback_Connections_Disabled" target="_blank">' . __('Click for instructions on how to resolve this issue.', 'it-l10n-backupbuddy') . '</a>';
             $message .= ' <b>Details:</b> <textarea style="height: 50px; width: 100%;">' . $loopback_response . '</textarea>';
         }
     }
     $tests[] = array('test' => 'loopbacks', 'success' => $success, 'message' => $message);
     // POSSIBLE CACHING PLUGIN CONFLICT WARNING.
     $success = true;
     $message = '';
     $found_plugins = array();
     if (!is_multisite()) {
         $active_plugins = serialize(get_option('active_plugins'));
         foreach (self::$warn_plugins as $warn_plugin => $warn_plugin_title) {
             if (FALSE !== strpos($active_plugins, $warn_plugin)) {
                 // Plugin active.
                 $found_plugins[] = $warn_plugin_title;
                 $success = false;
             }
         }
     }
     if (count($found_plugins) > 0) {
         $message = __('One or more caching plugins were detected as activated. Some caching plugin configurations may possibly cache & interfere with backup processes or WordPress cron. If you encounter problems clear the caching plugin\'s cache (deactivating the plugin may help) to troubleshoot.', 'it-l10n-backupbuddy') . ' ';
         $message .= __('Activated caching plugins detected:', 'it-l10n-backupbuddy') . ' ';
         $message .= implode(', ', $found_plugins);
         $message .= '.';
     }
     $tests[] = array('test' => 'loopbacks', 'success' => $success, 'message' => $message);
     // WORDPRESS IN SUBDIRECTORIES TEST.
     $wordpress_locations = self::get_wordpress_locations();
     if (count($wordpress_locations) > 0) {
         $success = false;
         $message = __('WordPress may have been detected in one or more subdirectories. Backing up multiple instances of WordPress may result in server timeouts due to increased backup time. You may exclude WordPress directories via the Settings page. Detected non-excluded locations:', 'it-l10n-backupbuddy') . ' ' . implode(', ', $wordpress_locations);
     } else {
         $success = true;
         $message = '';
     }
     $tests[] = array('test' => 'wordpress_subdirectories', 'success' => $success, 'message' => $message);
     // Log file directory writable for status logging.
     $status_directory = backupbuddy_core::getLogDirectory();
     if (!file_exists($status_directory)) {
         if (false === pb_backupbuddy::anti_directory_browsing($status_directory, $die = false)) {
             $success = false;
             $message = 'The status log file directory `' . $status_directory . '` is not creatable or permissions prevent access. Verify permissions of it and/or its parent directory. Backup status information will be unavailable until this is resolved.';
         }
     }
     if (!is_writable($status_directory)) {
         $success = false;
         $message = 'The status log file directory `' . $status_directory . '` is not writable. Please verify permissions before creating a backup. Backup status information will be unavailable until this is resolved.';
     } else {
         $success = true;
         $message = '';
     }
     $tests[] = array('test' => 'status_directory_writable', 'success' => $success, 'message' => $message);
     // CHECK ZIP AVAILABILITY.
     require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     /***** BEGIN LOOKING FOR UNFINISHED RECENT BACKUPS *****/
     if ('' != pb_backupbuddy::$options['last_backup_serial']) {
         $lastBackupFileoptions = backupbuddy_core::getLogDirectory() . 'fileoptions/' . pb_backupbuddy::$options['last_backup_serial'] . '.txt';
         if (file_exists($lastBackupFileoptions)) {
             require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
             pb_backupbuddy::status('details', 'Fileoptions instance #32.');
             $backup_options = new pb_backupbuddy_fileoptions($lastBackupFileoptions, $read_only = true);
             if (true !== ($result = $backup_options->is_ok()) || !isset($backup_options->options['updated_time'])) {
                 // NOTE: If this files during a backup it may try to read the fileoptions file too early due to the last_backup_serial being set. Suppressing errors for now.
                 pb_backupbuddy::status('details', 'Unable to retrieve fileoptions file (this is normal if a backup is currently in process & may be ignored) `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . pb_backupbuddy::$options['last_backup_serial'] . '.txt' . '`. Err 54478236765. Details: `' . $result . '`.');
             } else {
                 if ($backup_options->options['updated_time'] < 180) {
                     // Been less than 3min since last backup.
                     if (!empty($backup_options->options['steps'])) {
                         // Look for incomplete steps.
                         $found_unfinished = false;
                         foreach ((array) $backup_options->options['steps'] as $step) {
                             if ($step['finish_time'] == '0') {
                                 // Found an unfinished step.
                                 $found_unfinished = true;
                                 break;
                             }
                         }
                         // end foreach.
                         if ($found_unfinished === true) {
                             $tests[] = array('test' => 'recent_backup', 'success' => false, 'message' => __('A backup was recently started and reports unfinished steps. You should wait unless you are sure the previous backup has completed or failed to avoid placing a heavy load on your server.', 'it-l10n-backupbuddy') . ' Last updated: ' . pb_backupbuddy::$format->date($backup_options->options['updated_time']) . '; ' . ' Serial: ' . pb_backupbuddy::$options['last_backup_serial']);
                         }
                         // end $found_unfinished === true.
                     }
                     // end if.
                 }
             }
         }
     }
     /***** END LOOKING FOR UNFINISHED RECENT BACKUPS *****/
     /***** BEGIN LOOKING FOR BACKUP FILES IN SITE ROOT *****/
     $files = glob(ABSPATH . 'backup-*.zip');
     if (!is_array($files) || empty($files)) {
         $files = array();
     }
     foreach ($files as &$file) {
         $file = basename($file);
     }
     if (count($files) > 0) {
         $files_string = implode(', ', $files);
         $tests[] = array('test' => 'root_backups-' . $files_string, 'success' => false, 'message' => 'One or more backup files, `' . $files_string . '` was found in the root directory of this site. This may be leftover from a recent restore. You should usually remove backup files from the site root for security.');
     }
     /***** END LOOKING FOR BACKUP FILES IN SITE ROOT *****/
     if (!is_writable(backupbuddy_core::getBackupDirectory())) {
         $tests[] = array('test' => 'backup_dir_permissions', 'success' => false, 'message' => 'Invalid backup directory permissions. Verify the directory `' . backupbuddy_core::getBackupDirectory() . '` is writable.');
     }
     /* THIS MAY NOT EXIST YET.
     		if ( ! is_writable( backupbuddy_core::getTempDirectory() ) ) {
     			$tests[] = array(
     				'test'		=>	'temp_dir_permissions',
     				'success'	=>	false,
     				'message'	=>	'Invalid temp directory permissions. Verify the directory `' . backupbuddy_core::getTempDirectory() . '` is writable.'
     			);
     		}
     		*/
     return $tests;
 }
Пример #3
0
 function multisite_network_warning()
 {
     $message = 'BackupBuddy Multisite support is experimental beta software and is not officially supported in a Multisite setting.';
     if (!backupbuddy_core::is_network_activated()) {
         $message .= ' You must <a href="' . esc_url(admin_url('network/plugins.php')) . '">Network Activate</a> BackupBuddy to use it with Multisite (not activate within subsites nor the main site).';
     }
     if (!defined('PB_BACKUPBUDDY_MULTISITE_EXPERIMENT') || PB_BACKUPBUDDY_MULTISITE_EXPERIMENT != TRUE) {
         $message .= ' You must add the following line to your wp-config.php to activate Multisite experimental functionality: <b>define( \'PB_BACKUPBUDDY_MULTISITE_EXPERIMENT\', true );</b>';
     }
     pb_backupbuddy::alert($message, true);
 }
Пример #4
0
 function register_widgets()
 {
     //wp_add_dashboard_widget( 'pb_' . self::settings( 'slug' ) . '_' . $tag, $title,  array( &self::$_dashboard, $tag ) );
     foreach (pb_backupbuddy::$_dashboard_widgets as $widget) {
         if ($widget['capability'] == 'godmode') {
             // godmode capabiltiy.
             if (is_multisite() && backupbuddy_core::is_network_activated()) {
                 // In a network installation.
                 if (!current_user_can('manage_network')) {
                     continue;
                     // Skip this widget. Access denied to it.
                 }
             } else {
                 // Standalone
                 if (!current_user_can('activate_plugins')) {
                     continue;
                     // Skip this widget. Access denied to it.
                 }
             }
         } else {
             // WP capability.
             if (!current_user_can($widget['capability'])) {
                 continue;
                 // Skip this widget. Access denied to it.
             }
         }
         $widget_slug = 'pb_' . pb_backupbuddy::settings('slug') . '_' . $widget['tag'];
         wp_add_dashboard_widget($widget_slug, $widget['title'], array(&$this, $widget['tag']));
         // If force top is enabled then we will attempt to force the widget to the top if possible.
         if (isset($widget['force_top']) && $widget['force_top'] === true) {
             // Note: Only works if users have never re-arranged their dashboard widgets.
             global $wp_meta_boxes;
             $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
             $widget_backup = array($widget_slug => $normal_dashboard[$widget_slug]);
             // Save copy of our widget.
             unset($normal_dashboard[$widget_slug]);
             // Delete our widget.
             $wp_meta_boxes['dashboard']['normal']['core'] = array_merge($widget_backup, $normal_dashboard);
             // Merge our widget into the top.
         }
     }
 }