]> git.mxchange.org Git - friendica.git/commitdiff
Move functions to system
authorAdam Magness <adam.magness@gmail.com>
Sat, 27 Jan 2018 16:59:10 +0000 (11:59 -0500)
committerAdam Magness <adam.magness@gmail.com>
Sat, 27 Jan 2018 16:59:10 +0000 (11:59 -0500)
move some functions to system

21 files changed:
mod/_well_known.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/display.php
mod/hovercard.php
mod/nodeinfo.php
mod/notifications.php
mod/poco.php
mod/probe.php
mod/pubsubhubbub.php
mod/receive.php
mod/salmon.php
mod/search.php
mod/smilies.php
mod/statistics_json.php
mod/webfinger.php
src/Core/System.php
src/Module/Feed.php
src/Protocol/Diaspora.php
src/Util/Network.php

index e7bc8c92bf66bbce2f640bea829543d1f48dbaf6..25289171f67f3f9f4965c7b80acda5b3dd38d66a 100644 (file)
@@ -2,7 +2,7 @@
 
 use Friendica\App;
 use Friendica\Core\Config;
-use Friendica\Util\Network;
+use Friendica\Core\System;
 
 require_once 'mod/hostxrd.php';
 require_once 'mod/nodeinfo.php';
@@ -26,7 +26,7 @@ function _well_known_init(App $a)
                                break;
                }
        }
-       Network::httpStatusExit(404);
+       System::httpExit(404);
        killme();
 }
 
index 85e896dcf5775239d6dc47d750ff14ddda1dbe92..3066a871fc95ba89cbe15ac5c6394ecf26a428fc 100644 (file)
@@ -494,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::xmlExit(3, $message); // failure
+                       System::xmlExit(3, $message); // failure
                        // NOTREACHED
                }
 
@@ -504,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::xmlExit(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // verify everything
@@ -515,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::xmlExit(3, $message);
+                       System::xmlExit(3, $message);
                        // NOTREACHED
                }
 
@@ -531,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::xmlExit(3, $message);
+                               System::xmlExit(3, $message);
                                return; // NOTREACHED
                        }
                }
@@ -545,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::xmlExit(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                $decrypted_dfrn_id = "";
@@ -561,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::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
+                       System::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
                        // NOTREACHED
                }
 
@@ -572,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::xmlExit(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // It's possible that the other person also requested friendship.
@@ -627,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::xmlExit(3, $message);
+                       System::xmlExit(3, $message);
                }
 
                // Otherwise everything seems to have worked and we are almost done. Yay!
@@ -708,7 +708,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                }
                        }
                }
-               Network::xmlExit(0); // Success
+               System::xmlExit(0); // Success
                return; // NOTREACHED
                ////////////////////// End of this scenario ///////////////////////////////////////////////
        }
index 8efb9328d53cc887d7cb707a7a2fba313ef86898..2f4edafc5d8f37858854a1922b39bea8cb4cd8ad 100644 (file)
@@ -8,10 +8,10 @@
 
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Protocol\DFRN;
-use Friendica\Util\Network;
 
 require_once 'include/items.php';
 require_once 'include/event.php';
@@ -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::xmlExit(3, 'Could not match challenge');
+               System::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::xmlExit(3, 'Invalid direction');
+                       System::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::xmlExit(3, 'Contact not found');
+               System::xmlExit(3, 'Contact not found');
                //NOTREACHED
        }
 
@@ -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::xmlExit(0, 'relationship dissolved');
+               System::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::xmlExit(0, "rino version '$rino_remote' is lower than supported '$rino'");
+                       System::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::xmlExit(0, "Invalid sent version '$rino_remote'");
+                               System::xmlExit(0, "Invalid sent version '$rino_remote'");
                }
 
                logger('rino: decrypted data: ' . $data, LOGGER_DATA);
        }
 
        $ret = DFRN::import($data, $importer);
-       Network::xmlExit($ret, 'Processed');
+       System::xmlExit($ret, 'Processed');
 
        // NOTREACHED
 }
