aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-09-23 09:34:30 +0000
committermistic100 <mistic@piwigo.org>2012-09-23 09:34:30 +0000
commit7e33b84e770ddab61ef1d5c67061cd41c189f20e (patch)
tree6ffa8d888072108bcf05d0901fa22434dacecdc6 /include/functions.inc.php
parentb6d2db8600871cd72094a0c3043865b75357ef9b (diff)
feature 2754: Add "Email" field for user comments + mandatory "Author"
git-svn-id: http://piwigo.org/svn/trunk@18164 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php19
1 files changed, 19 insertions, 0 deletions
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