From aba34f84395913f333a6dcf6c6d5bc052b662670 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 7 Oct 2008 14:59:23 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSmail=20:=20input=20type=20text=20plutot?= =?UTF-8?q?=20qu'un=20select=20lorsqu'il=20y=20a=20qu'un=20seul=20mail=20?= =?UTF-8?q?=09propos=C3=A9=20-=20LSformRule=5Femail=20:=20possibilit=C3=A9?= =?UTF-8?q?=20de=20verifier=20si=20le=20domaine=20r=C3=A9pond=20=C3=A0=20u?= =?UTF-8?q?ne=20regex=20-=20checkEmail()=20:=20ajout=20d'un=20param=C3=A8t?= =?UTF-8?q?re=20en=20deuxi=C3=A8me=20position=20pour=20tester=20le=20=09do?= =?UTF-8?q?maine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/class/class.LSformRule_email.php | 2 +- trunk/includes/functions.php | 7 +++++-- trunk/templates/LSmail.tpl | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/trunk/includes/class/class.LSformRule_email.php b/trunk/includes/class/class.LSformRule_email.php index 40a292c4..b68d49d3 100644 --- a/trunk/includes/class/class.LSformRule_email.php +++ b/trunk/includes/class/class.LSformRule_email.php @@ -38,7 +38,7 @@ class LSformRule_email extends LSformRule { * @return boolean true si la valeur est valide, false sinon */ function validate($value,$option=array(),$formElement) { - return checkEmail($value,$option['param']['checkDomain']); + return checkEmail($value,$option['param']['domain'],$option['param']['checkDomain']); } } diff --git a/trunk/includes/functions.php b/trunk/includes/functions.php index 95d34945..b5c5961b 100644 --- a/trunk/includes/functions.php +++ b/trunk/includes/functions.php @@ -238,8 +238,11 @@ function LSdebug_print($return=false) { return $basedn; } - function checkEmail($value,$checkDns=true) { - $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\-]+))$/'; + 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.'$/'; if (!preg_match($regex, $value)) { LSdebug('checkEmail : regex fail'); diff --git a/trunk/templates/LSmail.tpl b/trunk/templates/LSmail.tpl index b2daad2f..b427f03f 100644 --- a/trunk/templates/LSmail.tpl +++ b/trunk/templates/LSmail.tpl @@ -2,9 +2,13 @@
{$LSmail_mail_label}
{if $LSmail_mails != ""} + {if $LSmail_mails|@count==1} + + {else} + {/if} {else} {/if}