index 3e5aa5b1c7bb285df46ad0298418624bfaacf127..7d5418c364533b4f27c073b9e3dfe0822453bca7 100644 (file)
@@ -49,7 +49,7 @@ function dfrn_poll_init(App $a)
 
        if (($dfrn_id === '') && (!x($_POST, 'dfrn_id'))) {
                if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
-                       Network::httpStatusExit(403);
+                       System::httpExit(403);
                }
 
                $user = '';
@@ -58,7 +58,7 @@ function dfrn_poll_init(App $a)
                                dbesc($a->argv[1])
                        );
                        if (!$r) {
-                               Network::httpStatusExit(404);
+                               System::httpExit(404);
                        }
 
                        $hidewall = ($r[0]['hidewall'] && !local_user());
@@ -145,7 +145,7 @@ function dfrn_poll_init(App $a)
                                dbesc($sec)
                        );
                        if (!DBM::is_result($r)) {
-                               Network::xmlExit(3, 'No ticket');
+                               System::xmlExit(3, 'No ticket');
                                // NOTREACHED
                        }
 
@@ -158,7 +158,7 @@ function dfrn_poll_init(App $a)
                                intval($r[0]['cid'])
                        );
                        if (!DBM::is_result($c)) {
-                               Network::xmlExit(3, 'No profile');
+                               System::xmlExit(3, 'No profile');
                        }
 
                        $contact = $c[0];
@@ -185,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::xmlExit(3, 'Bad decryption');
+                               System::xmlExit(3, 'Bad decryption');
                        }
 
                        header("Content-type: text/xml");
@@ -209,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::xmlExit(1);
+                               System::xmlExit(1);
                                return; // NOTREACHED
                        }
-                       Network::xmlExit(0);
+                       System::xmlExit(0);
                        return; // NOTREACHED
                }
        }
@@ -237,7 +237,7 @@ function dfrn_poll_post(App $a)
                                dbesc($sec)
                        );
                        if (!DBM::is_result($r)) {
-                               Network::xmlExit(3, 'No ticket');
+                               System::xmlExit(3, 'No ticket');
                                // NOTREACHED
                        }
 
@@ -250,7 +250,7 @@ function dfrn_poll_post(App $a)
                                intval($r[0]['cid'])
                        );
                        if (!DBM::is_result($c)) {
-                               Network::xmlExit(3, 'No profile');
+                               System::xmlExit(3, 'No profile');
                        }
 
                        $contact = $c[0];
@@ -277,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::xmlExit(3, 'Bad decryption');
+                               System::xmlExit(3, 'Bad decryption');
                        }
 
                        header("Content-type: text/xml");
index 54a54be1678fa615db4311afb735818faa6a257b..8d991d47681d04b8f8c6022c280570631e970b6c 100644 (file)
@@ -11,7 +11,6 @@ use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Profile;
 use Friendica\Protocol\DFRN;
