]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
Merge pull request #4195 from zeroadam/ContactSelector-#3878
[friendica.git] / include / network.php
index be5519d5c6d68de20da80c827247374d87682e9f..413048d5b8057992d731b5e489b7ba8bfb8be02a 100644 (file)
@@ -232,8 +232,6 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
        $a->set_curl_code($http_code);
        $a->set_curl_content_type($curl_info['content_type']);
 
-       $body = substr($s, strlen($header));
-
        $rc = intval($http_code);
        $ret['return_code'] = $rc;
        $ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
@@ -611,29 +609,40 @@ function blocked_url($url)
 function allowed_email($email)
 {
        $domain = strtolower(substr($email, strpos($email, '@') + 1));
-       if (! $domain) {
+       if (!$domain) {
                return false;
        }
 
-       $str_allowed = Config::get('system', 'allowed_email');
-       if (! $str_allowed) {
+       $str_allowed = Config::get('system', 'allowed_email', '');
+       if (!x($str_allowed)) {
                return true;
        }
 
-       $found = false;
-
-       $fnmatch = function_exists('fnmatch');
        $allowed = explode(',', $str_allowed);
 
-       if (count($allowed)) {
-               foreach ($allowed as $a) {
-                       $pat = strtolower(trim($a));
-                       if (($fnmatch && fnmatch($pat, $domain)) || ($pat == $domain)) {
-                               $found = true;
-                               break;
-                       }
+       return allowed_domain($domain, $allowed);
+}
+
+/**
+ * Checks for the existence of a domain in a domain list
+ *
+ * @brief Checks for the existence of a domain in a domain list
+ * @param string $domain
+ * @param array  $domain_list
+ * @return boolean
+ */
+function allowed_domain($domain, array $domain_list)
+{
+       $found = false;
+
+       foreach ($domain_list as $item) {
+               $pat = strtolower(trim($item));
+               if (fnmatch($pat, $domain) || ($pat == $domain)) {
+                       $found = true;
+                       break;
                }
        }
+
        return $found;
 }
 
@@ -680,8 +689,6 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
                $include_link = false;
        }
 
-       $a = get_app();
-
        // Picture addresses can contain special characters
        $s = htmlspecialchars_decode($srctext);
 
@@ -855,7 +862,6 @@ function original_url($url, $depth = 1, $fetchbody = false)
 
        $stamp1 = microtime(true);
 
-       $siteinfo = array();
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
@@ -864,7 +870,7 @@ function original_url($url, $depth = 1, $fetchbody = false)
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
 
-       $header = curl_exec($ch);
+       curl_exec($ch);
        $curl_info = @curl_getinfo($ch);
        $http_code = $curl_info['http_code'];
        curl_close($ch);
@@ -936,7 +942,6 @@ function original_url($url, $depth = 1, $fetchbody = false)
                if (@$attr["http-equiv"] == 'refresh') {
                        $path = $attr["content"];
                        $pathinfo = explode(";", $path);
-                       $content = "";
                        foreach ($pathinfo as $value) {
                                if (substr(strtolower($value), 0, 4) == "url=") {
                                        return(original_url(substr($value, 4), ++$depth));
@@ -945,7 +950,7 @@ function original_url($url, $depth = 1, $fetchbody = false)
                }
        }
 
-       return($url);
+       return $url;
 }
 
 function short_link($url)