aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-05-05 16:59:55 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-05-29 02:14:41 +0200
commit911725a5812cff5c1a0daa37b99767b5144e8a11 (patch)
treec8f51379a43a7ea6ab7011380005d29f078eb4e3 /phpBB/includes
parentf01e0a2eef0604367620e8b9aa323f3feb86ea3c (diff)
downloadforums-911725a5812cff5c1a0daa37b99767b5144e8a11.tar
forums-911725a5812cff5c1a0daa37b99767b5144e8a11.tar.gz
forums-911725a5812cff5c1a0daa37b99767b5144e8a11.tar.bz2
forums-911725a5812cff5c1a0daa37b99767b5144e8a11.tar.xz
forums-911725a5812cff5c1a0daa37b99767b5144e8a11.zip
[ticket/10073] Split email validation from email ban and taken checks
PHPBB3-10073
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_users.php2
-rw-r--r--phpBB/includes/functions_user.php45
-rw-r--r--phpBB/includes/ucp/ucp_profile.php2
-rw-r--r--phpBB/includes/ucp/ucp_register.php2
4 files changed, 38 insertions, 13 deletions
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index b653ddd13b..83ab88d48c 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -814,7 +814,7 @@ class acp_users
$check_ary += array(
'email' => array(
array('string', false, 6, 60),
- array('email', $user_row['user_email'])
+ array('user_email', $user_row['user_email']),
),
);
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 3dcb32350e..fafe29f957 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1746,25 +1746,21 @@ function validate_password($password)
}
/**
-* Check to see if email address is banned or already present in the DB
+* Check to see if email address is a valid address and contains a MX record
*
* @param string $email The email to check
-* @param string $allowed_email An allowed email, default being $user->data['user_email']
*
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/
-function validate_email($email, $allowed_email = false)
+function phpbb_validate_email($email, $config = null)
{
- global $config, $db, $user;
-
- $email = strtolower($email);
- $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
-
- if ($allowed_email == $email)
+ if ($config === null)
{
- return false;
+ global $config;
}
+ $email = strtolower($email);
+
if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email))
{
return 'EMAIL_INVALID';
@@ -1782,6 +1778,35 @@ function validate_email($email, $allowed_email = false)
}
}
+ return false;
+}
+
+/**
+* Check to see if email address is banned or already present in the DB
+*
+* @param string $email The email to check
+* @param string $allowed_email An allowed email, default being $user->data['user_email']
+*
+* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
+*/
+function validate_user_email($email, $allowed_email = false)
+{
+ global $config, $db, $user;
+
+ $email = strtolower($email);
+ $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
+
+ if ($allowed_email == $email)
+ {
+ return false;
+ }
+
+ $validate_email = phpbb_validate_email($email, $config);
+ if ($validate_email)
+ {
+ return $validate_email;
+ }
+
if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
{
return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index c7ed12f4ee..5ba5f1e830 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -66,7 +66,7 @@ class ucp_profile
'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
'email' => array(
array('string', false, 6, 60),
- array('email')),
+ array('user_email')),
);
if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index cdd5532429..97934fc32d 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -211,7 +211,7 @@ class ucp_register
'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']),
'email' => array(
array('string', false, 6, 60),
- array('email')),
+ array('user_email')),
'tz' => array('timezone'),
'lang' => array('language_iso_name'),
));