break;
default:
$appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
- if (filter_var($url, FILTER_VALIDATE_URL)) {
- System::externalRedirect($destination_url . $appendix);
- } else {
- $a->internalRedirect($destination_url . $appendix);
- }
+ $a->redirect($destination_url . $appendix);
break;
}
// NOTREACHED
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Util\Strings;
+use Friendica\Util\Network;
function redir_init(App $a) {
$contact_url = $contact['url'];
- if ($contact['network'] !== Protocol::DFRN // Authentication isn't supported for non DFRN contacts.
- || (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
+ if ((!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.
{
$a->redirect(defaults($url, $contact_url));
}
}
+ // When the remote page does support OWA, then we enforce the use of it
+ $basepath = Contact::getBasepath($contact_url);
+ $serverret = Network::curl($basepath . '/magic');
+ if ($serverret->isSuccess()) {
+ $contact['issued-id'] = '';
+ $contact['dfrn-id'] = '';
+ }
+
// Doing remote auth with dfrn.
if (local_user() && (!empty($contact['dfrn-id']) || !empty($contact['issued-id'])) && empty($contact['pending'])) {
$dfrn_id = $orig_id = (($contact['issued-id']) ? $contact['issued-id'] : $contact['dfrn-id']);
* @}
*/
+ /**
+ * @brief Get the basepath for a given contact link
+ *
+ * @param string $url The contact link
+ *
+ * @return string basepath
+ */
+ public static function getBasepath($url)
+ {
+ $data = Probe::uri($url);
+ if (!empty($data['baseurl'])) {
+ return $data['baseurl'];
+ }
+
+ $urlarr = explode('/profile/', $url);
+ $basepath = $urlarr[0];
+
+ return $basepath;
+ }
+
/**
* @brief Returns the contact id for the user and the public contact id for a given contact id
*
$this->redirectUrl = Network::unparseURL($redirect_parts);
- $this->isRedirectUrl = filter_var($this->redirectUrl, FILTER_VALIDATE_URL) !== false;
+ $this->isRedirectUrl = true;
} else {
$this->isRedirectUrl = false;
}
}
}
- self::$baseurl = "http://".$host;
+ self::$baseurl = $host_url;
Logger::log("Probing successful for ".$host, Logger::DEBUG);
}
$actor = JsonLD::fetchElement($data, 'actor', 'id');
- if (empty($actor)) {
+ if (empty($actor) || !is_string($actor)) {
return false;
}