}
// Taken from www.php.net eregi() user comments
-function VALIDATE_EMAIL ($email) {
+function isEmailValid ($email) {
// Compile email
$email = COMPILE_CODE($email);
// Check first part of email address
- $first = "[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*";
+ $first = '[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*';
// Check domain
- $domain = "[a-z0-9-]+(\.[a-z0-9-]{2,5})+";
+ $domain = '[a-z0-9-]+(\.[a-z0-9-]{2,5})+';
// Generate pattern
- $regex = '^'.$first.'@'.$domain.'$';
+ $regex = '@^' . $first . '\@' . $domain . '$@iU';
// Return check result
- // @TODO eregi() should be rewritten here
- return eregi($regex, $email);
+ // @NOTE altered the regex-pattern and added modificator i (match both upper and lower case letters) and U (PCRE_UNGREEDY) to work with preg_match the same way as eregi
+ return preg_match($regex, $email);
}
// Function taken from user comments on www.php.net / function eregi()
global $DATA;
// Initialize variables
-$FAILED = false; $SHORT_PASS = false; $cats = 0; $IP_TIMEOUT = false;
+$isFailed = false; $SHORT_PASS = false; $cats = 0; $IP_TIMEOUT = false;
if (!IS_FORM_SENT()) REQUEST_UNSET_POST('ok');
// Did he agree to our Terms Of Usage?
if (REQUEST_POST('agree') != 'Y') {
REQUEST_SET_POST('agree', '!');
- $FAILED = true;
+ $isFailed = true;
} // END - if
// Did he enter a valid email address? (we really don't care about
// that, he has to click on a confirmation link :P )
- if ((!REQUEST_ISSET_POST(('addy'))) || (!VALIDATE_EMAIL(REQUEST_POST('addy')))) {
+ if ((!REQUEST_ISSET_POST(('addy'))) || (!isEmailValid(REQUEST_POST('addy')))) {
REQUEST_SET_POST('addy', '!');
- $FAILED = true;
+ $isFailed = true;
} // END - if
// And what about surname and family's name?
if (!REQUEST_ISSET_POST(('surname'))) {
REQUEST_SET_POST('surname', '!');
- $FAILED = true;
+ $isFailed = true;
} // END - if
if (!REQUEST_ISSET_POST(('family'))) {
REQUEST_SET_POST('family', '!');
- $FAILED = true;
+ $isFailed = true;
} // END - if
// Check for required fields
- if (!$FAILED) $FAILED = REGISTER_CHECK_REQUIRED_FIELDS(REQUEST_POST_ARRAY());
+ if ($isFailed === false) $isFailed = REGISTER_CHECK_REQUIRED_FIELDS(REQUEST_POST_ARRAY());
// Did he enter his password twice?
if (((!REQUEST_ISSET_POST(('pass1'))) || (!REQUEST_ISSET_POST(('pass2')))) || ((REQUEST_POST('pass1') != REQUEST_POST('pass2')) && (REQUEST_ISSET_POST(('pass1'))) && (REQUEST_ISSET_POST(('pass2'))))) {
if (!REQUEST_ISSET_POST(('pass1'))) { REQUEST_SET_POST('pass1', '!'); } else { REQUEST_SET_POST('pass1', ''); }
if (!REQUEST_ISSET_POST(('pass2'))) { REQUEST_SET_POST('pass2', '!'); } else { REQUEST_SET_POST('pass2', ''); }
}
- $FAILED = true;
+ $isFailed = true;
} // END - if
// Is the password long enouth?
- if ((strlen(REQUEST_POST('pass1')) < getConfig('pass_len')) && (!$FAILED)) {
+ if ((strlen(REQUEST_POST('pass1')) < getConfig('pass_len')) && ($isFailed === false)) {
$SHORT_PASS = true;
- $FAILED = true;
+ $isFailed = true;
} // END - if
// No admin? Admins can always register!
if ($cats < getConfig('least_cats')) {
// ... nope!
- $FAILED = true;
+ $isFailed = true;
} // END - if
} // END - if
$CHK = isEmailTaken(REQUEST_POST('addy'));
if ($CHK === true) {
REQUEST_SET_POST('addy', '?');
- $FAILED = true;
+ $isFailed = true;
} // END - if
} // END - if
// Same IP in timeout range and different email address entered... Eat this, faker! ;-)
// But admins are allowed to fake their own exchange service.
$IP_TIMEOUT = true;
- $FAILED = true;
+ $isFailed = true;
} // END - if
} // END - if
SQL_FREERESULT($result);
}
-if ((IS_FORM_SENT()) && ((!$FAILED) || (IS_ADMIN()))) {
+if ((IS_FORM_SENT()) && (($isFailed === false) || (IS_ADMIN()))) {
// Prepapre month and day of birth
if (strlen(REQUEST_POST('day')) == 1) REQUEST_SET_POST('day' , '0'.REQUEST_POST('day'));
if (strlen(REQUEST_POST('month')) == 1) REQUEST_SET_POST('month', '0'.REQUEST_POST('month'));