X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FProbe.php;h=1b6feb107f4d32cf260da732dac770b64247790d;hb=6fdc219143b83c357a65179529752553a71b44f6;hp=5c2ba86ccde08e0ec1a56926bc97f139859d9c99;hpb=e54ee2e5091eafe7fa22baa213a798f9e6f58b01;p=friendica.git diff --git a/include/Probe.php b/include/Probe.php index 5c2ba86ccd..1b6feb107f 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -60,11 +60,20 @@ class Probe { $xrd_timeout = Config::get('system','xrd_timeout', 20); $redirects = 0; - $xml = fetch_url($ssl_url, false, $redirects, $xrd_timeout, "application/xrd+xml"); + $ret = z_fetch_url($ssl_url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml')); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $xml = $ret['body']; + $xrd = parse_xml_string($xml, false); if (!is_object($xrd)) { - $xml = fetch_url($url, false, $redirects, $xrd_timeout, "application/xrd+xml"); + $ret = z_fetch_url($url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml')); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $xml = $ret['body']; $xrd = parse_xml_string($xml, false); } if (!is_object($xrd)) @@ -324,7 +333,7 @@ class Probe { !isset($parts["path"])) return false; - // todo: Ports? + /// @todo: Ports? $host = $parts["host"]; if ($host == 'twitter.com') @@ -430,7 +439,12 @@ class Probe { $xrd_timeout = Config::get('system','xrd_timeout', 20); $redirects = 0; - $data = fetch_url($url, false, $redirects, $xrd_timeout, "application/xrd+xml"); + $ret = z_fetch_url($url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml')); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $data = $ret['body']; + $xrd = parse_xml_string($data, false); if (!is_object($xrd)) { @@ -482,9 +496,14 @@ class Probe { * @return array noscrape data */ private function poll_noscrape($noscrape, $data) { - $content = fetch_url($noscrape); - if (!$content) + $ret = z_fetch_url($noscrape); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $content = $ret['body']; + if (!$content) { return false; + } $json = json_decode($content, true); if (!is_array($json)) @@ -663,10 +682,14 @@ class Probe { * @return array hcard data */ private function poll_hcard($hcard, $data, $dfrn = false) { - - $content = fetch_url($hcard); - if (!$content) + $ret = z_fetch_url($hcard); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { return false; + } + $content = $ret['body']; + if (!$content) { + return false; + } $doc = new DOMDocument(); if (!@$doc->loadHTML($content)) @@ -715,11 +738,19 @@ class Probe { $photos = $xpath->query("//*[contains(concat(' ', @class, ' '), ' photo ') or contains(concat(' ', @class, ' '), ' avatar ')]", $vcard); // */ foreach ($photos AS $photo) { $attr = array(); - foreach ($photo->attributes as $attribute) + foreach ($photo->attributes as $attribute) { $attr[$attribute->name] = trim($attribute->value); + } - if (isset($attr["src"]) AND isset($attr["width"])) + if (isset($attr["src"]) AND isset($attr["width"])) { $avatar[$attr["width"]] = $attr["src"]; + } + + // We don't have a width. So we just take everything that we got. + // This is a Hubzilla workaround which doesn't send a width. + if ((sizeof($avatar) == 0) AND isset($attr["src"])) { + $avatar[] = $attr["src"]; + } } if (sizeof($avatar)) { @@ -851,8 +882,13 @@ class Probe { $pubkey = substr($pubkey, strpos($pubkey, ',') + 1); else $pubkey = substr($pubkey, 5); - } elseif (normalise_link($pubkey) == 'http://') - $pubkey = fetch_url($pubkey); + } elseif (normalise_link($pubkey) == 'http://') { + $ret = z_fetch_url($pubkey); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $pubkey = $ret['body']; + } $key = explode(".", $pubkey); @@ -872,7 +908,11 @@ class Probe { return false; // Fetch all additional data from the feed - $feed = fetch_url($data["poll"]); + $ret = z_fetch_url($data["poll"]); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $feed = $ret['body']; $feed_data = feed_import($feed,$dummy1,$dummy2, $dummy3, true); if (!$feed_data) return false; @@ -1027,7 +1067,11 @@ class Probe { * @return array feed data */ private function feed($url, $probe = true) { - $feed = fetch_url($url); + $ret = z_fetch_url($url); + if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { + return false; + } + $feed = $ret['body']; $feed_data = feed_import($feed, $dummy1, $dummy2, $dummy3, true); if (!$feed_data) {