Move fetch_url

move fetch_url function
This commit is contained in:
Adam Magness 2018-01-26 23:09:48 -05:00
parent 1b51777825
commit c67452f72e
25 changed files with 55 additions and 35 deletions

View file

@ -35,6 +35,7 @@ use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Network;
use Friendica\Util\XML;
require_once 'include/bbcode.php';
@ -5073,7 +5074,7 @@ function api_get_nick($profile)
if ($StatusnetHost != $profile) {
$StatusnetUser = preg_replace("=https?://(.*)/user/(.*)=ism", "$2", $profile);
if ($StatusnetUser != $profile) {
$UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
$UserData = Network::fetchURL("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
$user = json_decode($UserData);
if ($user) {
$nick = $user->screen_name;

View file

@ -13,6 +13,7 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Model\Contact;
use Friendica\Util\Map;
use Friendica\Util\Network;
require_once 'include/event.php';
require_once 'mod/proxy.php';
@ -688,7 +689,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
$StatusnetUser = preg_replace("=https?://(.*)/user/(.*)=ism", "$2", $profile);
if ($StatusnetUser != $profile) {
/// @TODO Some hosts run on https, not just http and sometimes http is disabled, let's support both here
$UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
$UserData = Network::fetchURL("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
$user = json_decode($UserData);
if ($user) {
if ($getnetwork) {
@ -749,7 +750,7 @@ function bb_RemovePictureLinks($match) {
// if its not a picture then look if its a page that contains a picture link
require_once("include/network.php");
$body = fetch_url($match[1]);
$body = Network::fetchURL($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);
@ -806,7 +807,7 @@ function bb_CleanPictureLinksSub($match) {
// if its not a picture then look if its a page that contains a picture link
require_once("include/network.php");
$body = fetch_url($match[1]);
$body = Network::fetchURL($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);

View file

@ -57,7 +57,7 @@ function blocked_url($url)
return Network::blockedURL($url);
}
function allowedEmail($email)
function allowed_email($email)
{
return Network::allowedEmail($email);
}

View file

@ -11,6 +11,7 @@ use Friendica\Database\DBM;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Util\Network;
require_once 'include/items.php';
@ -98,7 +99,7 @@ function dfrn_poll_init(App $a)
);
if (DBM::is_result($r)) {
$s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
$s = Network::fetchURL($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
@ -481,7 +482,7 @@ function dfrn_poll_content(App $a)
if (($type === 'profile') && (strlen($sec))) {
// URL reply
if ($dfrn_version < 2.2) {
$s = fetch_url($r[0]['poll']
$s = Network::fetchURL($r[0]['poll']
. '?dfrn_id=' . $encrypted_id
. '&type=profile-check'
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION

View file

@ -23,6 +23,7 @@ use Friendica\Model\User;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\Network;
require_once 'include/enotify.php';
@ -182,7 +183,7 @@ function dfrn_request_post(App $a)
}
if (strlen($dfrn_request) && strlen($confirm_key)) {
$s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key);
$s = Network::fetchURL($dfrn_request . '?confirm_key=' . $confirm_key);
}
// (ignore reply, nothing we can do it failed)

View file

@ -14,6 +14,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Network;
require_once 'mod/contacts.php';
@ -177,7 +178,7 @@ function dirfind_content(App $a, $prefix = "") {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
if(strlen(Config::get('system','directory')))
$x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
$x = Network::fetchURL(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
$j = json_decode($x);
}

View file

@ -8,6 +8,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Object\Image;
use Friendica\Util\Network;
$install_wizard_pass = 1;
@ -482,10 +483,10 @@ function check_htaccess(&$checks) {
$status = true;
$help = "";
if (function_exists('curl_init')) {
$test = fetch_url(System::baseUrl()."/install/testrewrite");
$test = Network::fetchURL(System::baseUrl()."/install/testrewrite");
if ($test != "ok") {
$test = fetch_url(normalise_link(System::baseUrl()."/install/testrewrite"));
$test = Network::fetchURL(normalise_link(System::baseUrl()."/install/testrewrite"));
}
if ($test != "ok") {

View file

@ -9,6 +9,7 @@ use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Util\Network;
function nodeinfo_wellknown(App $a) {
$nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
@ -246,7 +247,7 @@ function nodeinfo_cron() {
// Now trying to register
$url = 'http://the-federation.info/register/'.$a->get_hostname();
logger('registering url: '.$url, LOGGER_DEBUG);
$ret = fetch_url($url);
$ret = Network::fetchURL($url);
logger('registering answer: '.$ret, LOGGER_DEBUG);
logger('cron_end');

View file

@ -6,6 +6,7 @@ use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Module\Login;
use Friendica\Util\Network;
function oexchange_init(App $a) {
@ -39,7 +40,7 @@ function oexchange_content(App $a) {
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
$s = fetch_url(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
$s = Network::fetchURL(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
if (! strlen($s)) {
return;

View file

@ -10,6 +10,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Network;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -161,7 +162,7 @@ function proxy_init(App $a) {
// It shouldn't happen but it does - spaces in URL
$_REQUEST['url'] = str_replace(' ', '+', $_REQUEST['url']);
$redirects = 0;
$img_str = fetch_url($_REQUEST['url'], true, $redirects, 10);
$img_str = Network::fetchURL($_REQUEST['url'], true, $redirects, 10);
$tempfile = tempnam(get_temppath(), 'cache');
file_put_contents($tempfile, $img_str);

View file

@ -3,6 +3,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Util\Network;
function post_var($name) {
return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
@ -109,7 +110,7 @@ function pubsubhubbub_init(App $a) {
// we don't actually enforce the lease time because GNU
// Social/StatusNet doesn't honour it (yet)
$body = fetch_url($hub_callback . "?" . $params);
$body = Network::fetchURL($hub_callback . "?" . $params);
$ret = $a->get_curl_code();
// give up if the HTTP return code wasn't a success (2xx)

View file

@ -93,9 +93,9 @@ text { font:12px Dialog; }
<text x="149" y="2112" style="font:13px Open Sans">- create a contact for Karen in the contact table with </text>
<text x="149" y="2135" style="font:13px Open Sans">the scraped data with blocked = 1 and pending = 1 </text>
<text x="149" y="2158" style="font:13px Open Sans">(Karens pubkey becomes the contact site-pubkey)</text>
<text x="149" y="2204" style="font:13px Open Sans">- fetch_url($dfrn_request . '?confirm_key=' . </text>
<text x="149" y="2204" style="font:13px Open Sans">- Network::fetchURL($dfrn_request . '?confirm_key=' . </text>
<text x="149" y="2227" style="font:13px Open Sans">$confirm_key);</text>
<text x="149" y="2273" style="font:13px Open Sans">- fetch_url(http://karenhomepage.com/dfrn_request?</text>
<text x="149" y="2273" style="font:13px Open Sans">- Network::fetchURL(http://karenhomepage.com/dfrn_request?</text>
<text x="149" y="2296" style="font:13px Open Sans">confirm_key=”ABC123”)</text>
<clipPath id="clip13"><path d="M1061,2027 L1238,2027 L1238,2069 L1061,2069 L1061,2027 Z" /></clipPath>
<path d="M1070,2028 C1065.5820313,2028 1062,2031.5820313 1062,2036 L1062,2059 C1062,2063.4179688 1065.5820313,2067 1070,2067 L1228,2067 C1232.4179688,2067 1236,2063.4179688 1236,2059 L1236,2036 C1236,2031.5820313 1232.4179688,2028 1228,2028 Z" style="fill:rgb(127,127,127);stroke:none" clip-path="url(#clip13)" />

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -10,6 +10,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use dba;
use DOMDocument;
@ -77,7 +78,7 @@ class OEmbed
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
$redirects = 0;
$html_text = fetch_url($embedurl, false, $redirects, 15, "text/*");
$html_text = Network::fetchURL($embedurl, false, $redirects, 15, "text/*");
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
@ -85,13 +86,13 @@ class OEmbed
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
$txt = Network::fetchURL($href . '&maxwidth=' . $a->videowidth);
break;
}
$entries = $xpath->query("//link[@type='text/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = fetch_url($href . '&maxwidth=' . $a->videowidth);
$txt = Network::fetchURL($href . '&maxwidth=' . $a->videowidth);
break;
}
}

View file

@ -10,7 +10,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Process;
use Friendica\Util\Lock;
use Friendica\Util\Network;
use dba;
require_once 'include/dba.php';
@ -888,7 +888,7 @@ class Worker
}
$url = System::baseUrl()."/worker";
fetch_url($url, false, $redirects, 1);
Network::fetchURL($url, false, $redirects, 1);
}
/**

View file

@ -13,6 +13,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Network;
use dba;
use Exception;
@ -568,7 +569,7 @@ class GContact
$done[] = System::baseUrl() . '/poco';
if (strlen(Config::get('system', 'directory'))) {
$x = fetch_url(get_server()."/pubsites");
$x = Network::fetchURL(get_server()."/pubsites");
if ($x) {
$j = json_decode($x);
if ($j->entries) {

View file

@ -12,6 +12,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Image;
use Friendica\Util\Network;
use dba;
require_once 'include/dba.php';
@ -101,7 +102,7 @@ class Photo
$photo_failure = false;
$filename = basename($image_url);
$img_str = fetch_url($image_url, true);
$img_str = Network::fetchURL($image_url, true);
if ($quit_on_error && ($img_str == "")) {
return false;

View file

@ -17,6 +17,7 @@ use Friendica\Model\Group;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use dba;
use Exception;
@ -468,7 +469,7 @@ class User
$photo_failure = false;
$filename = basename($photo);
$img_str = fetch_url($photo, true);
$img_str = Network::fetchURL($photo, true);
// guess mimetype from headers or filename
$type = Image::guessType($photo, true);

View file

@ -12,6 +12,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Util\Network;
use Exception;
use Imagick;
use ImagickPixel;
@ -773,7 +774,7 @@ class Image
$data = Cache::get($url);
if (is_null($data) || !$data || !is_array($data)) {
$img_str = fetch_url($url, true, $redirects, 4);
$img_str = Network::fetchURL($url, true, $redirects, 4);
$filesize = strlen($img_str);
if (function_exists("getimagesizefromstring")) {

View file

@ -25,8 +25,8 @@ use Friendica\Model\Queue;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML;
use dba;
use SimpleXMLElement;
@ -1257,7 +1257,7 @@ class Diaspora
logger("Fetch post from ".$source_url, LOGGER_DEBUG);
$envelope = fetch_url($source_url);
$envelope = Network::fetchURL($source_url);
if ($envelope) {
logger("Envelope was fetched.", LOGGER_DEBUG);
$x = self::verifyMagicEnvelope($envelope);
@ -1275,7 +1275,7 @@ class Diaspora
$source_url = $server."/p/".urlencode($guid).".xml";
logger("Fetch post from ".$source_url, LOGGER_DEBUG);
$x = fetch_url($source_url);
$x = Network::fetchURL($source_url);
if (!$x) {
return false;
}

View file

@ -15,6 +15,7 @@ use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Util\Network;
use dba;
use DOMDocument;
use DOMXPath;
@ -85,7 +86,7 @@ class PortableContact
logger('load: ' . $url, LOGGER_DEBUG);
$s = fetch_url($url);
$s = Network::fetchURL($url);
logger('load: returns ' . $s, LOGGER_DATA);

View file

@ -6,6 +6,7 @@ namespace Friendica\Protocol;
use Friendica\Network\Probe;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML;
/**
@ -50,7 +51,7 @@ class Salmon
$ret[$x] = substr($ret[$x], 5);
}
} elseif (normalise_link($ret[$x]) == 'http://') {
$ret[$x] = fetch_url($ret[$x]);
$ret[$x] = Network::fetchURL($ret[$x]);
}
}
}

View file

@ -714,7 +714,7 @@ class Network
} else {
$scaled = $mtch[1];
}
$i = fetch_url($scaled);
$i = self::fetchURL($scaled);
if (! $i) {
return $srctext;
}

View file

@ -8,6 +8,7 @@
namespace Friendica\Worker;
use Friendica\Core\Config;
use Friendica\Util\Network;
/**
* @brief check the git repository VERSION file and save the version to the DB
@ -37,7 +38,7 @@ class CheckVersion {
logger("Checking VERSION from: ".$checked_url, LOGGER_DEBUG);
// fetch the VERSION file
$gitversion = dbesc(trim(fetch_url($checked_url)));
$gitversion = dbesc(trim(Network::fetchURL($checked_url)));
logger("Upstream VERSION is: ".$gitversion, LOGGER_DEBUG);
Config::set('system', 'git_friendica_version', $gitversion);

View file

@ -10,6 +10,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Util\Network;
class Directory {
public static function execute($url = '') {
@ -32,7 +33,7 @@ class Directory {
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
if (strlen($arr['url'])) {
fetch_url($dir . '?url=' . bin2hex($arr['url']));
Network::fetchURL($dir . '?url=' . bin2hex($arr['url']));
}
return;

View file

@ -11,6 +11,7 @@ use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Network;
require_once 'include/datetime.php';
@ -217,7 +218,7 @@ class DiscoverPoCo {
}
}
$x = fetch_url(get_server()."/lsearch?p=1&n=500&search=".urlencode($search));
$x = Network::fetchURL(get_server()."/lsearch?p=1&n=500&search=".urlencode($search));
$j = json_decode($x);
if (count($j->results)) {