mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +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) {
|
function checkEmail($value,$domain=NULL,$checkDns=true) {
|
||||||
if (!$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\-]+))$/';
|
||||||
$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.'$/';
|
|
||||||
|
|
||||||
if (!preg_match($regex, $value)) {
|
if (!preg_match($regex, $value)) {
|
||||||
LSdebug('checkEmail : regex fail');
|
LSdebug('checkEmail : regex fail');
|
||||||
return false;
|
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')) {
|
if ($checkDns && function_exists('checkdnsrr')) {
|
||||||
$tokens = explode('@', $value);
|
if (!(checkdnsrr($nd, 'MX') || checkdnsrr($nd, 'A'))) {
|
||||||
if (!(checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A'))) {
|
|
||||||
LSdebug('checkEmail : DNS fail');
|
LSdebug('checkEmail : DNS fail');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue