if (count($settings_result['errors']) > 0) {
     // Form errors.
     echo $login_welcome;
     pb_backupbuddy::alert(implode('<br>', $settings_result['errors']));
     $credentials_form->display_settings('Submit');
     $pb_hide_test = true;
     $pb_hide_save = true;
     return;
 } else {
     // No form errors; process!
     $pb_hide_test = true;
     $pb_hide_save = true;
     require_once dirname(__FILE__) . '/class.itx_helper2.php';
     global $wp_version;
     $itxapi_username = strtolower($settings_result['data']['itxapi_username']);
     $password_hash = iThemes_Credentials::get_password_hash($itxapi_username, $settings_result['data']['itxapi_password_raw']);
     $access_token = ITXAPI_Helper2::get_access_token($itxapi_username, $password_hash, site_url(), $wp_version);
     $settings = array('itxapi_username' => $itxapi_username, 'itxapi_password' => $access_token);
     $response = pb_backupbuddy_destination_stash2::stashAPI($settings, 'connect');
     if (!is_array($response)) {
         // Error message.
         pb_backupbuddy::alert('Error #23333: Unexpected server response. Check your login and try again. Detailed response: `' . print_r($response, true) . '`.');
         $credentials_form->display_settings('Submit');
     } else {
         if (isset($response['error'])) {
             pb_backupbuddy::alert('Error: ' . $response['error']['message']);
             $credentials_form->display_settings('Submit');
         } else {
             if (isset($response['token'])) {
                 $itxapi_token = $response['token'];
             } else {
示例#2
0
 private static function get_password_hash($username, $password)
 {
     require_once ABSPATH . 'wp-includes/class-phpass.php';
     require_once dirname(__FILE__) . '/class-ithemes-credentials.php';
     $password = iThemes_Credentials::get_password_hash($username, $password);
     $salted_password = $password . $username . self::get_site_url() . $GLOBALS['wp_version'];
     $salted_password = substr($salted_password, 0, max(strlen($password), 512));
     $hasher = new PasswordHash(self::$password_iterations, true);
     $auth_token = $hasher->HashPassword($salted_password);
     return $auth_token;
 }
 require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php';
 global $wp_version;
 $itxapi_username = strtolower(pb_backupbuddy::_POST('stash2_username'));
 // See if this user already exists.
 foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_index => $destination) {
     // Loop through ending with the last created destination of this type.
     if ('stash2' == $destination['type']) {
         if ($itxapi_username == $destination['itxapi_username']) {
             // Existing destination match.
             $destination_id = $destination_index;
         }
     }
 }
 if (!isset($destination_id)) {
     // Did not already find the same Stash destination.
     $password_hash = iThemes_Credentials::get_password_hash($itxapi_username, pb_backupbuddy::_POST('stash2_password'));
     $access_token = ITXAPI_Helper2::get_access_token($itxapi_username, $password_hash, site_url(), $wp_version);
     $settings = array('itxapi_username' => $itxapi_username, 'itxapi_password' => $access_token);
     $response = pb_backupbuddy_destination_stash2::stashAPI($settings, 'connect');
     if (!is_array($response)) {
         // Error message.
         $errors[] = 'Error #32898973: Unexpected server response. Check your Stash login and try again. Detailed response: `' . print_r($response, true) . '`.';
     } else {
         if (isset($response['error'])) {
             $errors[] = $response['error']['message'];
         } else {
             if (isset($response['token'])) {
                 $itxapi_token = $response['token'];
             } else {
                 $errors[] = 'Error #32977932: Unexpected server response. Token missing. Check your Stash login and try again. Detailed response: `' . print_r($response, true) . '`.';
             }
示例#4
0
        $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.
            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);
示例#5
0
文件: server.php 项目: AndyA/River
 private static function get_password_hash($username, $password)
 {
     require_once ABSPATH . 'wp-includes/class-phpass.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/class-ithemes-credentials.php';
     $password = iThemes_Credentials::get_password_hash($username, $password);
     $salted_password = $password . $username . get_bloginfo('url') . Ithemes_Sync_Functions::get_wordpress_version();
     $salted_password = substr($salted_password, 0, max(strlen($password), 512));
     $hasher = new PasswordHash(self::$password_iterations, true);
     $auth_token = $hasher->HashPassword($salted_password);
     return $auth_token;
 }