aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
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