mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
- checkEmail : Ajout de la possibilité de vérifier le nom de domaine par un
ou plusieurs.
This commit is contained in:
parent
52ede7e6f7
commit
38b8884ea6
1 changed files with 18 additions and 6 deletions
|
@ -316,19 +316,31 @@ function LSdebugDefined() {
|
|||
}
|
||||
|
||||
function checkEmail($value,$domain=NULL,$checkDns=true) {
|
||||
if (!$domain) {
|
||||
$domain = '((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))';
|
||||
}
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@'.$domain.'$/';
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
||||
|
||||
if (!preg_match($regex, $value)) {
|
||||
LSdebug('checkEmail : regex fail');
|
||||
return false;
|
||||
}
|
||||
|
||||
$nd = explode('@', $value);
|
||||
$nd=$nd[1];
|
||||
|
||||
if ($domain) {
|
||||
if(is_array($domain)) {
|
||||
if (!in_array($nd,$domain)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($nd!=$domain) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($checkDns && function_exists('checkdnsrr')) {
|
||||
$tokens = explode('@', $value);
|
||||
if (!(checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A'))) {
|
||||
if (!(checkdnsrr($nd, 'MX') || checkdnsrr($nd, 'A'))) {
|
||||
LSdebug('checkEmail : DNS fail');
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue