public function LingotekOAuthRequest::redirect in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::redirect()
- 7.5 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::redirect()
- 7.6 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::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 LingotekOAuthRequest::redirect()
- LingotekOAuthServer::authorizeFinish in lib/
oauth-php/ library/ LingotekOAuthServer.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/ LingotekOAuthRequest.php, line 804
Class
- LingotekOAuthRequest
- 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;
}