if ($x) {
$link = Contact::magicLink($x);
// @TODO making the return of magicLink save to use either externalRedirect or internalRedirect
- if (filter_var($link, FILTER_VALIDATE_URL)) {
- System::externalRedirect($link);
- } else {
- $a->internalRedirect($link);
- }
+ $a->redirect($link);
}
$a->internalRedirect('profile');
|| (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
{
- System::externalRedirect(defaults($url, $contact_url));
+ $a->redirect(defaults($url, $contact_url));
}
if ($contact['uid'] == 0 && local_user()) {
// Local user is already authenticated.
$target_url = defaults($url, $contact_url);
logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
- System::externalRedirect($target_url);
+ $a->redirect($target_url);
}
}
// Remote user is already authenticated.
$target_url = defaults($url, $contact_url);
logger($contact['name'] . " is already authenticated. Redirecting to " . $target_url, LOGGER_DEBUG);
- System::externalRedirect($target_url);
+ $a->redirect($target_url);
}
}
}
}
logger('redirecting to ' . $url, LOGGER_DEBUG);
- System::externalRedirect($url);
+ $a->redirect($url);
}
notice(L10n::t('Contact not found.'));
use DOMDocument;
use DOMXPath;
use Exception;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Network\HTTPException\InternalServerErrorException;
$redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
Core\System::externalRedirect($redirectTo);
}
+
+ /**
+ * Redirects to another URL in case
+ * Should only be used if it isn't clear if the URL is either internal or external
+ *
+ * @param string $toUrl The target URL
+ *
+ */
+ public function redirect($toUrl)
+ {
+ if (filter_var($toUrl, FILTER_VALIDATE_URL))
+ {
+ System::externalRedirect($toUrl);
+ } else {
+ $this->internalRedirect($toUrl);
+ }
+ }
}
if (!$cid) {
logger('No contact record found: ' . print_r($_REQUEST, true), LOGGER_DEBUG);
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
- if (filter_var($dest, FILTER_VALIDATE_URL)) {
- System::externalRedirect($dest);
- } else {
- $a->internalRedirect($dest);
- }
+ $a->redirect($dest);
}
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
}
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
- if (filter_var($dest, FILTER_VALIDATE_URL)) {
- System::externalRedirect($dest);
- } else {
- $a->internalRedirect($dest);
- }
+ $a->redirect($dest);
}
}