*/
private static function ownHost($host)
{
- $own_host = get_app()->get_hostname();
+ $own_host = get_app()->getHostName();
$parts = parse_url($host);
logger("Probing for ".$host, LOGGER_DEBUG);
$xrd = null;
- $ret = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
- if ($ret['success']) {
- $xml = $ret['body'];
+ $curlResult = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ if ($curlResult->isSuccess()) {
+ $xml = $curlResult->getBody();
$xrd = XML::parseString($xml, false);
$host_url = 'https://'.$host;
}
if (!is_object($xrd)) {
- $ret = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
- logger("Probing timeout for ".$url, LOGGER_DEBUG);
+ $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
+ if ($curlResult->isTimeout()) {
+ logger("Probing timeout for " . $url, LOGGER_DEBUG);
return false;
}
- $xml = $ret['body'];
+ $xml = $curlResult->getBody();
$xrd = XML::parseString($xml, false);
$host_url = 'http://'.$host;
}
$data = null;
}
- if (in_array(defaults($data, 'network', ''), ['', Protocol::PHANTOM])) {
- $ap_profile = ActivityPub::fetchProfile($uri);
- if (!empty($ap_profile) && ($ap_profile['network'] == Protocol::ACTIVITYPUB)) {
- $data = $ap_profile;
- }
+ $ap_profile = ActivityPub::probeProfile($uri);
+
+ if (!empty($ap_profile) && (defaults($data, 'network', '') != Protocol::DFRN)) {
+ $data = $ap_profile;
}
if (!isset($data["url"])) {
$xrd_timeout = Config::get('system', 'xrd_timeout', 20);
$redirects = 0;
- $ret = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
+ if ($curlResult->isTimeout()) {
return false;
}
- $data = $ret['body'];
+ $data = $curlResult->getBody();
$webfinger = json_decode($data, true);
if (is_array($webfinger)) {
*/
private static function pollNoscrape($noscrape_url, $data)
{
- $ret = Network::curl($noscrape_url);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($noscrape_url);
+ if ($curlResult->isTimeout()) {
return false;
}
- $content = $ret['body'];
+ $content = $curlResult->getBody();
if (!$content) {
logger("Empty body for ".$noscrape_url, LOGGER_DEBUG);
return false;
*/
private static function pollHcard($hcard_url, $data, $dfrn = false)
{
- $ret = Network::curl($hcard_url);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($hcard_url);
+ if ($curlResult->isTimeout()) {
return false;
}
- $content = $ret['body'];
+ $content = $curlResult->getBody();
if (!$content) {
return false;
}
$pubkey = substr($pubkey, 5);
}
} elseif (normalise_link($pubkey) == 'http://') {
- $ret = Network::curl($pubkey);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($pubkey);
+ if ($curlResult->isTimeout()) {
return false;
}
- $pubkey = $ret['body'];
+ $pubkey = $curlResult['body'];
}
$key = explode(".", $pubkey);
}
// Fetch all additional data from the feed
- $ret = Network::curl($data["poll"]);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($data["poll"]);
+ if ($curlResult->isTimeout()) {
return false;
}
- $feed = $ret['body'];
+ $feed = $curlResult->getBody();
$dummy1 = null;
$dummy2 = null;
$dummy2 = null;
*/
private static function feed($url, $probe = true)
{
- $ret = Network::curl($url);
- if (!empty($ret["errno"]) && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
+ $curlResult = Network::curl($url);
+ if ($curlResult->isTimeout()) {
return false;
}
- $feed = $ret['body'];
+ $feed = $curlResult->getBody();
$dummy1 = $dummy2 = $dummy3 = null;
$feed_data = Feed::import($feed, $dummy1, $dummy2, $dummy3, true);