예제 #1
0
    backupbuddy_core::php_runtime_test_results();
}
$liveDestinationID = false;
foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
    if ('live' == $destination['type']) {
        $liveDestinationID = $destination_id;
        break;
    }
}
// Handle disconnect.
if ('disconnect' == pb_backupbuddy::_GET('live_action') && false !== $liveDestinationID) {
    // If disconnecting and not already disconnected.
    $disconnected = false;
    require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
    require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/class.itx_helper2.php';
    $destination_settings = backupbuddy_live_periodic::get_destination_settings();
    if ('yes' == pb_backupbuddy::_POST('disconnect')) {
        pb_backupbuddy::verify_nonce();
        // Pass itxapi_password to disconnect.
        global $wp_version;
        $password_hash = iThemes_Credentials::get_password_hash($destination_settings['itxapi_username'], pb_backupbuddy::_POST('password'));
        $access_token = ITXAPI_Helper2::get_access_token($destination_settings['itxapi_username'], $password_hash, site_url(), $wp_version);
        $settings = array('itxapi_username' => $destination_settings['itxapi_username'], 'itxapi_password' => $access_token, 'itxapi_token' => $destination_settings['itxapi_token']);
        $response = pb_backupbuddy_destination_live::stashAPI($settings, 'disconnect');
        if (!is_array($response)) {
            pb_backupbuddy::alert('Error Disconnecting: ' . $response);
        } elseif (!isset($response['success']) || '1' != $response['success']) {
            pb_backupbuddy::alert('Error #483948944. Unexpected response disconnecting: `' . print_r($response, true) . '`.');
        } else {
            $disconnected = true;
            // Clear destination settings.
예제 #2
0
 public static function _run_remote_snapshot($trigger = 'unknown')
 {
     if (false === self::_load_state()) {
         return false;
     }
     $destination_settings = backupbuddy_live_periodic::get_destination_settings();
     // Send email notification?
     if ('1' == $destination_settings['send_snapshot_notification'] || 0 == self::$_state['stats']['first_completion']) {
         // Email notification enabled _OR_ it's the first snapshot for this site.
         if ('' != $destination_settings['email']) {
             $email = $destination_settings['email'];
         } else {
             pb_backupbuddy::status('details', 'Snapshot set to send email notification to account. Send notification?: `' . $destination_settings['send_snapshot_notification'] . '`. First completion: `' . self::$_state['stats']['first_completion'] . '`.');
             $email = 'account';
         }
     } else {
         pb_backupbuddy::status('details', 'Snapshot set not to send email notification.');
         $email = 'none';
     }
     $additionalParams = array('ibpass' => '', 'email' => $email, 'stash_copy' => true, 'trim' => backupbuddy_live::get_archive_limit_settings_array(false));
     if ('' != pb_backupbuddy::$options['importbuddy_pass_hash']) {
         $additionalParams['ibpass'] = pb_backupbuddy::$options['importbuddy_pass_hash'];
     }
     if (false !== ($timezone = self::tz_offset_to_name(get_option('gmt_offset')))) {
         $additionalParams['timezone'] = $timezone;
     }
     require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php';
     $response = pb_backupbuddy_destination_live::stashAPI($destination_settings, 'live-snapshot', $additionalParams, $blocking = true, $passthru_errors = true);
     self::$_state['stats']['last_remote_snapshot_trigger'] = $trigger;
     self::$_state['stats']['last_remote_snapshot_response'] = $response;
     self::$_state['stats']['last_remote_snapshot_response_time'] = microtime(true);
     self::$_state['stats']['manual_snapshot'] = false;
     // Set false no matter what.
     if (pb_backupbuddy::$options['log_level'] == '3') {
         // Full logging enabled.
         pb_backupbuddy::status('details', 'live-snapshot response due to logging level: `' . print_r($response, true) . '`. Call params: `' . print_r($additionalParams, true) . ' `.');
     }
     do_action('backupbuddy_run_remote_snapshot_response', $response);
     return $response;
 }