Move remaining functions

update remaining function calls
This commit is contained in:
Adam Magness 2018-01-27 08:25:54 -05:00
parent 1eb7c19c1e
commit ca76e49c23
19 changed files with 58 additions and 51 deletions

View file

@ -5,6 +5,7 @@ use Friendica\Core\Addon;
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;
use League\HTMLToMarkdown\HtmlConverter; use League\HTMLToMarkdown\HtmlConverter;
require_once 'include/event.php'; require_once 'include/event.php';
@ -82,7 +83,7 @@ function diaspora2bb($s) {
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s); $s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
// Don't show link to full picture (until it is fixed) // Don't show link to full picture (until it is fixed)
$s = scale_external_images($s, false); $s = Network::scaleExternalImages($s, false);
return $s; return $s;
} }

View file

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

View file

@ -9,6 +9,7 @@
*/ */
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb) function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb)
@ -362,7 +363,7 @@ function addHostnameSub($matches, $basepath)
$url = $matches[1]; $url = $matches[1];
$parts = array_merge($base, parse_url($url)); $parts = array_merge($base, parse_url($url));
$url2 = unParseUrl($parts); $url2 = Network::unParseURL($parts);
return str_replace($url, $url2, $link); return str_replace($url, $url2, $link);
} }

View file

@ -252,7 +252,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
return; return;
} }
$xml = parse_xml_string($res); $xml = Network::parseXmlString($res);
$status = (int) $xml->status; $status = (int) $xml->status;
$message = unxmlify($xml->message); // human readable text of what may have gone wrong. $message = unxmlify($xml->message); // human readable text of what may have gone wrong.
switch ($status) { switch ($status) {

View file

@ -123,7 +123,7 @@ function dfrn_notify_post(App $a) {
// if contact's ssl policy changed, update our links // if contact's ssl policy changed, update our links
fix_contact_ssl_policy($importer,$ssl_policy); Network::fixContactSslPolicy($importer, $ssl_policy);
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']); logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA); logger('dfrn_notify: data: ' . $data, LOGGER_DATA);

View file

@ -104,7 +104,7 @@ function dfrn_poll_init(App $a)
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA); logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
if (strlen($s)) { if (strlen($s)) {
$xml = parse_xml_string($s); $xml = Network::parseXmlString($s);
if ((int) $xml->status === 1) { if ((int) $xml->status === 1) {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
@ -521,7 +521,7 @@ function dfrn_poll_content(App $a)
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
if (strlen($s) && strstr($s, '<?xml')) { if (strlen($s) && strstr($s, '<?xml')) {
$xml = parse_xml_string($s); $xml = Network::parseXmlString($s);
logger('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), LOGGER_DATA); logger('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), LOGGER_DATA);

View file

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

View file

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

View file

@ -10,8 +10,7 @@ use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager; use Friendica\Core\NotificationsManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\Network;
require_once "include/network.php";
function notifications_post(App $a) { function notifications_post(App $a) {
@ -139,8 +138,9 @@ function notifications_content(App $a) {
$notifs['page'] = $a->pager['page']; $notifs['page'] = $a->pager['page'];
// Json output // Json output
if(intval($json) === 1) if (intval($json) === 1) {
json_return_and_die($notifs); Network::jsonReturnAndDie($notifs);
}
$notif_tpl = get_markup_template('notifications.tpl'); $notif_tpl = get_markup_template('notifications.tpl');

View file

@ -1,10 +1,10 @@
<?php <?php
/** /**
* @file mod/smilies.php * @file mod/smilies.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Content\Smilies; use Friendica\Content\Smilies;
use Friendica\Util\Network;
/** /**
* @param object $a App * @param object $a App
@ -18,7 +18,7 @@ function smilies_content(App $a)
for ($i = 0; $i < count($tmp['texts']); $i++) { for ($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = ['text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]]; $results[] = ['text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]];
} }
json_return_and_die($results); Network::jsonReturnAndDie($results);
} else { } else {
return Smilies::replace('', true); return Smilies::replace('', true);
} }

View file

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

View file

@ -26,7 +26,6 @@ use DOMXPath;
use DOMDocument; use DOMDocument;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/network.php';
/** /**
* @brief This class contain functions for probing URL * @brief This class contain functions for probing URL
@ -111,7 +110,7 @@ class Probe
$ret = Network::zFetchURL($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 = Network::parseXmlString($xml, false);
$host_url = 'https://'.$host; $host_url = 'https://'.$host;
} }
@ -122,7 +121,7 @@ class Probe
return false; return false;
} }
$xml = $ret['body']; $xml = $ret['body'];
$xrd = parse_xml_string($xml, false); $xrd = Network::parseXmlString($xml, false);
$host_url = 'http://'.$host; $host_url = 'http://'.$host;
} }
if (!is_object($xrd)) { if (!is_object($xrd)) {
@ -332,7 +331,7 @@ class Probe
} }
if (x($data, "photo")) { if (x($data, "photo")) {
$data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"])); $data["baseurl"] = Network::matchingURL(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
} else { } else {
$data["photo"] = System::baseUrl().'/images/person-175.jpg'; $data["photo"] = System::baseUrl().'/images/person-175.jpg';
} }
@ -709,7 +708,7 @@ class Probe
} }
// If it is not JSON, maybe it is XML // If it is not JSON, maybe it is XML
$xrd = parse_xml_string($data, false); $xrd = Network::parseXmlString($data, false);
if (!is_object($xrd)) { if (!is_object($xrd)) {
logger("No webfinger data retrievable for ".$url, LOGGER_DEBUG); logger("No webfinger data retrievable for ".$url, LOGGER_DEBUG);
return false; return false;

View file

@ -793,7 +793,7 @@ class DFRN
if ($activity) { if ($activity) {
$entry = $doc->createElement($element); $entry = $doc->createElement($element);
$r = parse_xml_string($activity, false); $r = Network::parseXmlString($activity, false);
if (!$r) { if (!$r) {
return false; return false;
} }
@ -816,7 +816,7 @@ class DFRN
$r->link = preg_replace('/\<link(.*?)\"\>/', '<link$1"/>', $r->link); $r->link = preg_replace('/\<link(.*?)\"\>/', '<link$1"/>', $r->link);
// XML does need a single element as root element so we add a dummy element here // XML does need a single element as root element so we add a dummy element here
$data = parse_xml_string("<dummy>" . $r->link . "</dummy>", false); $data = Network::parseXmlString("<dummy>" . $r->link . "</dummy>", false);
if (is_object($data)) { if (is_object($data)) {
foreach ($data->link as $link) { foreach ($data->link as $link) {
$attributes = []; $attributes = [];
@ -1212,7 +1212,7 @@ class DFRN
return 3; return 3;
} }
$res = parse_xml_string($xml); $res = Network::parseXmlString($xml);
if ((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) { if ((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) {
return (($res->status) ? $res->status : 3); return (($res->status) ? $res->status : 3);
@ -1357,7 +1357,7 @@ class DFRN
Contact::unmarkForArchival($contact); Contact::unmarkForArchival($contact);
} }
$res = parse_xml_string($xml); $res = Network::parseXmlString($xml);
if (!isset($res->status)) { if (!isset($res->status)) {
return -11; return -11;
@ -2188,7 +2188,7 @@ class DFRN
if (!$verb) { if (!$verb) {
return; return;
} }
$xo = parse_xml_string($item["object"], false); $xo = Network::parseXmlString($item["object"], false);
if (($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) { if (($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) {
// somebody was poked/prodded. Was it me? // somebody was poked/prodded. Was it me?
@ -2310,8 +2310,8 @@ class DFRN
} }
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) { if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"], false); $xo = Network::parseXmlString($item["object"], false);
$xt = parse_xml_string($item["target"], false); $xt = Network::parseXmlString($item["target"], false);
if ($xt->type == ACTIVITY_OBJ_NOTE) { if ($xt->type == ACTIVITY_OBJ_NOTE) {
$r = q( $r = q(
@ -2518,7 +2518,7 @@ class DFRN
$item["object"] = self::transformActivity($xpath, $object, "object"); $item["object"] = self::transformActivity($xpath, $object, "object");
if (trim($item["object"]) != "") { if (trim($item["object"]) != "") {
$r = parse_xml_string($item["object"], false); $r = Network::parseXmlString($item["object"], false);
if (isset($r->type)) { if (isset($r->type)) {
$item["object-type"] = $r->type; $item["object-type"] = $r->type;
} }
@ -2787,8 +2787,8 @@ class DFRN
} }
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) { if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"], false); $xo = Network::parseXmlString($item["object"], false);
$xt = parse_xml_string($item["target"], false); $xt = Network::parseXmlString($item["target"], false);
if ($xt->type == ACTIVITY_OBJ_NOTE) { if ($xt->type == ACTIVITY_OBJ_NOTE) {
$i = q( $i = q(

View file

@ -186,7 +186,7 @@ class Diaspora
*/ */
private static function verifyMagicEnvelope($envelope) private static function verifyMagicEnvelope($envelope)
{ {
$basedom = parse_xml_string($envelope); $basedom = Network::parseXmlString($envelope);
if (!is_object($basedom)) { if (!is_object($basedom)) {
logger("Envelope is no XML file"); logger("Envelope is no XML file");
@ -296,7 +296,7 @@ class Diaspora
$xml = $raw; $xml = $raw;
} }
$basedom = parse_xml_string($xml); $basedom = Network::parseXmlString($xml);
if (!is_object($basedom)) { if (!is_object($basedom)) {
logger('Received data does not seem to be an XML. Discarding. '.$xml); logger('Received data does not seem to be an XML. Discarding. '.$xml);
@ -347,7 +347,7 @@ class Diaspora
public static function decode($importer, $xml) public static function decode($importer, $xml)
{ {
$public = false; $public = false;
$basedom = parse_xml_string($xml); $basedom = Network::parseXmlString($xml);
if (!is_object($basedom)) { if (!is_object($basedom)) {
logger("XML is not parseable."); logger("XML is not parseable.");
@ -381,7 +381,7 @@ class Diaspora
$decrypted = self::aesDecrypt($outer_key, $outer_iv, $ciphertext); $decrypted = self::aesDecrypt($outer_key, $outer_iv, $ciphertext);
logger('decrypted: '.$decrypted, LOGGER_DEBUG); logger('decrypted: '.$decrypted, LOGGER_DEBUG);
$idom = parse_xml_string($decrypted); $idom = Network::parseXmlString($decrypted);
$inner_iv = base64_decode($idom->iv); $inner_iv = base64_decode($idom->iv);
$inner_aes_key = base64_decode($idom->aes_key); $inner_aes_key = base64_decode($idom->aes_key);
@ -631,7 +631,7 @@ class Diaspora
*/ */
private static function validPosting($msg) private static function validPosting($msg)
{ {
$data = parse_xml_string($msg["message"]); $data = Network::parseXmlString($msg["message"]);
if (!is_object($data)) { if (!is_object($data)) {
logger("No valid XML ".$msg["message"], LOGGER_DEBUG); logger("No valid XML ".$msg["message"], LOGGER_DEBUG);
@ -1281,7 +1281,7 @@ class Diaspora
} }
} }
$source_xml = parse_xml_string($x); $source_xml = Network::parseXmlString($x);
if (!is_object($source_xml)) { if (!is_object($source_xml)) {
return false; return false;

View file

@ -9,6 +9,7 @@ namespace Friendica\Protocol;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Util\Network;
use dba; use dba;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
@ -243,7 +244,7 @@ class Feed {
$orig_plink = $item["plink"]; $orig_plink = $item["plink"];
$item["plink"] = original_url($item["plink"]); $item["plink"] = Network::originalURL($item["plink"]);
$item["parent-uri"] = $item["uri"]; $item["parent-uri"] = $item["uri"];

View file

@ -11,6 +11,7 @@ use Friendica\Core\System;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'library/slinky.php'; require_once 'library/slinky.php';
@ -852,7 +853,7 @@ class Network
{ {
$a = get_app(); $a = get_app();
$url = strip_tracking_query_params($url); $url = self::stripTrackingQueryParams($url);
if ($depth > 10) { if ($depth > 10) {
return($url); return($url);
@ -885,15 +886,15 @@ class Network
&& (($curl_info['redirect_url'] != "") || ($curl_info['location'] != "")) && (($curl_info['redirect_url'] != "") || ($curl_info['location'] != ""))
) { ) {
if ($curl_info['redirect_url'] != "") { if ($curl_info['redirect_url'] != "") {
return(original_url($curl_info['redirect_url'], ++$depth, $fetchbody)); return(Network::originalURL($curl_info['redirect_url'], ++$depth, $fetchbody));
} else { } else {
return(original_url($curl_info['location'], ++$depth, $fetchbody)); return(Network::originalURL($curl_info['location'], ++$depth, $fetchbody));
} }
} }
// Check for redirects in the meta elements of the body if there are no redirects in the header. // Check for redirects in the meta elements of the body if there are no redirects in the header.
if (!$fetchbody) { if (!$fetchbody) {
return(original_url($url, ++$depth, true)); return(Network::originalURL($url, ++$depth, true));
} }
// if the file is too large then exit // if the file is too large then exit
@ -945,7 +946,7 @@ class Network
$pathinfo = explode(";", $path); $pathinfo = explode(";", $path);
foreach ($pathinfo as $value) { foreach ($pathinfo as $value) {
if (substr(strtolower($value), 0, 4) == "url=") { if (substr(strtolower($value), 0, 4) == "url=") {
return(original_url(substr($value, 4), ++$depth)); return(Network::originalURL(substr($value, 4), ++$depth));
} }
} }
} }

View file

@ -141,7 +141,7 @@ class ParseUrl
$url = trim($url, "'"); $url = trim($url, "'");
$url = trim($url, '"'); $url = trim($url, '"');
$url = strip_tracking_query_params($url); $url = Network::stripTrackingQueryParams($url);
$siteinfo["url"] = $url; $siteinfo["url"] = $url;
$siteinfo["type"] = "link"; $siteinfo["type"] = "link";

View file

@ -15,6 +15,7 @@ use Friendica\Model\User;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\Network;
use dba; use dba;
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
@ -299,7 +300,7 @@ class Delivery {
} }
$ssl_policy = Config::get('system','ssl_policy'); $ssl_policy = Config::get('system','ssl_policy');
fix_contact_ssl_policy($x[0],$ssl_policy); Network::fixContactSslPolicy($x[0], $ssl_policy);
// If we are setup as a soapbox we aren't accepting top level posts from this person // If we are setup as a soapbox we aren't accepting top level posts from this person

View file

@ -219,7 +219,7 @@ class OnePoll
} }
$res = parse_xml_string($handshake_xml); $res = Network::parseXmlString($handshake_xml);
if (intval($res->status) == 1) { if (intval($res->status) == 1) {
logger("$url replied status 1 - marking for death "); logger("$url replied status 1 - marking for death ");