Move z_fetch_url

move z_fetch_url method
This commit is contained in:
Adam Magness 2018-01-26 23:18:38 -05:00
parent c67452f72e
commit 2f9642392d
14 changed files with 58 additions and 60 deletions

View file

@ -11,6 +11,7 @@ use Friendica\Core\L10n;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Util\Network;
require_once "mod/proxy.php"; require_once "mod/proxy.php";
@ -733,7 +734,7 @@ function navbar_complete(App $a) {
if (! $localsearch) { if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = z_fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search)); $x = Network::zFetchURL(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
if ($x['success']) { if ($x['success']) {
$j = json_decode($x['body'],true); $j = json_decode($x['body'],true);
if ($j && isset($j['results'])) { if ($j && isset($j['results'])) {

View file

@ -12,16 +12,6 @@ use Friendica\Object\Image;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function fetch_url($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
{
return Network::fetchURL($url, $binary, $redirects, $timeout, $accept_content, $cookiejar);
}
function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = [])
{
return Network::zFetchURL($url, $binary, $redirects, $opts);
}
function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0) function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
{ {
return Network::postURL($url, $params, $headers, $redirects, $timeout); return Network::postURL($url, $params, $headers, $redirects, $timeout);

View file

@ -8,6 +8,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Network;
function ostatus_subscribe_content(App $a) { function ostatus_subscribe_content(App $a) {
@ -40,7 +41,7 @@ function ostatus_subscribe_content(App $a) {
$api = $contact["baseurl"]."/api/"; $api = $contact["baseurl"]."/api/";
// Fetching friends // Fetching friends
$data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]); $data = Network::zFetchURL($api."statuses/friends.json?screen_name=".$contact["nick"]);
if (!$data["success"]) { if (!$data["success"]) {
return $o.L10n::t("Couldn't fetch friends for contact."); return $o.L10n::t("Couldn't fetch friends for contact.");

View file

@ -12,6 +12,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
require_once("include/items.php"); require_once("include/items.php");
@ -60,7 +61,7 @@ function parse_url_content(App $a) {
// the URL with the corresponding BBCode media tag // the URL with the corresponding BBCode media tag
$redirects = 0; $redirects = 0;
// Fetch the header of the URL // Fetch the header of the URL
$result = z_fetch_url($url, false, $redirects, ["novalidate" => true, "nobody" => true]); $result = Network::zFetchURL($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
if($result["success"]) { if($result["success"]) {
// Convert the header fields into an array // Convert the header fields into an array
$hdrs = []; $hdrs = [];

View file

@ -981,7 +981,7 @@ class GContact
$url = $server."/main/statistics"; $url = $server."/main/statistics";
$result = z_fetch_url($url); $result = Network::zFetchURL($url);
if (!$result["success"]) { if (!$result["success"]) {
return false; return false;
} }

View file

@ -18,6 +18,7 @@ use Friendica\Model\Profile;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Protocol\Feed; use Friendica\Protocol\Feed;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
@ -107,7 +108,7 @@ class Probe
logger("Probing for ".$host, LOGGER_DEBUG); logger("Probing for ".$host, LOGGER_DEBUG);
$ret = z_fetch_url($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); $ret = Network::zFetchURL($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
if ($ret['success']) { if ($ret['success']) {
$xml = $ret['body']; $xml = $ret['body'];
$xrd = parse_xml_string($xml, false); $xrd = parse_xml_string($xml, false);
@ -115,7 +116,7 @@ class Probe
} }
if (!is_object($xrd)) { if (!is_object($xrd)) {
$ret = z_fetch_url($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); $ret = Network::zFetchURL($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
logger("Probing timeout for ".$url, LOGGER_DEBUG); logger("Probing timeout for ".$url, LOGGER_DEBUG);
return false; return false;
@ -692,7 +693,7 @@ class Probe
$xrd_timeout = Config::get('system', 'xrd_timeout', 20); $xrd_timeout = Config::get('system', 'xrd_timeout', 20);
$redirects = 0; $redirects = 0;
$ret = z_fetch_url($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]); $ret = Network::zFetchURL($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }
@ -759,7 +760,7 @@ class Probe
*/ */
private static function pollNoscrape($noscrape_url, $data) private static function pollNoscrape($noscrape_url, $data)
{ {
$ret = z_fetch_url($noscrape_url); $ret = Network::zFetchURL($noscrape_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }
@ -993,7 +994,7 @@ class Probe
*/ */
private static function pollHcard($hcard_url, $data, $dfrn = false) private static function pollHcard($hcard_url, $data, $dfrn = false)
{ {
$ret = z_fetch_url($hcard_url); $ret = Network::zFetchURL($hcard_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }
@ -1232,7 +1233,7 @@ class Probe
$pubkey = substr($pubkey, 5); $pubkey = substr($pubkey, 5);
} }
} elseif (normalise_link($pubkey) == 'http://') { } elseif (normalise_link($pubkey) == 'http://') {
$ret = z_fetch_url($pubkey); $ret = Network::zFetchURL($pubkey);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }
@ -1264,7 +1265,7 @@ class Probe
} }
// Fetch all additional data from the feed // Fetch all additional data from the feed
$ret = z_fetch_url($data["poll"]); $ret = Network::zFetchURL($data["poll"]);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }
@ -1448,7 +1449,7 @@ class Probe
*/ */
private static function feed($url, $probe = true) private static function feed($url, $probe = true)
{ {
$ret = z_fetch_url($url); $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false; return false;
} }

View file

@ -25,6 +25,7 @@ use Friendica\Model\User;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
@ -1186,7 +1187,7 @@ class DFRN
logger('dfrn_deliver: ' . $url); logger('dfrn_deliver: ' . $url);
$ret = z_fetch_url($url); $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return -2; // timed out return -2; // timed out

View file

@ -17,6 +17,7 @@ use Friendica\Model\Conversation;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Lock; use Friendica\Util\Lock;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
use DOMDocument; use DOMDocument;
@ -725,7 +726,7 @@ class OStatus
self::$conv_list[$conversation] = true; self::$conv_list[$conversation] = true;
$conversation_data = z_fetch_url($conversation, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']); $conversation_data = Network::zFetchURL($conversation, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
if (!$conversation_data['success']) { if (!$conversation_data['success']) {
return; return;
@ -753,7 +754,7 @@ class OStatus
} }
} }
if ($file != '') { if ($file != '') {
$conversation_atom = z_fetch_url($attribute['href']); $conversation_atom = Network::zFetchURL($attribute['href']);
if ($conversation_atom['success']) { if ($conversation_atom['success']) {
$xml = $conversation_atom['body']; $xml = $conversation_atom['body'];
@ -869,7 +870,7 @@ class OStatus
return; return;
} }
$self_data = z_fetch_url($self); $self_data = Network::zFetchURL($self);
if (!$self_data['success']) { if (!$self_data['success']) {
return; return;
@ -914,7 +915,7 @@ class OStatus
} }
$stored = false; $stored = false;
$related_data = z_fetch_url($related, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']); $related_data = Network::zFetchURL($related, false, $redirects, ['accept_content' => 'application/atom+xml, text/html']);
if (!$related_data['success']) { if (!$related_data['success']) {
return; return;
@ -945,7 +946,7 @@ class OStatus
} }
} }
if ($atom_file != '') { if ($atom_file != '') {
$related_atom = z_fetch_url($atom_file); $related_atom = Network::zFetchURL($atom_file);
if ($related_atom['success']) { if ($related_atom['success']) {
logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG); logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG);
@ -957,7 +958,7 @@ class OStatus
// Workaround for older GNU Social servers // Workaround for older GNU Social servers
if (($xml == '') && strstr($related, '/notice/')) { if (($xml == '') && strstr($related, '/notice/')) {
$related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related).'.atom'); $related_atom = Network::zFetchURL(str_replace('/notice/', '/api/statuses/show/', $related).'.atom');
if ($related_atom['success']) { if ($related_atom['success']) {
logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG); logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
@ -968,7 +969,7 @@ class OStatus
// Even more worse workaround for GNU Social ;-) // Even more worse workaround for GNU Social ;-)
if ($xml == '') { if ($xml == '') {
$related_guess = OStatus::convertHref($related_uri); $related_guess = OStatus::convertHref($related_uri);
$related_atom = z_fetch_url(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom'); $related_atom = Network::zFetchURL(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
if ($related_atom['success']) { if ($related_atom['success']) {
logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG); logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG);

View file

@ -288,7 +288,7 @@ class PortableContact
} }
// Fetch the host-meta to check if this really is a server // Fetch the host-meta to check if this really is a server
$serverret = z_fetch_url($server_url."/.well-known/host-meta"); $serverret = Network::zFetchURL($server_url."/.well-known/host-meta");
if (!$serverret["success"]) { if (!$serverret["success"]) {
return ""; return "";
} }
@ -367,7 +367,7 @@ class PortableContact
$server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", dbesc(normalise_link($server_url))); $server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", dbesc(normalise_link($server_url)));
if ($server) { if ($server) {
$noscraperet = z_fetch_url($server[0]["noscrape"]."/".$gcontacts[0]["nick"]); $noscraperet = Network::zFetchURL($server[0]["noscrape"]."/".$gcontacts[0]["nick"]);
if ($noscraperet["success"] && ($noscraperet["body"] != "")) { if ($noscraperet["success"] && ($noscraperet["body"] != "")) {
$noscrape = json_decode($noscraperet["body"], true); $noscrape = json_decode($noscraperet["body"], true);
@ -481,7 +481,7 @@ class PortableContact
GContact::update($contact); GContact::update($contact);
$feedret = z_fetch_url($data["poll"]); $feedret = Network::zFetchURL($data["poll"]);
if (!$feedret["success"]) { if (!$feedret["success"]) {
$fields = ['last_failure' => datetime_convert()]; $fields = ['last_failure' => datetime_convert()];
@ -632,7 +632,7 @@ class PortableContact
*/ */
private static function fetchNodeinfo($server_url) private static function fetchNodeinfo($server_url)
{ {
$serverret = z_fetch_url($server_url."/.well-known/nodeinfo"); $serverret = Network::zFetchURL($server_url."/.well-known/nodeinfo");
if (!$serverret["success"]) { if (!$serverret["success"]) {
return false; return false;
} }
@ -664,7 +664,7 @@ class PortableContact
return false; return false;
} }
$serverret = z_fetch_url($nodeinfo_url); $serverret = Network::zFetchURL($nodeinfo_url);
if (!$serverret["success"]) { if (!$serverret["success"]) {
return false; return false;
} }
@ -873,7 +873,7 @@ class PortableContact
$server_url = str_replace("http://", "https://", $server_url); $server_url = str_replace("http://", "https://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]); $serverret = Network::zFetchURL($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
// Quit if there is a timeout. // Quit if there is a timeout.
// But we want to make sure to only quit if we are mostly sure that this server url fits. // But we want to make sure to only quit if we are mostly sure that this server url fits.
@ -890,7 +890,7 @@ class PortableContact
$server_url = str_replace("https://", "http://", $server_url); $server_url = str_replace("https://", "http://", $server_url);
// We set the timeout to 20 seconds since this operation should be done in no time if the server was vital // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
$serverret = z_fetch_url($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]); $serverret = Network::zFetchURL($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
// Quit if there is a timeout // Quit if there is a timeout
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
@ -926,7 +926,7 @@ class PortableContact
// Look for poco // Look for poco
if (!$failure) { if (!$failure) {
$serverret = z_fetch_url($server_url."/poco"); $serverret = Network::zFetchURL($server_url."/poco");
if ($serverret["success"]) { if ($serverret["success"]) {
$data = json_decode($serverret["body"]); $data = json_decode($serverret["body"]);
if (isset($data->totalResults)) { if (isset($data->totalResults)) {
@ -952,7 +952,7 @@ class PortableContact
if (!$failure) { if (!$failure) {
// Test for Diaspora, Hubzilla, Mastodon or older Friendica servers // Test for Diaspora, Hubzilla, Mastodon or older Friendica servers
$serverret = z_fetch_url($server_url); $serverret = Network::zFetchURL($server_url);
if (!$serverret["success"] || ($serverret["body"] == "")) { if (!$serverret["success"] || ($serverret["body"] == "")) {
$failure = true; $failure = true;
@ -991,7 +991,7 @@ class PortableContact
// Test for Statusnet // Test for Statusnet
// Will also return data for Friendica and GNU Social - but it will be overwritten later // Will also return data for Friendica and GNU Social - but it will be overwritten later
// The "not implemented" is a special treatment for really, really old Friendica versions // The "not implemented" is a special treatment for really, really old Friendica versions
$serverret = z_fetch_url($server_url."/api/statusnet/version.json"); $serverret = Network::zFetchURL($server_url."/api/statusnet/version.json");
if ($serverret["success"] && ($serverret["body"] != '{"error":"not implemented"}') && if ($serverret["success"] && ($serverret["body"] != '{"error":"not implemented"}') &&
($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) { ($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) {
$platform = "StatusNet"; $platform = "StatusNet";
@ -1002,7 +1002,7 @@ class PortableContact
} }
// Test for GNU Social // Test for GNU Social
$serverret = z_fetch_url($server_url."/api/gnusocial/version.json"); $serverret = Network::zFetchURL($server_url."/api/gnusocial/version.json");
if ($serverret["success"] && ($serverret["body"] != '{"error":"not implemented"}') && if ($serverret["success"] && ($serverret["body"] != '{"error":"not implemented"}') &&
($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) { ($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) {
$platform = "GNU Social"; $platform = "GNU Social";
@ -1014,7 +1014,7 @@ class PortableContact
// Test for Mastodon // Test for Mastodon
$orig_version = $version; $orig_version = $version;
$serverret = z_fetch_url($server_url."/api/v1/instance"); $serverret = Network::zFetchURL($server_url."/api/v1/instance");
if ($serverret["success"] && ($serverret["body"] != '')) { if ($serverret["success"] && ($serverret["body"] != '')) {
$data = json_decode($serverret["body"]); $data = json_decode($serverret["body"]);
@ -1037,7 +1037,7 @@ class PortableContact
if (!$failure) { if (!$failure) {
// Test for Hubzilla and Red // Test for Hubzilla and Red
$serverret = z_fetch_url($server_url."/siteinfo.json"); $serverret = Network::zFetchURL($server_url."/siteinfo.json");
if ($serverret["success"]) { if ($serverret["success"]) {
$data = json_decode($serverret["body"]); $data = json_decode($serverret["body"]);
if (isset($data->url)) { if (isset($data->url)) {
@ -1065,7 +1065,7 @@ class PortableContact
} }
} else { } else {
// Test for Hubzilla, Redmatrix or Friendica // Test for Hubzilla, Redmatrix or Friendica
$serverret = z_fetch_url($server_url."/api/statusnet/config.json"); $serverret = Network::zFetchURL($server_url."/api/statusnet/config.json");
if ($serverret["success"]) { if ($serverret["success"]) {
$data = json_decode($serverret["body"]); $data = json_decode($serverret["body"]);
if (isset($data->site->server)) { if (isset($data->site->server)) {
@ -1120,7 +1120,7 @@ class PortableContact
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix // Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
if (!$failure) { if (!$failure) {
$serverret = z_fetch_url($server_url."/statistics.json"); $serverret = Network::zFetchURL($server_url."/statistics.json");
if ($serverret["success"]) { if ($serverret["success"]) {
$data = json_decode($serverret["body"]); $data = json_decode($serverret["body"]);
@ -1182,10 +1182,10 @@ class PortableContact
// Check for noscrape // Check for noscrape
// Friendica servers could be detected as OStatus servers // Friendica servers could be detected as OStatus servers
if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) { if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) {
$serverret = z_fetch_url($server_url."/friendica/json"); $serverret = Network::zFetchURL($server_url."/friendica/json");
if (!$serverret["success"]) { if (!$serverret["success"]) {
$serverret = z_fetch_url($server_url."/friendika/json"); $serverret = Network::zFetchURL($server_url."/friendika/json");
} }
if ($serverret["success"]) { if ($serverret["success"]) {
@ -1295,7 +1295,7 @@ class PortableContact
*/ */
private static function fetchServerlist($poco) private static function fetchServerlist($poco)
{ {
$serverret = z_fetch_url($poco."/@server"); $serverret = Network::zFetchURL($poco."/@server");
if (!$serverret["success"]) { if (!$serverret["success"]) {
return; return;
} }
@ -1344,7 +1344,7 @@ class PortableContact
if (!empty($accesstoken)) { if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0'; $api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = ['Authorization: Bearer '.$accesstoken]; $header = ['Authorization: Bearer '.$accesstoken];
$serverdata = z_fetch_url($api, false, $redirects, ['headers' => $header]); $serverdata = Network::zFetchURL($api, false, $redirects, ['headers' => $header]);
if ($serverdata['success']) { if ($serverdata['success']) {
$servers = json_decode($serverdata['body']); $servers = json_decode($serverdata['body']);
foreach ($servers->instances as $server) { foreach ($servers->instances as $server) {
@ -1361,7 +1361,7 @@ class PortableContact
//if (!Config::get('system','ostatus_disabled')) { //if (!Config::get('system','ostatus_disabled')) {
// $serverdata = "http://gstools.org/api/get_open_instances/"; // $serverdata = "http://gstools.org/api/get_open_instances/";
// $result = z_fetch_url($serverdata); // $result = Network::zFetchURL($serverdata);
// if ($result["success"]) { // if ($result["success"]) {
// $servers = json_decode($result["body"]); // $servers = json_decode($result["body"]);
@ -1390,7 +1390,7 @@ class PortableContact
logger("Fetch all users from the server ".$server["url"], LOGGER_DEBUG); logger("Fetch all users from the server ".$server["url"], LOGGER_DEBUG);
$retdata = z_fetch_url($url); $retdata = Network::zFetchURL($url);
if ($retdata["success"]) { if ($retdata["success"]) {
$data = json_decode($retdata["body"]); $data = json_decode($retdata["body"]);
@ -1409,7 +1409,7 @@ class PortableContact
$success = false; $success = false;
$retdata = z_fetch_url($url); $retdata = Network::zFetchURL($url);
if ($retdata["success"]) { if ($retdata["success"]) {
logger("Fetch all global contacts from the server ".$server["nurl"], LOGGER_DEBUG); logger("Fetch all global contacts from the server ".$server["nurl"], LOGGER_DEBUG);
$success = self::discoverServer(json_decode($retdata["body"])); $success = self::discoverServer(json_decode($retdata["body"]));
@ -1494,7 +1494,7 @@ class PortableContact
// Fetch all contacts from a given user from the other server // Fetch all contacts from a given user from the other server
$url = $server["poco"]."/".$username."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; $url = $server["poco"]."/".$username."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
$retdata = z_fetch_url($url); $retdata = Network::zFetchURL($url);
if ($retdata["success"]) { if ($retdata["success"]) {
self::discoverServer(json_decode($retdata["body"]), 3); self::discoverServer(json_decode($retdata["body"]), 3);
} }

View file

@ -38,9 +38,9 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Network;
use dba; use dba;
require_once 'include/dba.php';
require_once 'include/dba.php'; require_once 'include/dba.php';
class ExAuth class ExAuth
@ -181,7 +181,7 @@ class ExAuth
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user; $url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
$data = z_fetch_url($url); $data = Network::zFetchURL($url);
if (!is_array($data)) { if (!is_array($data)) {
return false; return false;

View file

@ -233,7 +233,7 @@ class Network
if (filter_var($newurl, FILTER_VALIDATE_URL)) { if (filter_var($newurl, FILTER_VALIDATE_URL)) {
$redirects++; $redirects++;
@curl_close($ch); @curl_close($ch);
return z_fetch_url($newurl, $binary, $redirects, $opts); return self::zFetchURL($newurl, $binary, $redirects, $opts);
} }
} }

View file

@ -8,6 +8,7 @@ namespace Friendica\Util;
use Friendica\Content\OEmbed; use Friendica\Content\OEmbed;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
@ -145,7 +146,7 @@ class ParseUrl
$siteinfo["url"] = $url; $siteinfo["url"] = $url;
$siteinfo["type"] = "link"; $siteinfo["type"] = "link";
$data = z_fetch_url($url); $data = Network::zFetchURL($url);
if (!$data['success']) { if (!$data['success']) {
return($siteinfo); return($siteinfo);
} }

View file

@ -281,7 +281,7 @@ class DiscoverPoCo {
$url = "http://gstools.org/api/users_search/".urlencode($search); $url = "http://gstools.org/api/users_search/".urlencode($search);
$result = z_fetch_url($url); $result = Network::zFetchURL($url);
if (!$result["success"]) { if (!$result["success"]) {
return false; return false;
} }

View file

@ -10,6 +10,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\Network;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -176,7 +177,7 @@ class OnePoll
. '&type=data&last_update=' . $last_update . '&type=data&last_update=' . $last_update
. '&perm=' . $perm ; . '&perm=' . $perm ;
$ret = z_fetch_url($url); $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
@ -311,7 +312,7 @@ class OnePoll
} }
$cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-'); $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
$ret = z_fetch_url($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]); $ret = Network::zFetchURL($contact['poll'], false, $redirects, ['cookiejar' => $cookiejar]);
unlink($cookiejar); unlink($cookiejar);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {