]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
Merge pull request #4167 from MrPetovan/bug/4155-remove-proxy-oembed
[friendica.git] / include / network.php
index be5519d5c6d68de20da80c827247374d87682e9f..bd64ab3508c45c2bb1222a6897907fa990c78483 100644 (file)
@@ -615,24 +615,37 @@ function allowed_email($email)
                return false;
        }
 
-       $str_allowed = Config::get('system', 'allowed_email');
-       if (! $str_allowed) {
-               return true;
-       }
+       $str_allowed = Config::get('system', 'allowed_email', '');
+       $allowed = explode(',', $str_allowed);
 
-       $found = false;
+       return allowed_domain($domain, $allowed);
+}
 
-       $fnmatch = function_exists('fnmatch');
-       $allowed = explode(',', $str_allowed);
+/**
+ * Checks for the existence of a domain in a domain list
+ *
+ * If strict is not set, an empty domain list counts as found
+ *
+ * @brief Checks for the existence of a domain in a domain list
+ * @param string $domain
+ * @param array $domain_list
+ * @param bool   $strict
+ * @return boolean
+ */
+function allowed_domain($domain, array $domain_list, $strict = false)
+{
+       $found = false;
 
-       if (count($allowed)) {
-               foreach ($allowed as $a) {
-                       $pat = strtolower(trim($a));
-                       if (($fnmatch && fnmatch($pat, $domain)) || ($pat == $domain)) {
+       if (count($domain_list)) {
+               foreach ($domain_list as $item) {
+                       $pat = strtolower(trim($item));
+                       if (fnmatch($pat, $domain) || ($pat == $domain)) {
                                $found = true;
                                break;
                        }
                }
+       } elseif(!$strict) {
+               $found = true;
        }
        return $found;
 }