Rewrite from stelzi implemented, variable and function name renamed to match with...
authorRoland Häder <roland@mxchange.org>
Tue, 7 Apr 2009 20:28:02 +0000 (20:28 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Apr 2009 20:28:02 +0000 (20:28 +0000)
inc/functions.php
inc/libs/sponsor_functions.php
inc/modules/guest/what-register.php
inc/modules/member/what-mydata.php

index 7262baf0b705d1fad031146fbf42b482dcdac4dc..64e185bdec56a990499f7ae4018c482ea523da91 100644 (file)
@@ -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()
index 3db8ad7841761e759746b1b5478c141a616fcfc3..bc7a15d08f85b598a5bc87c367608cfe6b57321c 100644 (file)
@@ -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 {
index ea30251620eac9afdcd6df92894b141b1195d670..c856e14dd790119f9e780bffeccddd7ca58978a6 100644 (file)
@@ -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'));
index a9ce3466a403cad306656ff81342702329a4e9a3..07603834339cd12041d411bb2b255283e37d19c0 100644 (file)
@@ -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 {