$data['url'] = $uri;
}
- if (!empty($data['photo'])) {
- $data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink($data['baseurl'] ?? ''), Strings::normaliseLink($data['photo']));
- } else {
+ if (!empty($data['photo']) && !empty($data["baseurl"])) {
+ $data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink($data['baseurl']), Strings::normaliseLink($data['photo']));
+ } elseif (empty($data['photo'])) {
$data['photo'] = System::baseUrl() . '/images/person-300.jpg';
}
$result = self::pumpio($webfinger, $addr, $result);
}
if ((empty($result['network']) && ($network == "")) || ($network == Protocol::ZOT)) {
- $result = self::hubzilla($webfinger, $result);
+ $result = self::zot($webfinger, $result);
}
if ((empty($result['network']) && ($network == "")) || ($network == Protocol::FEED)) {
$result = self::feed($uri, true, $result);
Logger::log($uri." is ".$result["network"], Logger::DEBUG);
- if (empty($result["baseurl"])) {
+ if (empty($result["baseurl"]) && ($result["network"] != Protocol::PHANTOM)) {
$pos = strpos($result["url"], $host);
if ($pos) {
$result["baseurl"] = substr($result["url"], 0, $pos).$host;
return $result;
}
- private static function hubzilla($webfinger, $data)
+ /**
+ * Check for Zot contact
+ *
+ * @param array $webfinger Webfinger data
+ * @param array $data previously probed data
+ *
+ * @return array Zot data
+ * @throws HTTPException\InternalServerErrorException
+ */
+ private static function zot($webfinger, $data)
{
- if (strstr($webfinger['properties']['http://purl.org/zot/federation'] ?? '', 'zot')) {
- $data['network'] = Protocol::ZOT;
- }
- if (!empty($webfinger['properties']['http://webfinger.net/ns/name'])) {
- $data['name'] = $webfinger['properties']['http://webfinger.net/ns/name'];
- }
- if (!empty($webfinger['properties']['https://w3id.org/security/v1#publicKeyPem'])) {
- $data['pubkey'] = $webfinger['properties']['https://w3id.org/security/v1#publicKeyPem'];
- }
-//print_r($webfinger);
- $hcard_url = '';
$zot_url = '';
foreach ($webfinger['links'] as $link) {
- if (($link['rel'] == 'http://microformats.org/profile/hcard') && !empty($link['href'])) {
- $hcard_url = $link['href'];
- } elseif (($link['rel'] == 'http://purl.org/zot/protocol') && !empty($link['href'])) {
+ if (($link['rel'] == 'http://purl.org/zot/protocol') && !empty($link['href'])) {
$zot_url = $link['href'];
- } elseif (($link["rel"] == "http://purl.org/zot/protocol/6.0") && !empty($link["href"])) {
- $data["url"] = $link["href"];
- } elseif (($link["rel"] == "http://webfinger.net/rel/blog") && !empty($link["href"]) && empty($data["url"])) {
- $data["url"] = $link["href"];
}
}
$zot_url = self::$baseurl . '/.well-known/zot-info?address=' . $data['addr'];
}
- if (!empty($hcard_url)) {
- $data = self::pollHcard($hcard_url, $data, false);
- }
-
if (!empty($zot_url)) {
$data = self::pollZot($zot_url, $data);
}
if (!empty($json['protocols']) && in_array('zot', $json['protocols'])) {
$data['network'] = Protocol::ZOT;
+ } elseif (!isset($json['protocols'])) {
+ $data['network'] = Protocol::ZOT;
}
if (!empty($json['guid'])) {
if (!empty($json['name'])) {
$data['name'] = $json['name'];
}
+ if (!empty($json['photo']) && empty($data['photo'])) {
+ $data['photo'] = $json['photo'];
+ }
if (!empty($json['address'])) {
$data['addr'] = $json['address'];
}
* @brief Check for Diaspora contact
*
* @param array $webfinger Webfinger data
+ * @param array $data previously probed data
*
* @return array Diaspora data
* @throws HTTPException\InternalServerErrorException
*
* @param array $webfinger Webfinger data
* @param bool $short Short detection mode
+ * @param array $data previously probed data
*
* @return array|bool OStatus data or "false" on error or "true" on short mode
* @throws HTTPException\InternalServerErrorException
/**
* @brief Check for pump.io contact
*
- * @param array $webfinger Webfinger data
- *
- * @param $addr
+ * @param array $webfinger Webfinger data
+ * @param string $addr
+ * @param array $data previously probed data
* @return array pump.io data
*/
private static function pumpio($webfinger, $addr, $data)
*
* @param string $url Profile link
* @param boolean $probe Do a probe if the page contains a feed link
+ * @param array $data previously probed data
*
* @return array feed data
* @throws HTTPException\InternalServerErrorException