Firefox PHP

email format validation changes...

Posted by caffiend 
email format validation changes...
July 20, 2003 09:35PM
Here are the changes to make sure that someone has submitted an email address in a valid format. I've got probably 50 users or so who unintentionally screwed up their profile.

It should be fine, but I haven't given it a solid test yet.

It's a unified diff, just copy it into your phorum directory and apply it under unix or with cygwin for windows.

patch -p1 < validate_email.diff

remove it with

patch -R -p1 < validate_email.diff

Attachments:
open | download - phorum-3.4.4email.diff.zip (2.5 KB)
Anonymous User
Re: email format validation changes...
July 22, 2003 01:29PM
without looking at the code ... what does it do?

Re: email format validation changes...
July 24, 2003 05:49PM
Nothing too tricky,

+ // check email address for correct syntax
+ function validate_email($email)
+ {
+ if(preg_match("/^.+@.+\..{2,3}$/", $email)){
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+ }

call the function in profile.php and added a new string to english.php to reflect the error

Anonymous User
Re: email format validation changes...
July 26, 2003 12:50PM
you surely know the function "is_email" which is in common.php?
its already used on posting to check if an email is valid.

Re: email format validation changes...
July 26, 2003 10:12PM
hmmm... apparently not.

I wrote it with 3.2 in mind and I had users who where able to change emails without syntax validation. As it stands now it looks like is_email() is not executed in 3.4.4 when the user edits their profile... I'll dig more...

Re: email format validation changes...
July 26, 2003 11:22PM
Thomas, does this make sense? I don't think that all the coffee in the world today would be enough...

in profile.php I added

// check for valid email syntax
if(!is_email($safe_email)){
$EditError=$lEmailSyntax;
}

and in register.php

if(!is_email($safe_email)){
$Error=$lEmailSyntax;
}else{
$SQL="select username, email from ".$pho_main."_auth where (upper(username)=upper('$safe_user') or upper(email)=upper('$safe_email'))";+ //run query
$q->query($DB,$SQL);
.......
.......
}

if so I'll post an updated patch....

Anonymous User
Re: email format validation changes...
July 27, 2003 01:23PM
it should be fine, just that I would put the check in both files some lines up, where already checks are made for censor and such.

Sorry, you do not have permission to post/reply in this forum.