Review update

Rename function, move others
This commit is contained in:
Adam Magness 2018-01-27 11:13:41 -05:00
parent 0f1be37279
commit f04d40a37e
55 changed files with 331 additions and 326 deletions

View file

@ -734,7 +734,7 @@ function navbar_complete(App $a) {
if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = Network::zFetchURL(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
$x = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
if ($x['success']) {
$j = json_decode($x['body'],true);
if ($j && isset($j['results'])) {

View file

@ -5074,7 +5074,7 @@ function api_get_nick($profile)
if ($StatusnetHost != $profile) {
$StatusnetUser = preg_replace("=https?://(.*)/user/(.*)=ism", "$2", $profile);
if ($StatusnetUser != $profile) {
$UserData = Network::fetchURL("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

@ -1,11 +1,11 @@
<?php
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Util\Network;
use League\HTMLToMarkdown\HtmlConverter;
require_once 'include/event.php';
@ -83,7 +83,7 @@ function diaspora2bb($s) {
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
// Don't show link to full picture (until it is fixed)
$s = Network::scaleExternalImages($s, false);
$s = BBCode::scaleExternalImages($s, false);
return $s;
}

View file

@ -689,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 = Network::fetchURL("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) {
@ -748,7 +748,7 @@ function bb_RemovePictureLinks($match) {
$text = "[url=".$match[2]."]".$match[2]."[/url]";
// if its not a picture then look if its a page that contains a picture link
$body = Network::fetchURL($match[1]);
$body = Network::fetchUrl($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);
@ -803,7 +803,7 @@ function bb_CleanPictureLinksSub($match) {
$text = "[img]".$match[2]."[/img]";
// if its not a picture then look if its a page that contains a picture link
$body = Network::fetchURL($match[1]);
$body = Network::fetchUrl($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);

View file

@ -15,7 +15,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Object\Thread;
use Friendica\Object\Post;
use Friendica\Util\Network;
use Friendica\Util\XML;
require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
@ -185,8 +185,8 @@ function localize_item(&$item) {
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
$obj = Network::parseXmlString($xmlhead.$item['object']);
$links = Network::parseXmlString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$obj = XML::parseString($xmlhead.$item['object']);
$links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title;
$Blink = ""; $Bphoto = "";
@ -221,8 +221,8 @@ function localize_item(&$item) {
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = Network::parseXmlString($xmlhead.$item['object']);
$links = Network::parseXmlString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$obj = XML::parseString($xmlhead.$item['object']);
$links = XML::parseString($xmlhead."<links>".unxmlify($obj->link)."</links>");
$Bname = $obj->title;
$Blink = "";
@ -296,7 +296,7 @@ function localize_item(&$item) {
}
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
$parsedobj = Network::parseXmlString($xmlhead.$item['object']);
$parsedobj = XML::parseString($xmlhead.$item['object']);
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag );
@ -313,7 +313,7 @@ function localize_item(&$item) {
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = Network::parseXmlString($xmlhead.$item['object']);
$obj = XML::parseString($xmlhead.$item['object']);
if (strlen($obj->id)) {
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($obj->id),

View file

@ -363,7 +363,7 @@ function addHostnameSub($matches, $basepath)
$url = $matches[1];
$parts = array_merge($base, parse_url($url));
$url2 = Network::unParseURL($parts);
$url2 = Network::unparseURL($parts);
return str_replace($url, $url2, $link);
}

View file

@ -1481,7 +1481,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
dba::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
}
Network::postURL($url, $params);
Network::post($url, $params);
logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG);

View file

@ -31,6 +31,7 @@ use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML;
require_once 'include/enotify.php';
require_once 'include/items.php';
@ -221,7 +222,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
*
*/
$res = Network::postURL($dfrn_confirm, $params, null, $redirects, 120);
$res = Network::post($dfrn_confirm, $params, null, $redirects, 120);
logger(' Confirm: received data: ' . $res, LOGGER_DATA);
@ -252,7 +253,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
return;
}
$xml = Network::parseXmlString($res);
$xml = XML::parseString($res);
$status = (int) $xml->status;
$message = unxmlify($xml->message); // human readable text of what may have gone wrong.
switch ($status) {
@ -493,7 +494,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$user = dba::selectFirst('user', [], ['nickname' => $node]);
if (!DBM::is_result($user)) {
$message = L10n::t('No user record found for \'%s\' ', $node);
Network::xmlStatus(3, $message); // failure
Network::xmlExit(3, $message); // failure
// NOTREACHED
}
@ -503,7 +504,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (!strstr($my_prvkey, 'PRIVATE KEY')) {
$message = L10n::t('Our site encryption key is apparently messed up.');
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
}
// verify everything
@ -514,7 +515,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (!strlen($decrypted_source_url)) {
$message = L10n::t('Empty site URL was provided or URL could not be decrypted by us.');
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
// NOTREACHED
}
@ -530,7 +531,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (!DBM::is_result($contact)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = L10n::t('Contact record was not found for you on our site.');
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
return; // NOTREACHED
}
}
@ -544,7 +545,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (!$foreign_pubkey) {
$message = L10n::t('Site public key not available in contact record for URL %s.', $decrypted_source_url);
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
}
$decrypted_dfrn_id = "";
@ -560,7 +561,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (dba::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) {
$message = L10n::t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
Network::xmlStatus(1, $message); // Birthday paradox - duplicate dfrn-id
Network::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
// NOTREACHED
}
@ -571,7 +572,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
);
if (!DBM::is_result($r)) {
$message = L10n::t('Unable to set your contact credentials on our system.');
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
}
// It's possible that the other person also requested friendship.
@ -626,7 +627,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
);
if (!DBM::is_result($r)) { // indicates schema is messed up or total db failure
$message = L10n::t('Unable to update your contact profile details on our system');
Network::xmlStatus(3, $message);
Network::xmlExit(3, $message);
}
// Otherwise everything seems to have worked and we are almost done. Yay!
@ -707,7 +708,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
}
}
Network::xmlStatus(0); // Success
Network::xmlExit(0); // Success
return; // NOTREACHED
////////////////////// End of this scenario ///////////////////////////////////////////////
}

View file

@ -49,7 +49,7 @@ function dfrn_notify_post(App $a) {
);
if (! DBM::is_result($r)) {
logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
Network::xmlStatus(3, 'Could not match challenge');
Network::xmlExit(3, 'Could not match challenge');
}
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
@ -71,7 +71,7 @@ function dfrn_notify_post(App $a) {
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
break;
default:
Network::xmlStatus(3, 'Invalid direction');
Network::xmlExit(3, 'Invalid direction');
break; // NOTREACHED
}
@ -97,7 +97,7 @@ function dfrn_notify_post(App $a) {
if (! DBM::is_result($r)) {
logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
Network::xmlStatus(3, 'Contact not found');
Network::xmlExit(3, 'Contact not found');
//NOTREACHED
}
@ -123,7 +123,7 @@ function dfrn_notify_post(App $a) {
// if contact's ssl policy changed, update our links
Network::fixContactSslPolicy($importer, $ssl_policy);
$importer = Contact::updateSslPolicy($importer, $ssl_policy);
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
@ -132,7 +132,7 @@ function dfrn_notify_post(App $a) {
// Relationship is dissolved permanently
Contact::remove($importer['id']);
logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']);
Network::xmlStatus(0, 'relationship dissolved');
Network::xmlExit(0, 'relationship dissolved');
}
$rino = Config::get('system', 'rino_encrypt');
@ -146,7 +146,7 @@ function dfrn_notify_post(App $a) {
// but only for $remote_rino > 1, because old code did't send rino version
if ($rino_remote > 1 && $rino < $rino_remote) {
logger("rino version '$rino_remote' is lower than supported '$rino'");
Network::xmlStatus(0, "rino version '$rino_remote' is lower than supported '$rino'");
Network::xmlExit(0, "rino version '$rino_remote' is lower than supported '$rino'");
}
$rawkey = hex2bin(trim($key));
@ -176,14 +176,14 @@ function dfrn_notify_post(App $a) {
break;
default:
logger("rino: invalid sent version '$rino_remote'");
Network::xmlStatus(0, "Invalid sent version '$rino_remote'");
Network::xmlExit(0, "Invalid sent version '$rino_remote'");
}
logger('rino: decrypted data: ' . $data, LOGGER_DATA);
}
$ret = DFRN::import($data, $importer);
Network::xmlStatus($ret, 'Processed');
Network::xmlExit($ret, 'Processed');
// NOTREACHED
}

View file

@ -12,6 +12,7 @@ use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Util\Network;
use Friendica\Util\XML;
require_once 'include/items.php';
@ -99,12 +100,12 @@ function dfrn_poll_init(App $a)
);
if (DBM::is_result($r)) {
$s = Network::fetchURL($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);
if (strlen($s)) {
$xml = Network::parseXmlString($s);
$xml = XML::parseString($s);
if ((int) $xml->status === 1) {
$_SESSION['authenticated'] = 1;
@ -144,7 +145,7 @@ function dfrn_poll_init(App $a)
dbesc($sec)
);
if (!DBM::is_result($r)) {
Network::xmlStatus(3, 'No ticket');
Network::xmlExit(3, 'No ticket');
// NOTREACHED
}
@ -157,7 +158,7 @@ function dfrn_poll_init(App $a)
intval($r[0]['cid'])
);
if (!DBM::is_result($c)) {
Network::xmlStatus(3, 'No profile');
Network::xmlExit(3, 'No profile');
}
$contact = $c[0];
@ -184,7 +185,7 @@ function dfrn_poll_init(App $a)
if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
Network::xmlStatus(3, 'Bad decryption');
Network::xmlExit(3, 'Bad decryption');
}
header("Content-type: text/xml");
@ -208,10 +209,10 @@ function dfrn_poll_init(App $a)
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id));
if (DBM::is_result($r)) {
Network::xmlStatus(1);
Network::xmlExit(1);
return; // NOTREACHED
}
Network::xmlStatus(0);
Network::xmlExit(0);
return; // NOTREACHED
}
}
@ -236,7 +237,7 @@ function dfrn_poll_post(App $a)
dbesc($sec)
);
if (!DBM::is_result($r)) {
Network::xmlStatus(3, 'No ticket');
Network::xmlExit(3, 'No ticket');
// NOTREACHED
}
@ -249,7 +250,7 @@ function dfrn_poll_post(App $a)
intval($r[0]['cid'])
);
if (!DBM::is_result($c)) {
Network::xmlStatus(3, 'No profile');
Network::xmlExit(3, 'No profile');
}
$contact = $c[0];
@ -276,7 +277,7 @@ function dfrn_poll_post(App $a)
if ($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
Network::xmlStatus(3, 'Bad decryption');
Network::xmlExit(3, 'Bad decryption');
}
header("Content-type: text/xml");
@ -482,7 +483,7 @@ function dfrn_poll_content(App $a)
if (($type === 'profile') && (strlen($sec))) {
// URL reply
if ($dfrn_version < 2.2) {
$s = Network::fetchURL($r[0]['poll']
$s = Network::fetchUrl($r[0]['poll']
. '?dfrn_id=' . $encrypted_id
. '&type=profile-check'
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
@ -490,7 +491,7 @@ function dfrn_poll_content(App $a)
. '&sec=' . $sec
);
} else {
$s = Network::postURL($r[0]['poll'], [
$s = Network::post($r[0]['poll'], [
'dfrn_id' => $encrypted_id,
'type' => 'profile-check',
'dfrn_version' => DFRN_PROTOCOL_VERSION,
@ -521,7 +522,7 @@ function dfrn_poll_content(App $a)
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
if (strlen($s) && strstr($s, '<?xml')) {
$xml = Network::parseXmlString($s);
$xml = XML::parseString($s);
logger('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), LOGGER_DATA);

View file

@ -183,7 +183,7 @@ function dfrn_request_post(App $a)
}
if (strlen($dfrn_request) && strlen($confirm_key)) {
$s = Network::fetchURL($dfrn_request . '?confirm_key=' . $confirm_key);
$s = Network::fetchUrl($dfrn_request . '?confirm_key=' . $confirm_key);
}
// (ignore reply, nothing we can do it failed)
@ -332,20 +332,20 @@ function dfrn_request_post(App $a)
intval($contact_record['id'])
);
} else {
$url = Network::validateURL($url);
$url = Network::isUrlValid($url);
if (!$url) {
notice(L10n::t('Invalid profile URL.') . EOL);
goaway(System::baseUrl() . '/' . $a->cmd);
return; // NOTREACHED
}
if (!Network::allowedURL($url)) {
if (!Network::isUrlAllowed($url)) {
notice(L10n::t('Disallowed profile URL.') . EOL);
goaway(System::baseUrl() . '/' . $a->cmd);
return; // NOTREACHED
}
if (Network::blockedURL($url)) {
if (Network::isUrlBlocked($url)) {
notice(L10n::t('Blocked domain') . EOL);
goaway(System::baseUrl() . '/' . $a->cmd);
return; // NOTREACHED

View file

@ -46,7 +46,7 @@ function dirfind_content(App $a, $prefix = "") {
if (strpos($search,'@') === 0) {
$search = substr($search,1);
$header = L10n::t('People Search - %s', $search);
if ((valid_email($search) && Network::validateEmail($search)) ||
if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = Probe::uri($search);
$discover_user = (in_array($user_data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA]));
@ -178,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 = Network::fetchURL(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

@ -91,7 +91,7 @@ function hovercard_content()
return $o;
} else {
Network::jsonReturnAndDie($profile);
Network::jsonExit($profile);
}
}

View file

@ -483,10 +483,10 @@ function check_htaccess(&$checks) {
$status = true;
$help = "";
if (function_exists('curl_init')) {
$test = Network::fetchURL(System::baseUrl()."/install/testrewrite");
$test = Network::fetchUrl(System::baseUrl()."/install/testrewrite");
if ($test != "ok") {
$test = Network::fetchURL(normalise_link(System::baseUrl()."/install/testrewrite"));
$test = Network::fetchUrl(normalise_link(System::baseUrl()."/install/testrewrite"));
}
if ($test != "ok") {

View file

@ -29,7 +29,6 @@ use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Util\Emailer;
use Friendica\Util\Network;
require_once 'include/enotify.php';
require_once 'include/tags.php';
@ -520,7 +519,7 @@ function item_post(App $a) {
// Fold multi-line [code] sequences
$body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body);
$body = Network::scaleExternalImages($body, false);
$body = BBCode::scaleExternalImages($body, false);
// Setting the object type if not defined before
if (!$objecttype) {

View file

@ -59,9 +59,9 @@ function match_content(App $a)
}
if (strlen(Config::get('system', 'directory'))) {
$x = Network::postURL(get_server().'/msearch', $params);
$x = Network::post(get_server().'/msearch', $params);
} else {
$x = Network::postURL(System::baseUrl() . '/msearch', $params);
$x = Network::post(System::baseUrl() . '/msearch', $params);
}
$j = json_decode($x);

View file

@ -247,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 = Network::fetchURL($url);
$ret = Network::fetchUrl($url);
logger('registering answer: '.$ret, LOGGER_DEBUG);
logger('cron_end');

View file

@ -139,7 +139,7 @@ function notifications_content(App $a) {
// Json output
if (intval($json) === 1) {
Network::jsonReturnAndDie($notifs);
Network::jsonExit($notifs);
}
$notif_tpl = get_markup_template('notifications.tpl');

View file

@ -40,7 +40,7 @@ function oexchange_content(App $a) {
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
$s = Network::fetchURL(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

@ -41,7 +41,7 @@ function ostatus_subscribe_content(App $a) {
$api = $contact["baseurl"]."/api/";
// Fetching friends
$data = Network::zFetchURL($api."statuses/friends.json?screen_name=".$contact["nick"]);
$data = Network::curl($api."statuses/friends.json?screen_name=".$contact["nick"]);
if (!$data["success"]) {
return $o.L10n::t("Couldn't fetch friends for contact.");

View file

@ -61,7 +61,7 @@ function parse_url_content(App $a) {
// the URL with the corresponding BBCode media tag
$redirects = 0;
// Fetch the header of the URL
$result = Network::zFetchURL($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
$result = Network::curl($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
if($result["success"]) {
// Convert the header fields into an array
$hdrs = [];

View file

@ -162,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 = Network::fetchURL($_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

@ -110,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 = Network::fetchURL($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

@ -536,7 +536,7 @@ function settings_post(App $a)
// If openid has changed or if there's an openid but no openidserver, try and discover it.
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
if (Network::validateURL($openid)) {
if (Network::isUrlValid($openid)) {
logger('updating openidserver');
require_once 'library/openid.php';
$open_id_obj = new LightOpenID;

View file

@ -18,7 +18,7 @@ function smilies_content(App $a)
for ($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = ['text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]];
}
Network::jsonReturnAndDie($results);
Network::jsonExit($results);
} else {
return Smilies::replace('', true);
}

View file

@ -69,7 +69,7 @@ text { font:12px Dialog; }
<text x="29" y="1664" style="font:13px Open Sans">getting transmitted (if $aes_allow -&gt; encrypt the the public key)</text>
<text x="29" y="1710" style="font:13px Open Sans"> -&gt; add duplex state and page-flags to the params</text>
<text x="29" y="1756" style="font:13px Open Sans"> -&gt; send params to Bobs dfrn_confirm page ($res = </text>
<text x="29" y="1779" style="font:13px Open Sans">Network::postURL($dfrn_confirm,$params);</text>
<text x="29" y="1779" style="font:13px Open Sans">Network::post($dfrn_confirm,$params);</text>
<clipPath id="clip11"><path d="M1041,1319 L1619,1319 L1619,1913 L1041,1913 L1041,1319 Z" /></clipPath>
<path d="M1050,1320 C1045.5820313,1320 1042,1323.5820313 1042,1328 L1042,1903 C1042,1907.4179688 1045.5820313,1911 1050,1911 L1609,1911 C1613.4179688,1911 1617,1907.4179688 1617,1903 L1617,1328 C1617,1323.5820313 1613.4179688,1320 1609,1320 Z" style="fill:rgb(255,255,3);stroke:none" clip-path="url(#clip11)" />
<text x="1055" y="1342" style="font:13px Open Sans">dfrn_confirm_post()</text>

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

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">- Network::fetchURL($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">- Network::fetchURL(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

@ -78,7 +78,7 @@ class OEmbed
if (!in_array($ext, $noexts)) {
// try oembed autodiscovery
$redirects = 0;
$html_text = Network::fetchURL($embedurl, false, $redirects, 15, "text/*");
$html_text = Network::fetchUrl($embedurl, false, $redirects, 15, "text/*");
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
@ -86,13 +86,13 @@ class OEmbed
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$txt = Network::fetchURL($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 = Network::fetchURL($href . '&maxwidth=' . $a->videowidth);
$txt = Network::fetchUrl($href . '&maxwidth=' . $a->videowidth);
break;
}
}
@ -312,7 +312,7 @@ class OEmbed
$allowed = explode(',', $str_allowed);
return Network::allowedDomain($domain, $allowed);
return Network::isDomainAllowed($domain, $allowed);
}
public static function getHTML($url, $title = null)

View file

@ -6,7 +6,10 @@ namespace Friendica\Content\Text;
use Friendica\App;
use Friendica\Content\Text\Plaintext;
use Friencica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Object\Image;
use Friendica\Util\ParseUrl;
@ -475,4 +478,74 @@ class BBCode
return($post);
}
public static function scaleExternalImages($srctext, $include_link = true, $scale_replace = false)
{
// Suppress "view full size"
if (intval(Config::get('system', 'no_view_full_size'))) {
$include_link = false;
}
// Picture addresses can contain special characters
$s = htmlspecialchars_decode($srctext);
$matches = null;
$c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism', $s, $matches, PREG_SET_ORDER);
if ($c) {
foreach ($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]);
$hostname = str_replace('www.', '', substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3));
if (stristr($mtch[1], $hostname)) {
continue;
}
// $scale_replace, if passed, is an array of two elements. The
// first is the name of the full-size image. The second is the
// name of a remote, scaled-down version of the full size image.
// This allows Friendica to display the smaller remote image if
// one exists, while still linking to the full-size image
if ($scale_replace) {
$scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[1]);
} else {
$scaled = $mtch[1];
}
$i = self::fetchURL($scaled);
if (! $i) {
return $srctext;
}
// guess mimetype from headers or filename
$type = Image::guessType($mtch[1], true);
if ($i) {
$Image = new Image($i, $type);
if ($Image->isValid()) {
$orig_width = $Image->getWidth();
$orig_height = $Image->getHeight();
if ($orig_width > 640 || $orig_height > 640) {
$Image->scaleDown(640);
$new_width = $Image->getWidth();
$new_height = $Image->getHeight();
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
$s = str_replace(
$mtch[0],
'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]'
. "\n" . (($include_link)
? '[url=' . $mtch[1] . ']' . L10n::t('view full size') . '[/url]' . "\n"
: ''),
$s
);
logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG);
}
}
}
}
}
// replace the special char encoding
$s = htmlspecialchars($s, ENT_NOQUOTES, 'UTF-8');
return $s;
}
}

View file

@ -13,7 +13,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Util\Network;
use Friendica\Util\XML;
require_once 'include/dba.php';
require_once 'include/html2plain.php';
@ -338,7 +338,7 @@ class NotificationsManager extends BaseObject
case ACTIVITY_FRIEND:
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = Network::parseXmlString($xmlhead . $it['object']);
$obj = XML::parseString($xmlhead . $it['object']);
$it['fname'] = $obj->title;
$notif = [

View file

@ -888,7 +888,7 @@ class Worker
}
$url = System::baseUrl()."/worker";
Network::fetchURL($url, false, $redirects, 1);
Network::fetchUrl($url, false, $redirects, 1);
}
/**

View file

@ -1132,12 +1132,12 @@ class Contact extends BaseObject
// remove ajax junk, e.g. Twitter
$url = str_replace('/#!/', '/', $url);
if (!Network::allowedURL($url)) {
if (!Network::isUrlAllowed($url)) {
$result['message'] = L10n::t('Disallowed profile URL.');
return $result;
}
if (Network::blockedURL($url)) {
if (Network::isUrlBlocked($url)) {
$result['message'] = L10n::t('Blocked domain');
return $result;
}
@ -1321,4 +1321,37 @@ class Contact extends BaseObject
$result['success'] = true;
return $result;
}
public static function updateSslPolicy($contact, $new_policy)
{
$ssl_changed = false;
if ((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'], 'https:')) {
$ssl_changed = true;
$contact['url'] = str_replace('https:', 'http:', $contact['url']);
$contact['request'] = str_replace('https:', 'http:', $contact['request']);
$contact['notify'] = str_replace('https:', 'http:', $contact['notify']);
$contact['poll'] = str_replace('https:', 'http:', $contact['poll']);
$contact['confirm'] = str_replace('https:', 'http:', $contact['confirm']);
$contact['poco'] = str_replace('https:', 'http:', $contact['poco']);
}
if ((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'], 'http:')) {
$ssl_changed = true;
$contact['url'] = str_replace('http:', 'https:', $contact['url']);
$contact['request'] = str_replace('http:', 'https:', $contact['request']);
$contact['notify'] = str_replace('http:', 'https:', $contact['notify']);
$contact['poll'] = str_replace('http:', 'https:', $contact['poll']);
$contact['confirm'] = str_replace('http:', 'https:', $contact['confirm']);
$contact['poco'] = str_replace('http:', 'https:', $contact['poco']);
}
if ($ssl_changed) {
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
'notify' => $contact['notify'], 'poll' => $contact['poll'],
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
dba::update('contact', $fields, ['id' => $contact['id']]);
}
return $contact;
}
}

View file

@ -568,7 +568,7 @@ class GContact
$done[] = System::baseUrl() . '/poco';
if (strlen(Config::get('system', 'directory'))) {
$x = Network::fetchURL(get_server()."/pubsites");
$x = Network::fetchUrl(get_server()."/pubsites");
if ($x) {
$j = json_decode($x);
if ($j->entries) {
@ -980,7 +980,7 @@ class GContact
$url = $server."/main/statistics";
$result = Network::zFetchURL($url);
$result = Network::curl($url);
if (!$result["success"]) {
return false;
}

View file

@ -102,7 +102,7 @@ class Photo
$photo_failure = false;
$filename = basename($image_url);
$img_str = Network::fetchURL($image_url, true);
$img_str = Network::fetchUrl($image_url, true);
if ($quit_on_error && ($img_str == "")) {
return false;

View file

@ -964,7 +964,7 @@ class Profile
public static function zrlInit(App $a)
{
$my_url = self::getMyURL();
$my_url = Network::validateURL($my_url);
$my_url = Network::isUrlValid($my_url);
if ($my_url) {
// Is it a DDoS attempt?
// The check fetches the cached value from gprobe to reduce the load for this system

View file

@ -281,7 +281,7 @@ class User
if (!x($username) || !x($email) || !x($nickname)) {
if ($openid_url) {
if (!Network::validateURL($openid_url)) {
if (!Network::isUrlValid($openid_url)) {
throw new Exception(L10n::t('Invalid OpenID url'));
}
$_SESSION['register'] = 1;
@ -304,7 +304,7 @@ class User
throw new Exception(L10n::t('Please enter the required information.'));
}
if (!Network::validateURL($openid_url)) {
if (!Network::isUrlValid($openid_url)) {
$openid_url = '';
}
@ -329,11 +329,11 @@ class User
}
}
if (!Network::allowedEmail($email)) {
if (!Network::isEmailDomainAllowed($email)) {
throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
}
if (!valid_email($email) || !Network::validateEmail($email)) {
if (!valid_email($email) || !Network::isEmailDomainValid($email)) {
throw new Exception(L10n::t('Not a valid email address.'));
}
@ -460,7 +460,7 @@ class User
// if we have no OpenID photo try to look up an avatar
if (!strlen($photo)) {
$photo = Network::avatarImg($email);
$photo = Network::lookupAvatarByEmail($email);
}
// unless there is no avatar-addon loaded
@ -468,7 +468,7 @@ class User
$photo_failure = false;
$filename = basename($photo);
$img_str = Network::fetchURL($photo, true);
$img_str = Network::fetchUrl($photo, true);
// guess mimetype from headers or filename
$type = Image::guessType($photo, true);

View file

@ -60,7 +60,7 @@ class Login extends BaseModule
$openid_url = trim($_POST['openid_url'] ? : $_POST['username']);
// if it's an email address or doesn't resolve to a URL, fail.
if ($noid || strpos($openid_url, '@') || !Network::validateURL($openid_url)) {
if ($noid || strpos($openid_url, '@') || !Network::isUrlValid($openid_url)) {
notice(L10n::t('Login failed.') . EOL);
goaway(self::getApp()->get_baseurl());
// NOTREACHED

View file

@ -107,21 +107,21 @@ class Probe
logger("Probing for ".$host, LOGGER_DEBUG);
$ret = Network::zFetchURL($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
$ret = Network::curl($ssl_url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
if ($ret['success']) {
$xml = $ret['body'];
$xrd = Network::parseXmlString($xml, false);
$xrd = XML::parseString($xml, false);
$host_url = 'https://'.$host;
}
if (!is_object($xrd)) {
$ret = Network::zFetchURL($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
$ret = Network::curl($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;
}
$xml = $ret['body'];
$xrd = Network::parseXmlString($xml, false);
$xrd = XML::parseString($xml, false);
$host_url = 'http://'.$host;
}
if (!is_object($xrd)) {
@ -331,7 +331,7 @@ class Probe
}
if (x($data, "photo")) {
$data["baseurl"] = Network::matchingURL(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
$data["baseurl"] = Network::getUrlMatch(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
} else {
$data["photo"] = System::baseUrl().'/images/person-175.jpg';
}
@ -692,7 +692,7 @@ class Probe
$xrd_timeout = Config::get('system', 'xrd_timeout', 20);
$redirects = 0;
$ret = Network::zFetchURL($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
$ret = Network::curl($url, false, $redirects, ['timeout' => $xrd_timeout, 'accept_content' => $type]);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
@ -708,7 +708,7 @@ class Probe
}
// If it is not JSON, maybe it is XML
$xrd = Network::parseXmlString($data, false);
$xrd = XML::parseString($data, false);
if (!is_object($xrd)) {
logger("No webfinger data retrievable for ".$url, LOGGER_DEBUG);
return false;
@ -759,7 +759,7 @@ class Probe
*/
private static function pollNoscrape($noscrape_url, $data)
{
$ret = Network::zFetchURL($noscrape_url);
$ret = Network::curl($noscrape_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}
@ -993,7 +993,7 @@ class Probe
*/
private static function pollHcard($hcard_url, $data, $dfrn = false)
{
$ret = Network::zFetchURL($hcard_url);
$ret = Network::curl($hcard_url);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
return false;
}