1
0
Fork 0

Split goaway to System::externalRedirectTo() and App->internalRedirect()

This commit is contained in:
Philipp Holzer 2018-10-19 20:11:27 +02:00
commit d00ddc01af
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
61 changed files with 286 additions and 266 deletions

View file

@ -2001,20 +2001,21 @@ class App
}
/**
* Redirects to another URL and exits this process.
* Redirects to another service relative to the current Friendica base.
* If you want to redirect to a external URL, use System::externalRedirectTo()
*
* @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
* @param bool $ssl if true, base URL will try to get called with https:// (works just for relative paths)
*
* @throws InternalServerErrorException In Case the given URL is not relative to the Friendica node
*/
public function redirect($toUrl = '', $ssl = false)
public function internalRedirect($toUrl = '', $ssl = false)
{
if (strstr(normalise_link($toUrl), 'http://')) {
$redirectTo = $toUrl;
} else {
$redirectTo = self::getApp()->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo');
}
header("Location: $redirectTo");
exit();
$redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
System::externalRedirect($redirectTo);
}
}