-use Friendica\Util\Network;
 
 function display_init(App $a)
 {
@@ -424,7 +423,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
 function displayShowFeed($item_id, $conversation) {
        $xml = DFRN::itemFeed($item_id, $conversation);
        if ($xml == '') {
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
        header("Content-type: application/atom+xml");
        echo $xml;
index 0bd1d261782e594ce42eeedd3b195c582326bf90..01d9feb1e46fb4f1711e65e8d185e5b31293a5e1 100644 (file)
@@ -9,10 +9,10 @@
  */
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\System;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Profile;
-use Friendica\Util\Network;
 
 function hovercard_init(App $a)
 {
@@ -27,7 +27,7 @@ function hovercard_content()
 
        // Get out if the system doesn't have public access allowed
        if (intval(Config::get('system', 'block_public'))) {
-               Network::httpStatusExit(401);
+               System::httpExit(401);
        }
 
        // Return the raw content of the template. We use this to make templates usable for js functions.
@@ -91,7 +91,7 @@ function hovercard_content()
 
                return $o;
        } else {
-               Network::jsonExit($profile);
+               System::jsonExit($profile);
        }
 }
 
index 026d3f03d93a49edbe156058714c4a9582332c79..5cadc41c4975c1a19debb1a3564b3016a04ac732 100644 (file)
@@ -22,12 +22,12 @@ function nodeinfo_wellknown(App $a) {
 
 function nodeinfo_init(App $a) {
        if (!Config::get('system', 'nodeinfo')) {
-               Network::httpStatusExit(404);
+               System::httpExit(404);
                killme();
        }
 
        if (($a->argc != 2) || ($a->argv[1] != '1.0')) {
-               Network::httpStatusExit(404);
+               System::httpExit(404);
                killme();
        }
 
index 067e954228db696eedc0734a13ce8fb3e830ca3c..46519075b4a933d7590a78cc12628e52bb91a067 100644 (file)
@@ -10,7 +10,6 @@ use Friendica\Core\L10n;
 use Friendica\Core\NotificationsManager;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
-use Friendica\Util\Network;
 
 function notifications_post(App $a) {
 
@@ -139,7 +138,7 @@ function notifications_content(App $a) {
 
        // Json output
        if (intval($json) === 1) {
-               Network::jsonExit($notifs);
+               System::jsonExit($notifs);
        }
 
        $notif_tpl = get_markup_template('notifications.tpl');
index 348f76d1ce8904c52a695edf3a24e5310a343280..c27cd7c49c5ccfbd2bbb1dcc6eae0f2706be91b9 100644 (file)
@@ -6,15 +6,15 @@
 use Friendica\App;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Protocol\PortableContact;
-use Friendica\Util\Network;
 
 function poco_init(App $a) {
        $system_mode = false;
 
        if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) {
-               Network::httpStatusExit(401);
+               System::httpExit(401);
        }
 
        if ($a->argc > 1) {
@@ -23,7 +23,7 @@ function poco_init(App $a) {
        if (! x($user)) {
                $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
                if (! DBM::is_result($c)) {
-                       Network::httpStatusExit(401);
+                       System::httpExit(401);
                }
                $system_mode = true;
        }
@@ -64,7 +64,7 @@ function poco_init(App $a) {
                        dbesc($user)
                );
                if (! DBM::is_result($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                $user = $users[0];
@@ -358,7 +358,7 @@ function poco_init(App $a) {
                        $ret['entry'][] = [];
                }
        } else {
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
        logger("End of poco", LOGGER_DEBUG);
 
@@ -372,6 +372,6 @@ function poco_init(App $a) {
                echo json_encode($ret);
                killme();
        } else {
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
 }
index a7746d55bcddceb8de7539532a9ed06d2b1f26c2..b4f6ff3a4db0b0646ea2fefa6b10bd40610400a5 100644 (file)
@@ -4,13 +4,13 @@
  */
 use Friendica\App;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 use Friendica\Network\Probe;
-use Friendica\Util\Network;
 
 function probe_content(App $a)
 {
        if (!local_user()) {
-               Network::httpStatusExit(403, ["title" => L10n::t("Public access denied."),
+               System::httpExit(403, ["title" => L10n::t("Public access denied."),
                        "description" => L10n::t("Only logged in users are permitted to perform a probing.")]);
                killme();
        }
index 210bc6efbc12ec8c28395e1251c034f665db72bf..ac85657ddfea64811b5cce6ed8f2a947112b8324 100644 (file)
@@ -2,6 +2,7 @@
 
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Util\Network;
 
@@ -13,7 +14,7 @@ function pubsubhubbub_init(App $a) {
        // PuSH subscription must be considered "public" so just block it
        // if public access isn't enabled.
        if (Config::get('system', 'block_public')) {
-               Network::httpStatusExit(403);
+               System::httpExit(403);
        }
 
        // Subscription request from subscriber
@@ -41,7 +42,7 @@ function pubsubhubbub_init(App $a) {
                        $subscribe = 0;
                } else {
                        logger("pubsubhubbub: invalid hub_mode=$hub_mode, ignoring.");
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                logger("pubsubhubbub: $hub_mode request from " .
@@ -57,7 +58,7 @@ function pubsubhubbub_init(App $a) {
 
                if (!$nick) {
                        logger('pubsubhubbub: bad hub_topic=$hub_topic, ignoring.');
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                // fetch user from database given the nickname
@@ -67,7 +68,7 @@ function pubsubhubbub_init(App $a) {
 
                if (!DBM::is_result($r)) {
                        logger('pubsubhubbub: local account not found: ' . $nick);
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                $owner = $r[0];
@@ -76,7 +77,7 @@ function pubsubhubbub_init(App $a) {
                if ($r[0]['hidewall']) {
                        logger('pubsubhubbub: local user ' . $nick .
                                   'has chosen to hide wall, ignoring.');
-                       Network::httpStatusExit(403);
+                       System::httpExit(403);
                }
 
                // get corresponding row from contact table
@@ -85,7 +86,7 @@ function pubsubhubbub_init(App $a) {
                           intval($owner['uid']));
                if (!DBM::is_result($r)) {
                        logger('pubsubhubbub: contact not found.');
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                $contact = $r[0];
@@ -94,7 +95,7 @@ function pubsubhubbub_init(App $a) {
                if (!link_compare($hub_topic, $contact['poll'])) {
                        logger('pubsubhubbub: hub topic ' . $hub_topic . ' != ' .
                                   $contact['poll']);
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                // do subscriber verification according to the PuSH protocol
@@ -117,7 +118,7 @@ function pubsubhubbub_init(App $a) {
                if ($ret < 200 || $ret > 299) {
                        logger("pubsubhubbub: subscriber verification at $hub_callback ".
                                   "returned $ret, ignoring.");
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                // check that the correct hub_challenge code was echoed back
@@ -125,7 +126,7 @@ function pubsubhubbub_init(App $a) {
                        logger("pubsubhubbub: subscriber did not echo back ".
                                   "hub.challenge, ignoring.");
                        logger("\"$hub_challenge\" != \"".trim($body)."\"");
-                       Network::httpStatusExit(404);
+                       System::httpExit(404);
                }
 
                // fetch the old subscription if it exists
@@ -163,7 +164,7 @@ function pubsubhubbub_init(App $a) {
                        logger("pubsubhubbub: successfully unsubscribed [$hub_callback].");
                        // we do nothing here, since the row was already deleted
                }
-               Network::httpStatusExit(202);
+               System::httpExit(202);
        }
 
        killme();
index 60b8ed7961afe143aa1129c95ff9f276d99f6995..41f2225cb4d3a54b4f072d13eedb509f7b434d69 100644 (file)
@@ -6,9 +6,9 @@
 
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Protocol\Diaspora;
-use Friendica\Util\Network;
 
 /**
  * @param object $a App
@@ -19,7 +19,7 @@ function receive_post(App $a)
        $enabled = intval(Config::get('system', 'diaspora_enabled'));
        if (!$enabled) {
                logger('mod-diaspora: disabled');
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
 
        if (($a->argc == 2) && ($a->argv[1] === 'public')) {
@@ -29,13 +29,13 @@ function receive_post(App $a)
                $public = false;
 
                if ($a->argc != 3 || $a->argv[1] !== 'users') {
-                       Network::httpStatusExit(500);
+                       System::httpExit(500);
                }
                $guid = $a->argv[2];
 
                $importer = dba::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
                if (!DBM::is_result($importer)) {
-                       Network::httpStatusExit(500);
+                       System::httpExit(500);
                }
        }
 
@@ -48,7 +48,7 @@ function receive_post(App $a)
        if (!$xml) {
                $postdata = file_get_contents("php://input");
                if ($postdata == '') {
-                       Network::httpStatusExit(500);
+                       System::httpExit(500);
                }
 
                logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
@@ -68,7 +68,7 @@ function receive_post(App $a)
        logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
 
        if (!is_array($msg)) {
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
 
        logger('mod-diaspora: dispatching', LOGGER_DEBUG);
@@ -80,6 +80,6 @@ function receive_post(App $a)
                $ret = Diaspora::dispatch($importer, $msg);
        }
 
-       Network::httpStatusExit(($ret) ? 200 : 500);
+       System::httpExit(($ret) ? 200 : 500);
        // NOTREACHED
 }
index 20806df559472616729a299300f94814f0b61a22..af8f5fa55b12c8813aef5d0ce5551f6a41e4d875 100644 (file)
@@ -4,12 +4,12 @@
  */
 use Friendica\App;
 use Friendica\Core\PConfig;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\Salmon;
 use Friendica\Util\Crypto;
-use Friendica\Util\Network;
 
 require_once 'include/items.php';
 
@@ -39,7 +39,7 @@ function salmon_post(App $a) {
                dbesc($nick)
        );
        if (! DBM::is_result($r)) {
-               Network::httpStatusExit(500);
+               System::httpExit(500);
        }
 
        $importer = $r[0];
@@ -59,7 +59,7 @@ function salmon_post(App $a) {
 
        if(! $base) {
                logger('mod-salmon: unable to locate salmon data in xml ');
-               Network::httpStatusExit(400);
+               System::httpExit(400);
        }
 
        // Stash the signature away for now. We have to find their key or it won't be good for anything.
@@ -97,7 +97,7 @@ function salmon_post(App $a) {
 
        if(! $author_link) {
                logger('mod-salmon: Could not retrieve author URI.');
-               Network::httpStatusExit(400);
+               System::httpExit(400);
        }
 
        // Once we have the author URI, go to the web and try to find their public key
@@ -108,7 +108,7 @@ function salmon_post(App $a) {
 
        if(! $key) {
                logger('mod-salmon: Could not retrieve author key.');
-               Network::httpStatusExit(400);
+               System::httpExit(400);
        }
 
        $key_info = explode('.',$key);
@@ -140,7 +140,7 @@ function salmon_post(App $a) {
 
        if (! $verify) {
                logger('mod-salmon: Message did not verify. Discarding.');
-               Network::httpStatusExit(400);
+               System::httpExit(400);
        }
 
        logger('mod-salmon: Message verified with mode '.$mode);
@@ -184,7 +184,7 @@ function salmon_post(App $a) {
        //if((DBM::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
        if (DBM::is_result($r) && $r[0]['blocked']) {
                logger('mod-salmon: Ignoring this author.');
-               Network::httpStatusExit(202);
+               System::httpExit(202);
                // NOTREACHED
        }
 
@@ -195,5 +195,5 @@ function salmon_post(App $a) {
 
        OStatus::import($data, $importer, $contact_rec, $hub);
 
-       Network::httpStatusExit(200);
+       System::httpExit(200);
 }
index 681dbc9a526a719397d8f011fb8f4f9e7a329bb7..c1990bf8708ba1d9a9d5148264f34d87ea9c9a79 100644 (file)
@@ -8,8 +8,8 @@ use Friendica\Content\Nav;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 use Friendica\Database\DBM;
-use Friendica\Util\Network;
 
 require_once "include/bbcode.php";
 require_once 'include/security.php';
@@ -100,7 +100,7 @@ function search_content(App $a) {
        }
 
        if (Config::get('system','local_search') && !local_user() && !remote_user()) {
-               Network::httpStatusExit(403,
+               System::httpExit(403,
                                ["title" => L10n::t("Public access denied."),
                                        "description" => L10n::t("Only logged in users are permitted to perform a search.")]);
                killme();
@@ -125,7 +125,7 @@ function search_content(App $a) {
                if (!is_null($result)) {
                        $resultdata = json_decode($result);
                        if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
-                               Network::httpStatusExit(429,
+                               System::httpExit(429,
                                                ["title" => L10n::t("Too Many Requests"),
                                                        "description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
                                killme();
index 19f0152ef8a80edec930ba5b1af0bf6182c657da..a33cbf6ad5adabc4ca4e8704d278df634f6513d7 100644 (file)
@@ -4,7 +4,7 @@
  */
 use Friendica\App;
 use Friendica\Content\Smilies;
-use Friendica\Util\Network;
+use Friendica\Core\System;
 
 /**
  * @param object $a App
@@ -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::jsonExit($results);
+               System::jsonExit($results);
        } else {
                return Smilies::replace('', true);
        }
index 75e89ba75e304ed4377a5f3f6a6bb86671c9f884..c035c1c05a5753d4307243e8c3b935ae2cc20edb 100644 (file)
@@ -7,12 +7,12 @@
 use Friendica\App;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
-use Friendica\Util\Network;
+use Friendica\Core\System;
 
 function statistics_json_init(App $a) {
 
        if (!Config::get("system", "nodeinfo")) {
-               Network::httpStatusExit(404);
+               System::httpExit(404);
                killme();
        }
 
index f834e4ff36e86a729499551a56b34ec6246f074d..c8867935278960b07ab235ae02fbf486277a212a 100644 (file)
@@ -4,13 +4,13 @@
  */
 use Friendica\App;
 use Friendica\Core\L10n;
+use Friendica\Core\System;
 use Friendica\Network\Probe;
-use Friendica\Util\Network;
 
 function webfinger_content(App $a)
 {
        if (!local_user()) {
-               Network::httpStatusExit(
+               System::httpExit(
                        403,
                        [
                                "title" => L10n::t("Public access denied."),
index 469016770c5b69b5532975d8b49b1546f6d82c55..d0eb651e938d5524091e643a0b9c302b0b146e31 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
+use Friendica\Util\XML;
 
 /**
  * @file include/Core/System.php
@@ -97,6 +98,86 @@ EOT;
                killme();
        }
 
+       /**
+        * Generic XML return
+        * Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
+        * of $st and an optional text <message> of $message and terminates the current process.
+        */
+       public static function xmlExit($st, $message = '')
+       {
+               $result = ['status' => $st];
+
+               if ($message != '') {
+                       $result['message'] = $message;
+               }
+
+               if ($st) {
+                       logger('xml_status returning non_zero: ' . $st . " message=" . $message);
+               }
+
+               header("Content-type: text/xml");
+
+               $xmldata = ["result" => $result];
+
+               echo XML::fromArray($xmldata, $xml);
+
+               killme();
+       }
+
+       /**
+        * @brief Send HTTP status header and exit.
+        *
+        * @param integer $val         HTTP status result value
+        * @param array   $description optional message
+        *                             'title' => header title
+        *                             'description' => optional message
+        */
+       public static function httpExit($val, $description = [])
+       {
+               $err = '';
+               if ($val >= 400) {
+                       $err = 'Error';
+                       if (!isset($description["title"])) {
+                               $description["title"] = $err." ".$val;
+                       }
+               }
+
+               if ($val >= 200 && $val < 300) {
+                       $err = 'OK';
+               }
+
+               logger('http_status_exit ' . $val);
+               header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
+
+               if (isset($description["title"])) {
+                       $tpl = get_markup_template('http_status.tpl');
+                       echo replace_macros(
+                               $tpl,
+                               [
+                                       '$title' => $description["title"],
+                                       '$description' => $description["description"]]
+                       );
+               }
+
+               killme();
+       }
+
+       /**
+        * @brief Encodes content to json
+        *
+        * This function encodes an array to json format
+        * and adds an application/json HTTP header to the output.
+        * After finishing the process is getting killed.
+        *
+        * @param array $x The input content
+        */
+       public static function jsonExit($x)
+       {
+               header("content-type: application/json");
+               echo json_encode($x);
+               killme();
+       }
+
        /// @todo Move the following functions from boot.php
        /*
        function get_guid($size = 16, $prefix = "")
index efc5a097e827c3b77e8133fdb2773a58d7c38b37..485d070e30dd37dcc68e9e37db79b0c489169703 100644 (file)
@@ -3,8 +3,8 @@
 namespace Friendica\Module;\r
 \r
 use Friendica\BaseModule;\r
+use Friendica\Core\System;\r
 use Friendica\Protocol\OStatus;\r
-use Friendica\Util\Network;\r
 \r
 /**\r
  * Provides public Atom feeds\r
@@ -32,7 +32,7 @@ class Feed extends BaseModule
                $nocache     = x($_GET, 'nocache') && local_user();\r
 \r
                if ($a->argc < 2) {\r
-                       Network::httpStatusExit(400);\r
+                       System::httpExit(400);\r
                }\r
 \r
                $type = null;\r
index a6c74537d2b6d8358dab4b95e850c81c63f48446..86fdb2374cfb7a957d4da8a7eea0903755c1ffa1 100644 (file)
@@ -285,7 +285,7 @@ class Diaspora
 
                        if (!is_object($j_outer_key_bundle)) {
                                logger('Outer Salmon did not verify. Discarding.');
-                               Network::httpStatusExit(400);
+                               System::httpExit(400);
                        }
 
                        $outer_iv = base64_decode($j_outer_key_bundle->iv);
@@ -300,7 +300,7 @@ class Diaspora
 
                if (!is_object($basedom)) {
                        logger('Received data does not seem to be an XML. Discarding. '.$xml);
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
 
                $base = $basedom->children(NAMESPACE_SALMON_ME);
@@ -325,7 +325,7 @@ class Diaspora
                $verify = Crypto::rsaVerify($signed_data, $signature, $key);
                if (!$verify) {
                        logger('Message did not verify. Discarding.');
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
 
                return ['message' => (string)base64url_decode($base->data),
@@ -403,7 +403,7 @@ class Diaspora
 
                if (!$base) {
                        logger('unable to locate salmon data in xml');
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
 
 
@@ -441,7 +441,7 @@ class Diaspora
 
                if (!$author_link) {
                        logger('Could not retrieve author URI.');
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
                // Once we have the author URI, go to the web and try to find their public key
                // (first this will look it up locally if it is in the fcontact cache)
@@ -452,14 +452,14 @@ class Diaspora
 
                if (!$key) {
                        logger('Could not retrieve author key.');
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
 
                $verify = Crypto::rsaVerify($signed_data, $signature, $key);
 
                if (!$verify) {
                        logger('Message did not verify. Discarding.');
-                       Network::httpStatusExit(400);
+                       System::httpExit(400);
                }
 
                logger('Message verified.');
index b013f65a3df60c1cb6d1751de4bd3234d6adc208..ab1d44625c92a14aa3680b4162c85f06bc82b44b 100644 (file)
@@ -399,70 +399,6 @@ class Network
                return $body;
        }
 
-       /**
-        * Generic XML return
-        * Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
-        * of $st and an optional text <message> of $message and terminates the current process.
-        */
-       public static function xmlExit($st, $message = '')
-       {
-               $result = ['status' => $st];
-
-               if ($message != '') {
-                       $result['message'] = $message;
-               }
-
-               if ($st) {
-                       logger('xml_status returning non_zero: ' . $st . " message=" . $message);
-               }
-
-               header("Content-type: text/xml");
-
-               $xmldata = ["result" => $result];
-
-               echo XML::fromArray($xmldata, $xml);
-
-               killme();
-       }
-
-       /**
-        * @brief Send HTTP status header and exit.
-        *
-        * @param integer $val         HTTP status result value
-        * @param array   $description optional message
-        *                             'title' => header title
-        *                             'description' => optional message
-        */
-       public static function httpStatusExit($val, $description = [])
-       {
-               $err = '';
-               if ($val >= 400) {
-                       $err = 'Error';
-                       if (!isset($description["title"])) {
-                               $description["title"] = $err." ".$val;
-                       }
-               }
-
-               if ($val >= 200 && $val < 300) {
-                       $err = 'OK';
-               }
-
-               logger('http_status_exit ' . $val);
-               header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
-
-               if (isset($description["title"])) {
-                       $tpl = get_markup_template('http_status.tpl');
-                       echo replace_macros(
-                               $tpl,
-                               [
-                                       '$title' => $description["title"],
-                                       '$description' => $description["description"]]
-                       );
-               }
-
-               killme();
-       }
-
        /**
         * @brief Check URL to see if it's real
         *
@@ -858,22 +794,6 @@ class Network
                return $slinky->short();
        }
 
-       /**
-        * @brief Encodes content to json
-        *
-        * This function encodes an array to json format
-        * and adds an application/json HTTP header to the output.
-        * After finishing the process is getting killed.
-        *
-        * @param array $x The input content
-        */
-       public static function jsonExit($x)
-       {
-               header("content-type: application/json");
-               echo json_encode($x);
-               killme();
-       }
-
        /**
         * @brief Find the matching part between two url
         *