From 7e33b84e770ddab61ef1d5c67061cd41c189f20e Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sun, 23 Sep 2012 09:34:30 +0000 Subject: feature 2754: Add "Email" field for user comments + mandatory "Author" git-svn-id: http://piwigo.org/svn/trunk@18164 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/functions.inc.php') diff --git a/include/functions.inc.php b/include/functions.inc.php index f94aad480..0be5ec9ef 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1725,4 +1725,23 @@ function url_check_format($url) return (bool)preg_match('@^https?://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS', $url); } } + +/** + * check email format + */ +function email_check_format($mail_address) +{ + if (version_compare(PHP_VERSION, '5.2.0') >= 0) + { + return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false; + } + else + { + $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase + $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name + $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; + + return (bool)preg_match($regex, $mail_address); + } +} ?> \ No newline at end of file -- cgit v1.2.3