X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FProbe.php;h=2c42643b44a07fae9389c4ac738aa3ebac54c82c;hb=12ddb3bb5472cac5292131b9002935904e846fc2;hp=0e9219c5a615b8b095f1068b827f060f640d27c4;hpb=e45206ae5d92f99b5f6d027682001ccefd910eec;p=friendica.git diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 0e9219c5a6..2c42643b44 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -74,7 +74,7 @@ class Probe */ private static function ownHost($host) { - $own_host = get_app()->get_hostname(); + $own_host = get_app()->getHostName(); $parts = parse_url($host); @@ -112,20 +112,20 @@ class Probe 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; } @@ -335,11 +335,10 @@ class Probe $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"])) { @@ -743,11 +742,11 @@ class Probe $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)) { @@ -810,11 +809,11 @@ class Probe */ 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; @@ -1055,11 +1054,11 @@ class Probe */ 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; } @@ -1302,11 +1301,11 @@ class Probe $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); @@ -1334,11 +1333,11 @@ class Probe } // 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; @@ -1544,11 +1543,11 @@ class Probe */ 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);