]> git.mxchange.org Git - friendica.git/commitdiff
Move multiple functions
authorAdam Magness <adam.magness@gmail.com>
Sat, 27 Jan 2018 04:51:41 +0000 (23:51 -0500)
committerAdam Magness <adam.magness@gmail.com>
Sat, 27 Jan 2018 04:51:41 +0000 (23:51 -0500)
move multiple smaller functions

include/network.php
mod/dfrn_request.php
mod/dirfind.php
mod/settings.php
src/Content/OEmbed.php
src/Model/Contact.php
src/Model/Profile.php
src/Model/User.php
src/Module/Login.php
src/Network/Probe.php
src/Util/Network.php

index 726eac757062b7d758bda7af11cce250a0c1559e..840991aa527b785083e11feee25205574e9d801a 100644 (file)
@@ -12,42 +12,6 @@ use Friendica\Object\Image;
 use Friendica\Util\Network;
 use Friendica\Util\XML;
 
-function validate_url($url)
-{
-       return Network::validateURL($url);
-}
-
-function validate_email($addr)
-{
-       return Network::validateEmail($addr);
-}
-
-function allowed_url($url)
-{
-       return Network::allowedURL($url);
-}
-
-function blocked_url($url)
-{
-       return Network::blockedURL($url);
-}
-
-function allowed_email($email)
-{
-       return Network::allowedEmail($email);
-}
-
-function allowed_domain($domain, array $domain_list)
-{
-       return Network::allowedDomain($domain, $domain_list);
-}
-
-function avatar_img($email)
-{
-       return Network::avatarImg($email);
-}
-
-
 function parse_xml_string($s, $strict = true)
 {
        return Network::parseXmlString($s, $strict);
index 18a6eefaf250ad3d824c6188d219106284bac88c..1d3e4cd8f6dfb76812f22bc6058955372a5679c3 100644 (file)
@@ -332,20 +332,20 @@ function dfrn_request_post(App $a)
                                        intval($contact_record['id'])
                                );
                        } else {
-                               $url = validate_url($url);
+                               $url = Network::validateURL($url);
                                if (!$url) {
                                        notice(L10n::t('Invalid profile URL.') . EOL);
                                        goaway(System::baseUrl() . '/' . $a->cmd);
                                        return; // NOTREACHED
                                }
 
-                               if (!allowed_url($url)) {
+                               if (!Network::allowedURL($url)) {
                                        notice(L10n::t('Disallowed profile URL.') . EOL);
                                        goaway(System::baseUrl() . '/' . $a->cmd);
                                        return; // NOTREACHED
                                }
 
-                               if (blocked_url($url)) {
+                               if (Network::blockedURL($url)) {
                                        notice(L10n::t('Blocked domain') . EOL);
                                        goaway(System::baseUrl() . '/' . $a->cmd);
                                        return; // NOTREACHED
index c010aaac92480ee1945923d78bd7851fbcedc292..f08e723bae02c6a0819256aa01da90435c425898 100644 (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) && validate_email($search)) ||
+               if ((valid_email($search) && Network::validateEmail($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]));
index 5b4bd903ece5ed66ea510192427f4887a26cf217..a6ffd99e992ef4e13ba9108d8426852ec4598d44 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Model\GContact;
 use Friendica\Model\Group;
 use Friendica\Model\User;
 use Friendica\Protocol\Email;
+use Friendica\Util\Network;
 
 function get_theme_config_file($theme)
 {
@@ -535,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 (validate_url($openid)) {
+               if (Network::validateURL($openid)) {
                        logger('updating openidserver');
                        require_once 'library/openid.php';
                        $open_id_obj = new LightOpenID;
index 80fab8c647a5d320b32eb9bc432d31a3b3f2ac41..1ddd3e65c621ed8d5f4924364ce2dabd2527c643 100644 (file)
@@ -312,7 +312,7 @@ class OEmbed
 
                $allowed = explode(',', $str_allowed);
 
-               return allowed_domain($domain, $allowed);
+               return Network::allowedDomain($domain, $allowed);
        }
 
        public static function getHTML($url, $title = null)
index acdb4815e6b2374c4dcd64a331a632c46fcfe661..bda5a925f51b03f0fdc92fa9d112baaa7e05281a 100644 (file)
@@ -20,6 +20,7 @@ use Friendica\Protocol\DFRN;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\PortableContact;
 use Friendica\Protocol\Salmon;
+use Friendica\Util\Network;
 use dba;
 
 require_once 'boot.php';
@@ -1131,12 +1132,12 @@ class Contact extends BaseObject
                // remove ajax junk, e.g. Twitter
                $url = str_replace('/#!/', '/', $url);
 
-               if (!allowed_url($url)) {
+               if (!Network::allowedURL($url)) {
                        $result['message'] = L10n::t('Disallowed profile URL.');
                        return $result;
                }
 
-               if (blocked_url($url)) {
+               if (Network::blockedURL($url)) {
                        $result['message'] = L10n::t('Blocked domain');
                        return $result;
                }
index 8e32f60aec24b59a66dda78bcaf108387e30afd8..c77b6bbe442c31629e107570e41d306bc20cef6a 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Protocol\Diaspora;
+use Friendica\Util\Network;
 use dba;
 
 require_once 'include/dba.php';
@@ -963,7 +964,7 @@ class Profile
        public static function zrlInit(App $a)
        {
                $my_url = self::getMyURL();
-               $my_url = validate_url($my_url);
+               $my_url = Network::validateURL($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
index ecd1040b7562b69435842e8d66cbe538889a805d..bc14098d40145c73849617b8cd2791881fda9dbc 100644 (file)
@@ -282,7 +282,7 @@ class User
 
                if (!x($username) || !x($email) || !x($nickname)) {
                        if ($openid_url) {
-                               if (!validate_url($openid_url)) {
+                               if (!Network::validateURL($openid_url)) {
                                        throw new Exception(L10n::t('Invalid OpenID url'));
                                }
                                $_SESSION['register'] = 1;
@@ -305,7 +305,7 @@ class User
                        throw new Exception(L10n::t('Please enter the required information.'));
                }
 
-               if (!validate_url($openid_url)) {
+               if (!Network::validateURL($openid_url)) {
                        $openid_url = '';
                }
 
@@ -330,11 +330,11 @@ class User
                        }
                }
 
-               if (!allowed_email($email)) {
+               if (!Network::allowedEmail($email)) {
                        throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
                }
 
-               if (!valid_email($email) || !validate_email($email)) {
+               if (!valid_email($email) || !Network::validateEmail($email)) {
                        throw new Exception(L10n::t('Not a valid email address.'));
                }
 
@@ -461,7 +461,7 @@ class User
 
                // if we have no OpenID photo try to look up an avatar
                if (!strlen($photo)) {
-                       $photo = avatar_img($email);
+                       $photo = Network::avatarImg($email);
                }
 
                // unless there is no avatar-addon loaded
index fdfa6623fe2dafbc9679b233e1ba4ab0c9ea0ae3..c6396a4148e1bda0af1cc92d098f961b9d1ff7f0 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Database\DBM;
 use Friendica\Model\User;
+use Friendica\Util\Network;
 use dba;
 
 require_once 'boot.php';
@@ -59,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, '@') || !validate_url($openid_url)) {
+                       if ($noid || strpos($openid_url, '@') || !Network::validateURL($openid_url)) {
                                notice(L10n::t('Login failed.') . EOL);
                                goaway(self::getApp()->get_baseurl());
                                // NOTREACHED
index 94fd929e107b1c4d52575d42011e23d4c48e28ec..e3130a4d753991e322b9df579fd1d6550fa4f835 100644 (file)
@@ -1510,7 +1510,7 @@ class Probe
         */
        private static function mail($uri, $uid)
        {
-               if (!validate_email($uri)) {
+               if (!Network::validateEmail($uri)) {
                        return false;
                }
 
@@ -1544,7 +1544,7 @@ class Probe
                $data["network"] = NETWORK_MAIL;
                $data["name"]    = substr($uri, 0, strpos($uri, '@'));
                $data["nick"]    = $data["name"];
-               $data["photo"]   = avatar_img($uri);
+               $data["photo"]   = Network::avatarImg($uri);
                $data["url"]     = 'mailto:'.$uri;
                $data["notify"]  = 'smtp '.random_string();
                $data["poll"]    = 'email '.random_string();
index e0400c7f0ab132bc8e11f16506dee1a4264300ec..cc796c5f7a00ca1587c8f966d647f9841da800a6 100644 (file)
@@ -79,7 +79,7 @@ class Network
 
                $a = get_app();
 
-               if (blocked_url($url)) {
+               if (self::blockedURL($url)) {
                        logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
                        return $ret;
                }
@@ -281,7 +281,7 @@ class Network
        {
                $stamp1 = microtime(true);
 
-               if (blocked_url($url)) {
+               if (self::blockedURL($url)) {
                        logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
                        return false;
                }
@@ -622,7 +622,7 @@ class Network
 
                $allowed = explode(',', $str_allowed);
 
-               return allowed_domain($domain, $allowed);
+               return self::allowedDomain($domain, $allowed);
        }
 
        /**