Thought it best to add the email validate now

git-svn-id: file:///svn/phpbb/trunk@931 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-08-24 15:47:14 +00:00
parent 8723edc8c8
commit 1330d26720
3 changed files with 60 additions and 22 deletions

View file

@ -454,6 +454,52 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
} }
//
// Check to see if email address is banned
// or already present in the DB
//
function validate_email($email)
{
global $db;
if($email != "")
{
$sql = "SELECT ban_email
FROM " . BANLIST_TABLE;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain email ban information.", "", __LINE__, __FILE__, $sql);
}
$ban_email_list = $db->sql_fetchrowset($result);
for($i = 0; $i < count($ban_email_list); $i++)
{
$match_email = str_replace("*@", ".*@", $ban_email_list[$i]['ban_email']);
if( preg_match("/^" . $match_email . "$/is", $email) )
{
return(0);
}
}
$sql = "SELECT user_email
FROM " . USERS_TABLE . "
WHERE user_email = '" . $email . "'";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain user email information.", "", __LINE__, __FILE__, $sql);
}
$email_taken = $db->sql_fetchrow($result);
if($email_taken['user_email'] != "")
{
return(0);
}
return(1);
}
else
{
return(0);
}
}
// //
// Check to see if the username has been taken, or if it is disallowed. // Check to see if the username has been taken, or if it is disallowed.
// Used for registering, changing names, and posting anonymously with a username // Used for registering, changing names, and posting anonymously with a username

View file

@ -377,7 +377,7 @@ $lang['of_total'] = "of total"; // follows percentage of total posts
$lang['Wrong_Profile'] = "You cannot modify a profile that is not your own."; $lang['Wrong_Profile'] = "You cannot modify a profile that is not your own.";
$lang['Bad_username'] = "The username you choose has been taken or is disallowed by the administrator."; $lang['Bad_username'] = "The username you choose has been taken or is disallowed by the administrator.";
$lang['Sorry_banned_email'] = "Sorry but the email address you gave has been banned from registering on this system."; $lang['Sorry_banned_or_taken_email'] = "Sorry but the email address you gave has either been banned or is already registered to another user. You may try an alternative address, if that is also banned then you should contact the board administrator for advice.";
$lang['Only_one_avatar'] = "Only one type of avatar can be specified"; $lang['Only_one_avatar'] = "Only one type of avatar can be specified";
$lang['File_no_data'] = "The file at the URL you gave contains no data"; $lang['File_no_data'] = "The file at the URL you gave contains no data";
$lang['No_connection_URL'] = "A connection could not be made to the URL you gave"; $lang['No_connection_URL'] = "A connection could not be made to the URL you gave";

View file

@ -322,27 +322,6 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
// //
// Do a ban check on this email address // Do a ban check on this email address
// //
$sql = "SELECT ban_email
FROM " . BANLIST_TABLE;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain email ban information.", "", __LINE__, __FILE__, $sql);
}
$ban_email_list = $db->sql_fetchrowset($result);
for($i = 0; $i < count($ban_email_list); $i++)
{
$match_email = str_replace("*@", ".*@", $ban_email_list[$i]['ban_email']);
if( preg_match("/^" . $match_email . "$/is", $email) )
{
$error = TRUE;
if(isset($error_msg))
{
$error_msg .= "<br />";
}
$error_msg .= $lang['Sorry_banned_email'];
}
}
if(!empty($password) && !empty($password_confirm)) if(!empty($password) && !empty($password_confirm))
{ {
// Awww, the user wants to change their password, isn't that cute.. // Awww, the user wants to change their password, isn't that cute..
@ -363,6 +342,19 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
$error_msg = $lang['Password_mismatch']; $error_msg = $lang['Password_mismatch'];
} }
if($email != $userdata['user_email'] || $mode == "register")
{
if(!validate_email($email))
{
$error = TRUE;
if(isset($error_msg))
{
$error_msg .= "<br />";
}
$error_msg .= $lang['Sorry_banned_or_taken_email'];
}
}
if($board_config['allow_namechange'] || $mode == "register") if($board_config['allow_namechange'] || $mode == "register")
{ {
if($username != $userdata['username'] || $mode == "register") if($username != $userdata['username'] || $mode == "register")