示例#1
0
}
// 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.
            unset(pb_backupbuddy::$options['remote_destinations'][$liveDestinationID]);
            pb_backupbuddy::save();
            // Clear cached Live credentials.
            require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php';
            delete_transient(pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME);
            pb_backupbuddy::disalert('', 'You have disconnected from Stash Live.');
            $liveDestinationID = false;
        }
<?php

backupbuddy_core::verifyAjaxAccess();
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
$destination_settings = backupbuddy_live_periodic::get_destination_settings();
$additionalParams = array('snapshot' => pb_backupbuddy::_POST('snapshot_id'));
require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php';
$response = pb_backupbuddy_destination_live::stashAPI($destination_settings, 'live-snapshot-status', $additionalParams);
if (!is_array($response)) {
    $error = 'Error #3497943: Unable to get Live snapshot status. Details: `' . $response . '`.';
    pb_backupbuddy::status('error', $error);
    die($error);
} else {
    pb_backupbuddy::status('details', 'Retrieved live snapshot status.');
    if (pb_backupbuddy::$options['log_level'] == '3') {
        // Full logging enabled.
        pb_backupbuddy::status('details', 'live-snapshot-status response due to logging level: `' . print_r($response, true) . '`. Call params: `' . print_r($additionalParams, true) . ' `.');
    }
    // If no impoortbuddy password is set then remove importbuddy from response so it is not shown for download.
    if ('' == pb_backupbuddy::$options['importbuddy_pass_hash']) {
        unset($response['snapshot']['importbuddy']);
    }
    $response['current_time'] = time();
    die(json_encode($response));
}
// end deletion.
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
    $downloadSettings = $settings;
    $downloadSettings['directory'] = $remotePath;
    $link = pb_backupbuddy_destination_live::getFileURL($downloadSettings, base64_decode(pb_backupbuddy::_GET('downloadlink_file')));
    pb_backupbuddy::alert('You may download this backup (' . base64_decode(pb_backupbuddy::_GET('downloadlink_file')) . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
    echo '<br>';
}
// end download link.
$marker = null;
if ('' != pb_backupbuddy::_GET('marker')) {
    // Jump to specific spot.
    $marker = base64_decode(urldecode(pb_backupbuddy::_GET('marker')));
}
$files = pb_backupbuddy_destination_live::listFiles($settings, $remotePath, $marker);
if (!is_array($files)) {
    pb_backupbuddy::alert('Error #892329b: ' . $files);
    die;
}
/*
echo '<pre>';
print_r( $files );
echo '</pre>';
*/
$backup_list_temp = array();
foreach ((array) $files as $file) {
    $last_modified = strtotime($file['LastModified']);
    while (isset($backup_list_temp[$last_modified])) {
        $last_modified += 0.1;
        // Add .1 repeatedly until timestamp is free.
示例#4
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;
 }