} elseif ($curlResult->isTimeout()) {
Logger::info('Probing timeout', ['url' => $ssl_url], Logger::DEBUG);
self::$istimeout = true;
- return false;
+ return [];
}
if (!is_object($xrd) && !empty($url)) {
if ($curlResult->isTimeout()) {
Logger::info('Probing timeout', ['url' => $url], Logger::DEBUG);
self::$istimeout = true;
- return false;
+ return [];
} elseif ($connection_error && $ssl_connection_error) {
self::$istimeout = true;
- return false;
+ return [];
}
$xml = $curlResult->getBody();
}
}
- if (!is_array($webfinger["links"])) {
+ if (empty($webfinger["links"])) {
Logger::log("No webfinger links found for ".$uri, Logger::DEBUG);
- return false;
+ return [];
}
$data = [];
$ap_profile = ActivityPub::probeProfile($uri);
if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') != Protocol::DFRN))) {
- $subscribe = $data['subscribe'];
+ $subscribe = $data['subscribe'] ?? '';
$data = $ap_profile;
$data['subscribe'] = $subscribe;
} elseif (!empty($ap_profile)) {
$curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return [];
}
$data = $curlResult->getBody();
$webfinger = json_decode($data, true);
- if (is_array($webfinger)) {
+ if (!empty($webfinger)) {
if (!isset($webfinger["links"])) {
Logger::log("No json webfinger links for ".$url, Logger::DEBUG);
- return false;
+ return [];
}
return $webfinger;
}
$xrd = XML::parseString($data, true);
if (!is_object($xrd)) {
Logger::log("No webfinger data retrievable for ".$url, Logger::DEBUG);
- return false;
+ return [];
}
$xrd_arr = XML::elementToArray($xrd);
if (!isset($xrd_arr["xrd"]["link"])) {
Logger::log("No XML webfinger links for ".$url, Logger::DEBUG);
- return false;
+ return [];
}
$webfinger = [];
$curlResult = Network::curl($noscrape_url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return [];
}
$content = $curlResult->getBody();
if (!$content) {
Logger::log("Empty body for ".$noscrape_url, Logger::DEBUG);
- return false;
+ return [];
}
$json = json_decode($content, true);
if (!is_array($json)) {
Logger::log("No json data for ".$noscrape_url, Logger::DEBUG);
- return false;
+ return [];
}
if (!empty($json["fn"])) {
}
if (!isset($data["network"]) || ($hcard_url == "")) {
- return false;
+ return [];
}
// Fetch data via noscrape - this is faster
$curlResult = Network::curl($hcard_url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return [];
}
$content = $curlResult->getBody();
if (!$content) {
- return false;
+ return [];
}
$doc = new DOMDocument();
if (!@$doc->loadHTML($content)) {
- return false;
+ return [];
}
$xpath = new DomXPath($doc);
$vcards = $xpath->query("//div[contains(concat(' ', @class, ' '), ' vcard ')]");
if (!is_object($vcards)) {
- return false;
+ return [];
}
if (!isset($data["baseurl"])) {
}
if (empty($data["url"]) || empty($hcard_url)) {
- return false;
+ return [];
}
if (!empty($webfinger["aliases"]) && is_array($webfinger["aliases"])) {
$data = self::pollHcard($hcard_url, $data);
if (!$data) {
- return false;
+ return [];
}
if (!empty($data["url"])
$data["notify"] = $data["baseurl"] . "/receive/users/" . $data["guid"];
$data["batch"] = $data["baseurl"] . "/receive/public";
} else {
- return false;
+ return [];
}
return $data;
$data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
}
- if (is_array($webfinger["links"])) {
+ if (!empty($webfinger["links"])) {
// The array is reversed to take into account the order of preference for same-rel links
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
foreach (array_reverse($webfinger["links"]) as $link) {
$curlResult = Network::curl($pubkey);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return $short ? false : [];
}
$pubkey = $curlResult->getBody();
}
) {
$data["network"] = Protocol::OSTATUS;
} else {
- return false;
+ return $short ? false : [];
}
if ($short) {
$curlResult = Network::curl($data["poll"]);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return [];
}
$feed = $curlResult->getBody();
$feed_data = Feed::import($feed);
if (!$feed_data) {
- return false;
+ return [];
}
if (!empty($feed_data["header"]["author-name"])) {
{
$curlResult = Network::curl($profile_link);
if (!$curlResult->isSuccess()) {
- return false;
+ return [];
}
$doc = new DOMDocument();
if (!@$doc->loadHTML($curlResult->getBody())) {
- return false;
+ return [];
}
$xpath = new DomXPath($doc);
$data["network"] = Protocol::PUMPIO;
} else {
- return false;
+ return [];
}
$profile_data = self::pumpioProfileData($data["url"]);
if (!$profile_data) {
- return false;
+ return [];
}
$data = array_merge($data, $profile_data);
$curlResult = Network::curl($url);
if ($curlResult->isTimeout()) {
self::$istimeout = true;
- return false;
+ return [];
}
$feed = $curlResult->getBody();
$feed_data = Feed::import($feed);
if (!$feed_data) {
if (!$probe) {
- return false;
+ return [];
}
$feed_url = self::getFeedLink($url, $feed);
if (!$feed_url) {
- return false;
+ return [];
}
return self::feed($feed_url, false);
private static function mail($uri, $uid)
{
if (!Network::isEmailDomainValid($uri)) {
- return false;
+ return [];
}
if ($uid == 0) {
- return false;
+ return [];
}
$user = DBA::selectFirst('user', ['prvkey'], ['uid' => $uid]);
$mailacct = DBA::selectFirst('mailacct', $fields, $condition);
if (!DBA::isResult($user) || !DBA::isResult($mailacct)) {
- return false;
+ return [];
}
$mailbox = Email::constructMailboxName($mailacct);
openssl_private_decrypt(hex2bin($mailacct['pass']), $password, $user['prvkey']);
$mbox = Email::connect($mailbox, $mailacct['user'], $password);
if (!$mbox) {
- return false;
+ return [];
}
$msgs = Email::poll($mbox, $uri);
Logger::log('searching '.$uri.', '.count($msgs).' messages found.', Logger::DEBUG);
if (!count($msgs)) {
- return false;
+ return [];
}
$phost = substr($uri, strpos($uri, '@') + 1);