+
+ if (empty($webfinger) && empty($lrdd)) {
+ while (empty($lrdd) && empty($webfinger) && (sizeof($path_parts) > 1)) {
+ $host .= "/".array_shift($path_parts);
+ $baseurl = $parts['scheme'] . '://' . $host;
+
+ if (!empty($nick)) {
+ $addr = $nick."@".$host;
+ }
+
+ $webfinger = self::getWebfinger($parts['scheme'] . '://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr);
+ if (empty($webfinger)) {
+ $lrdd = self::hostMeta($host);
+ }
+ }
+
+ if (empty($lrdd) && empty($webfinger)) {
+ return [];
+ }
+ }
+ } elseif (strstr($uri, '@')) {
+ // Remove "acct:" from the URI
+ $uri = str_replace('acct:', '', $uri);
+
+ $host = substr($uri, strpos($uri, '@') + 1);
+ $nick = substr($uri, 0, strpos($uri, '@'));
+ $addr = $uri;
+
+ $webfinger = self::getWebfinger('https://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr);
+ if (self::$istimeout) {
+ return [];
+ }
+
+ if (empty($webfinger)) {
+ $webfinger = self::getWebfinger('http://' . $host . self::WEBFINGER, 'application/jrd+json', $uri, $addr);
+ if (self::$istimeout) {
+ return [];
+ }
+ } else {
+ $baseurl = 'https://' . $host;
+ }
+
+ if (empty($webfinger)) {
+ $lrdd = self::hostMeta($host);
+ if (self::$istimeout) {
+ return [];
+ }
+ $baseurl = self::$baseurl;
+ } else {
+ $baseurl = 'http://' . $host;