use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
+use Friendica\Util\Network;
require_once "mod/proxy.php";
if (! $localsearch) {
$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']) {
$j = json_decode($x['body'],true);
if ($j && isset($j['results'])) {
use Friendica\Util\Network;
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)
{
return Network::postURL($url, $params, $headers, $redirects, $timeout);
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
+use Friendica\Util\Network;
function ostatus_subscribe_content(App $a) {
$api = $contact["baseurl"]."/api/";
// 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"]) {
return $o.L10n::t("Couldn't fetch friends for contact.");
use Friendica\App;
use Friendica\Core\Addon;
+use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
require_once("include/items.php");
// the URL with the corresponding BBCode media tag
$redirects = 0;
// 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"]) {
// Convert the header fields into an array
$hdrs = [];
$url = $server."/main/statistics";
- $result = z_fetch_url($url);
+ $result = Network::zFetchURL($url);
if (!$result["success"]) {
return false;
}
use Friendica\Protocol\Email;
use Friendica\Protocol\Feed;
use Friendica\Util\Crypto;
+use Friendica\Util\Network;
use Friendica\Util\XML;
use dba;
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']) {
$xml = $ret['body'];
$xrd = parse_xml_string($xml, false);
}
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) {
logger("Probing timeout for ".$url, LOGGER_DEBUG);
return false;
$xrd_timeout = Config::get('system', 'xrd_timeout', 20);
$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) {
return false;
}
*/
private static function pollNoscrape($noscrape_url, $data)
{
- $ret = z_fetch_url($noscrape_url);
+ $ret = Network::zFetchURL($noscrape_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return 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) {
return false;
}
$pubkey = substr($pubkey, 5);
}
} elseif (normalise_link($pubkey) == 'http://') {
- $ret = z_fetch_url($pubkey);
+ $ret = Network::zFetchURL($pubkey);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
}
// Fetch all additional data from the feed
- $ret = z_fetch_url($data["poll"]);
+ $ret = Network::zFetchURL($data["poll"]);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
*/
private static function feed($url, $probe = true)
{
- $ret = z_fetch_url($url);
+ $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
use Friendica\Object\Image;
use Friendica\Protocol\OStatus;
use Friendica\Util\Crypto;
+use Friendica\Util\Network;
use Friendica\Util\XML;
use dba;
logger('dfrn_deliver: ' . $url);
- $ret = z_fetch_url($url);
+ $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return -2; // timed out
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Util\Lock;
+use Friendica\Util\Network;
use Friendica\Util\XML;
use dba;
use DOMDocument;
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']) {
return;
}
}
if ($file != '') {
- $conversation_atom = z_fetch_url($attribute['href']);
+ $conversation_atom = Network::zFetchURL($attribute['href']);
if ($conversation_atom['success']) {
$xml = $conversation_atom['body'];
return;
}
- $self_data = z_fetch_url($self);
+ $self_data = Network::zFetchURL($self);
if (!$self_data['success']) {
return;
}
$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']) {
return;
}
}
if ($atom_file != '') {
- $related_atom = z_fetch_url($atom_file);
+ $related_atom = Network::zFetchURL($atom_file);
if ($related_atom['success']) {
logger('Fetched XML for URI '.$related_uri, LOGGER_DEBUG);
// Workaround for older GNU Social servers
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']) {
logger('GNU Social workaround to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
// Even more worse workaround for GNU Social ;-)
if ($xml == '') {
$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']) {
logger('GNU Social workaround 2 to fetch XML for URI '.$related_uri, LOGGER_DEBUG);
}
// 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"]) {
return "";
}
$server = q("SELECT `noscrape`, `network` FROM `gserver` WHERE `nurl` = '%s' AND `noscrape` != ''", dbesc(normalise_link($server_url)));
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"] != "")) {
$noscrape = json_decode($noscraperet["body"], true);
GContact::update($contact);
- $feedret = z_fetch_url($data["poll"]);
+ $feedret = Network::zFetchURL($data["poll"]);
if (!$feedret["success"]) {
$fields = ['last_failure' => datetime_convert()];
*/
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"]) {
return false;
}
return false;
}
- $serverret = z_fetch_url($nodeinfo_url);
+ $serverret = Network::zFetchURL($nodeinfo_url);
if (!$serverret["success"]) {
return false;
}
$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
- $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.
// But we want to make sure to only quit if we are mostly sure that this server url fits.
$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
- $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
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
// Look for poco
if (!$failure) {
- $serverret = z_fetch_url($server_url."/poco");
+ $serverret = Network::zFetchURL($server_url."/poco");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);
if (isset($data->totalResults)) {
if (!$failure) {
// 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"] == "")) {
$failure = true;
// Test for Statusnet
// 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
- $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"}') &&
($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) {
$platform = "StatusNet";
}
// 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"}') &&
($serverret["body"] != '') && (strlen($serverret["body"]) < 30)) {
$platform = "GNU Social";
// Test for Mastodon
$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"] != '')) {
$data = json_decode($serverret["body"]);
if (!$failure) {
// Test for Hubzilla and Red
- $serverret = z_fetch_url($server_url."/siteinfo.json");
+ $serverret = Network::zFetchURL($server_url."/siteinfo.json");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);
if (isset($data->url)) {
}
} else {
// 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"]) {
$data = json_decode($serverret["body"]);
if (isset($data->site->server)) {
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
if (!$failure) {
- $serverret = z_fetch_url($server_url."/statistics.json");
+ $serverret = Network::zFetchURL($server_url."/statistics.json");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);
// Check for noscrape
// Friendica servers could be detected as OStatus servers
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"]) {
- $serverret = z_fetch_url($server_url."/friendika/json");
+ $serverret = Network::zFetchURL($server_url."/friendika/json");
}
if ($serverret["success"]) {
*/
private static function fetchServerlist($poco)
{
- $serverret = z_fetch_url($poco."/@server");
+ $serverret = Network::zFetchURL($poco."/@server");
if (!$serverret["success"]) {
return;
}
if (!empty($accesstoken)) {
$api = 'https://instances.social/api/1.0/instances/list?count=0';
$header = ['Authorization: Bearer '.$accesstoken];
- $serverdata = z_fetch_url($api, false, $redirects, ['headers' => $header]);
+ $serverdata = Network::zFetchURL($api, false, $redirects, ['headers' => $header]);
if ($serverdata['success']) {
$servers = json_decode($serverdata['body']);
foreach ($servers->instances as $server) {
//if (!Config::get('system','ostatus_disabled')) {
// $serverdata = "http://gstools.org/api/get_open_instances/";
- // $result = z_fetch_url($serverdata);
+ // $result = Network::zFetchURL($serverdata);
// if ($result["success"]) {
// $servers = json_decode($result["body"]);
logger("Fetch all users from the server ".$server["url"], LOGGER_DEBUG);
- $retdata = z_fetch_url($url);
+ $retdata = Network::zFetchURL($url);
if ($retdata["success"]) {
$data = json_decode($retdata["body"]);
$success = false;
- $retdata = z_fetch_url($url);
+ $retdata = Network::zFetchURL($url);
if ($retdata["success"]) {
logger("Fetch all global contacts from the server ".$server["nurl"], LOGGER_DEBUG);
$success = self::discoverServer(json_decode($retdata["body"]));
// 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";
- $retdata = z_fetch_url($url);
+ $retdata = Network::zFetchURL($url);
if ($retdata["success"]) {
self::discoverServer(json_decode($retdata["body"]), 3);
}
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\User;
+use Friendica\Util\Network;
use dba;
-require_once 'include/dba.php';
require_once 'include/dba.php';
class ExAuth
$url = ($ssl ? 'https' : 'http') . '://' . $host . '/noscrape/' . $user;
- $data = z_fetch_url($url);
+ $data = Network::zFetchURL($url);
if (!is_array($data)) {
return false;
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
$redirects++;
@curl_close($ch);
- return z_fetch_url($newurl, $binary, $redirects, $opts);
+ return self::zFetchURL($newurl, $binary, $redirects, $opts);
}
}
use Friendica\Content\OEmbed;
use Friendica\Core\Addon;
use Friendica\Object\Image;
+use Friendica\Util\Network;
use Friendica\Util\XML;
use dba;
$siteinfo["url"] = $url;
$siteinfo["type"] = "link";
- $data = z_fetch_url($url);
+ $data = Network::zFetchURL($url);
if (!$data['success']) {
return($siteinfo);
}
$url = "http://gstools.org/api/users_search/".urlencode($search);
- $result = z_fetch_url($url);
+ $result = Network::zFetchURL($url);
if (!$result["success"]) {
return false;
}
use Friendica\Model\Contact;
use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact;
+use Friendica\Util\Network;
use dba;
require_once 'include/dba.php';
. '&type=data&last_update=' . $last_update
. '&perm=' . $perm ;
- $ret = z_fetch_url($url);
+ $ret = Network::zFetchURL($url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
// set the last-update so we don't keep polling
}
$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);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {