From: Michael Date: Fri, 5 Jul 2019 06:41:48 +0000 (+0000) Subject: Basepath function now uses the contact field X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dda86f6dfc6ac74c17b05b93cd55def76dafb1ea;p=friendica.git Basepath function now uses the contact field --- diff --git a/mod/redir.php b/mod/redir.php index 233ec9b007..c99e1823c7 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -85,7 +85,7 @@ function redir_init(App $a) { // When the remote page does support OWA, then we enforce the use of it $basepath = Contact::getBasepath($contact_url); - if ($basepath == System::baseUrl()) { + if (Strings::compareLink($basepath, System::baseUrl())) { $use_magic = true; } else { $serverret = Network::curl($basepath . '/magic'); diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3f37d4ec90..775cc3fdad 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -176,7 +176,6 @@ class Contact extends BaseObject /** * @brief Get the basepath for a given contact link - * @todo Add functionality to store this value in the contact table * * @param string $url The contact link * @@ -186,13 +185,19 @@ class Contact extends BaseObject */ public static function getBasepath($url) { - $data = Probe::uri($url); - if (!empty($data['baseurl'])) { - return $data['baseurl']; + $contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]); + if (!empty($contact['baseurl'])) { + return $contact['baseurl']; + } + + self::updateFromProbeByURL($url, true); + + $contact = DBA::selectFirst('contact', ['baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]); + if (!empty($contact['baseurl'])) { + return $contact['baseurl']; } - // When we can't probe the server, we use some ugly function that does some pattern matching - return PortableContact::detectServer($url); + return ''; } /**