mirror of
https://github.com/friendica/friendica
synced 2024-11-13 02:22:53 +00:00
Add allowed_domain generic function
This commit is contained in:
parent
00d369a65d
commit
3494663c15
1 changed files with 25 additions and 12 deletions
|
@ -613,24 +613,37 @@ function allowed_email($email)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_allowed = Config::get('system', 'allowed_email');
|
$str_allowed = Config::get('system', 'allowed_email', '');
|
||||||
if (! $str_allowed) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$found = false;
|
|
||||||
|
|
||||||
$fnmatch = function_exists('fnmatch');
|
|
||||||
$allowed = explode(',', $str_allowed);
|
$allowed = explode(',', $str_allowed);
|
||||||
|
|
||||||
if (count($allowed)) {
|
return allowed_domain($domain, $allowed);
|
||||||
foreach ($allowed as $a) {
|
}
|
||||||
$pat = strtolower(trim($a));
|
|
||||||
if (($fnmatch && fnmatch($pat, $domain)) || ($pat == $domain)) {
|
/**
|
||||||
|
* 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($domain_list)) {
|
||||||
|
foreach ($domain_list as $item) {
|
||||||
|
$pat = strtolower(trim($item));
|
||||||
|
if (fnmatch($pat, $domain) || ($pat == $domain)) {
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif(!$strict) {
|
||||||
|
$found = true;
|
||||||
}
|
}
|
||||||
return $found;
|
return $found;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue