From 116f17077ae6fa32c7373ccd6aaf94044bb6c276 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 7 Apr 2009 20:28:02 +0000 Subject: [PATCH] Rewrite from stelzi implemented, variable and function name renamed to match with naming convention --- inc/functions.php | 12 ++++++------ inc/libs/sponsor_functions.php | 2 +- inc/modules/guest/what-register.php | 28 ++++++++++++++-------------- inc/modules/member/what-mydata.php | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7262baf0b7..64e185bdec 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1964,22 +1964,22 @@ function sendRawRequest ($host, $request) { } // 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() diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 3db8ad7841..bc7a15d08f 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -69,7 +69,7 @@ function SPONSOR_HANDLE_SPONSOR (&$POST, $NO_UPDATE=false, $messageArray=array() { case 'email': $ALREADY = false; - if (!VALIDATE_EMAIL($v)) { + if (!isEmailValid($v)) { // Email address is not valid $SAVE = false; } else { diff --git a/inc/modules/guest/what-register.php b/inc/modules/guest/what-register.php index ea30251620..c856e14dd7 100644 --- a/inc/modules/guest/what-register.php +++ b/inc/modules/guest/what-register.php @@ -51,7 +51,7 @@ ADD_DESCR('guest', __FILE__); 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'); @@ -96,28 +96,28 @@ if (IS_FORM_SENT()) { // 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'))))) { @@ -128,13 +128,13 @@ if (IS_FORM_SENT()) { 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! @@ -146,7 +146,7 @@ if (IS_FORM_SENT()) { if ($cats < getConfig('least_cats')) { // ... nope! - $FAILED = true; + $isFailed = true; } // END - if } // END - if @@ -155,7 +155,7 @@ if (IS_FORM_SENT()) { $CHK = isEmailTaken(REQUEST_POST('addy')); if ($CHK === true) { REQUEST_SET_POST('addy', '?'); - $FAILED = true; + $isFailed = true; } // END - if } // END - if @@ -168,7 +168,7 @@ if (IS_FORM_SENT()) { // 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 @@ -176,7 +176,7 @@ if (IS_FORM_SENT()) { 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')); diff --git a/inc/modules/member/what-mydata.php b/inc/modules/member/what-mydata.php index a9ce3466a4..0760383433 100644 --- a/inc/modules/member/what-mydata.php +++ b/inc/modules/member/what-mydata.php @@ -199,7 +199,7 @@ case 'save': // Save entered data $DATA[3] = generateDateTime($DATA[3] + getConfig('profile_lock'), '0'); // You cannot change your account LOAD_TEMPLATE("member_mydata_locked"); - } elseif (!VALIDATE_EMAIL(REQUEST_POST('addy'))) { + } elseif (!isEmailValid(REQUEST_POST('addy'))) { // Invalid email address! LOAD_TEMPLATE('admin_settings_saved', false, getMessage('INVALID_EMAIL_ADDRESS_ENTERED')); } else { -- 2.39.5