You are here

public function OAuthRequest::redirect in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.2 lib/oauth-php/library/OAuthRequest.php \OAuthRequest::redirect()

* Simple function to perform a redirect (GET). * Redirects the User-Agent, does not return. * *

Parameters

string uri: * @param array params parameters, urlencoded * @exception OAuthException2 when redirect uri is illegal

1 call to OAuthRequest::redirect()
OAuthServer::authorizeFinish in lib/oauth-php/library/OAuthServer.php
* Overrule this method when you want to display a nice page when * the authorization is finished. This function does not know if the authorization was * succesfull, you need to check the token in the database. * *

File

lib/oauth-php/library/OAuthRequest.php, line 804

Class

OAuthRequest
Object to parse an incoming OAuth request or prepare an outgoing OAuth request

Code

public function redirect($uri, $params) {
  if (!empty($params)) {
    $q = array();
    foreach ($params as $name => $value) {
      $q[] = $name . '=' . $value;
    }
    $q_s = implode('&', $q);
    if (strpos($uri, '?')) {
      $uri .= '&' . $q_s;
    }
    else {
      $uri .= '?' . $q_s;
    }
  }

  // simple security - multiline location headers can inject all kinds of extras
  $uri = preg_replace('/\\s/', '%20', $uri);
  if (strncasecmp($uri, 'http://', 7) && strncasecmp($uri, 'https://', 8)) {
    if (strpos($uri, '://')) {
      throw new OAuthException2('Illegal protocol in redirect uri ' . $uri);
    }
    $uri = 'http://' . $uri;
  }
  header('HTTP/1.1 302 Found');
  header('Location: ' . $uri);
  echo '';
  exit;
}