]> git.mxchange.org Git - mailer.git/commitdiff
Fixes for mydata
authorRoland Häder <roland@mxchange.org>
Wed, 28 Oct 2009 19:44:55 +0000 (19:44 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 28 Oct 2009 19:44:55 +0000 (19:44 +0000)
inc/filter-functions.php
inc/filters.php
inc/modules/guest/what-register.php
inc/modules/member/what-mydata.php
inc/mysql-connect.php

index dca5b9ec6cff5fa9a013f1e610180f905c8194ce..d76cad43ed1d8bc42b7c02d03ebe2e276f5311fb 100644 (file)
@@ -123,6 +123,7 @@ ORDER BY
        registerFilter('init', 'CHECK_SVN_REVISION');
        registerFilter('init', 'RUN_DAILY_RESET');
        registerFilter('init', 'INIT_RANDOMIZER');
+       registerFilter('init', 'INIT_RANDOM_NUMBER');
        registerFilter('init', 'TRIGGER_SENDING_POOL');
        registerFilter('init', 'DETERMINE_USERNAME');
        registerFilter('init', 'DETERMINE_WHAT_ACTION');
index c90cdea9be9e0a8415ab65e87fb65a53da0e35fa..1b7eb19dae2e94f9a2dd606c71f265bb96cd59b7 100644 (file)
@@ -681,5 +681,20 @@ function FILTER_CHECK_ADMIN_ACL () {
        $GLOBALS['acl_allow'] = $ret;
 }
 
+// Init random number/cache buster
+function FILTER_INIT_RANDOM_NUMBER () {
+       // Is the extension sql_patches installed and at least 0.3.6?
+       if ((isExtensionActive('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6')) {
+               // Generate random number
+               setConfigEntry('RAND_NUMBER', generateRandomCode(10, mt_rand(10000, 32766), getUserId(), ''));
+       } else {
+               // Generate weak (!!!) code
+               setConfigEntry('RAND_NUMBER', mt_rand(1000000, 9999999));
+       }
+
+       // Copy it to CACHE_BUSTER
+       setConfigEntry('CACHE_BUSTER', getConfig('RAND_NUMBER'));
+}
+
 // [EOF]
 ?>
index ee33a91fde18c9784eaad0d6c6369896ad9a204c..cbd1d658eda07588e1ec316f8434eb6d3b052292 100644 (file)
@@ -53,7 +53,7 @@ if (!isExtensionActive('register')) {
 }
 
 // Initialize variables
-$isFailed   = false;
+$isOkay     = true;
 $shortPass  = false;
 $cats       = 0;
 $ipTimedOut = false;
@@ -83,31 +83,31 @@ if (isFormSent()) {
        // Did he agree to our Terms Of Usage?
        if (postRequestElement('agree') != 'Y') {
                setRequestPostElement('agree', '!');
-               $isFailed = true;
+               $isOkay = false;
        } // 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 ((!isPostRequestElementSet('email')) || (!isEmailValid(postRequestElement('email')))) {
                setRequestPostElement('email', '!');
-               $isFailed = true;
+               $isOkay = false;
        } // END - if
 
        // And what about surname and family's name?
        if (!isPostRequestElementSet('surname')) {
                setRequestPostElement('surname', '!');
-               $isFailed = true;
+               $isOkay = false;
        } // END - if
        if (!isPostRequestElementSet('family')) {
                setRequestPostElement('family', '!');
-               $isFailed = true;
+               $isOkay = false;
        } // END - if
 
        // Get temporary array for modification
        $postArray = postRequestArray();
 
        // Check for required fields
-       if ($isFailed === false) $isFailed = ifRequiredRegisterFieldsAreSet($postArray);
+       if ($isOkay === true) $isOkay = ifRequiredRegisterFieldsAreSet($postArray);
 
        // Set it back in request
        setPostRequestArray($postArray);
@@ -121,13 +121,13 @@ if (isFormSent()) {
                        if (!isPostRequestElementSet('pass1')) { setRequestPostElement('pass1', '!'); } else { setRequestPostElement('pass1', ''); }
                        if (!isPostRequestElementSet('pass2')) { setRequestPostElement('pass2', '!'); } else { setRequestPostElement('pass2', ''); }
                }
-               $isFailed = true;
+               $isOkay = false;
        } // END - if
 
        // Is the password long enouth?
-       if ((strlen(postRequestElement('pass1')) < getConfig('pass_len')) && ($isFailed === false)) {
+       if ((strlen(postRequestElement('pass1')) < getConfig('pass_len')) && ($isOkay === true)) {
                $shortPass = true;
-               $isFailed = true;
+               $isOkay = false;
        } // END - if
 
        // No admin? Admins can always register!
@@ -139,7 +139,7 @@ if (isFormSent()) {
 
                if ($cats < getConfig('least_cats')) {
                        // ... nope!
-                       $isFailed = true;
+                       $isOkay = false;
                } // END - if
        } // END - if
 
@@ -148,7 +148,7 @@ if (isFormSent()) {
                $CHK = isEmailTaken(postRequestElement('email'));
                if ($CHK === true) {
                        setRequestPostElement('email', '?');
-                       $isFailed = true;
+                       $isOkay = false;
                } // END - if
        } // END - if
 
@@ -168,15 +168,17 @@ LIMIT 1",
                        // Same IP in timeout range and different email address entered... Eat this, faker! ;-)
                        // But admins are allowed to fake their own exchange service.
                        $ipTimedOut = true;
-                       $isFailed = true;
+                       $isOkay = false;
                } // END - if
-       } // END - if
 
-       // Free memory
-       SQL_FREERESULT($result);
+               // Free memory
+               SQL_FREERESULT($result);
+       } // END - if
 } // END - if
 
-if ((isFormSent()) && (($isFailed === false) || (isAdmin()))) {
+// Is the form sent and all went fine or admin logged in?
+//* DEBUG: */ print intval(isFormSent()).'/'.intval($isOkay).'/'.intval(isAdmin()).'<br />';
+if ((isFormSent()) && (($isOkay === true) || (isAdmin()))) {
        // Prepapre month and day of birth
        if (strlen(postRequestElement('day'))   == 1) setRequestPostElement('day'  , '0'.postRequestElement('day'));
        if (strlen(postRequestElement('month')) == 1) setRequestPostElement('month', '0'.postRequestElement('month'));
@@ -321,7 +323,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF
                // Start with the gender...
                $content = array(
                        'hash'    => $hash,
-                       'userid'     => $userid,
+                       'userid'  => $userid,
                        'gender'  => $gender,
                        'surname' => SQL_ESCAPE(postRequestElement('surname')),
                        'family'  => SQL_ESCAPE(postRequestElement('family')),
@@ -337,7 +339,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF
                // No ZIP code entered
                $content = array(
                        'hash'    => $hash,
-                       'userid'     => $userid,
+                       'userid'  => $userid,
                        'gender'  => $gender,
                        'surname' => SQL_ESCAPE(postRequestElement('surname')),
                        'family'  => SQL_ESCAPE(postRequestElement('family')),
index c18d46bc839925ed5696947f104624148d095660..17a435539a2faba819d62c536e24445c9687b91c 100644 (file)
@@ -51,8 +51,10 @@ if ((!isExtensionActive('mydata')) && (!isAdmin())) {
        return;
 } // END - if
 
-// Remember userid
-$content['userid'] = getUserId();
+// Add userid
+$content = array(
+       'userid' => getUserId()
+);
 
 // Init variable to prevent notices
 $URL = '';
@@ -66,15 +68,19 @@ if (isPostRequestElementSet('notify')) $mode = 'notify'; // Switch off notificat
 switch ($mode) {
        case 'show': // Show his data
                if (isExtensionActive('country', true)) {
-                       // New way                         0        1         2          3         4     5     6        7           8            9       10      11           12           13
-                       $result = SQL_QUERY_ESC("SELECT surname, family, street_nr, country_code, zip, city, email, birth_day, birth_month, birth_year, gender, max_mails, receive_mails, last_update FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
+                       // New way                          1          2            3             4         5      6        7           8            9              10         11         12               13            14
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `street_nr`, `country_code`, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `gender`, `max_mails`, `receive_mails`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                } else {
-                       // Old way                         0        1         2        3      4     5     6        7           8            9       10      11           12           13
-                       $result = SQL_QUERY_ESC("SELECT surname, family, street_nr, country, zip, city, email, birth_day, birth_month, birth_year, gender, max_mails, receive_mails, last_update FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
+                       // Old way                          1          2            3        4         5      6        7           8            9              10         11         12               13            14
+                       $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `street_nr`, `country`, `zip`, `city`, `email`, `birth_day`, `birth_month`, `birth_year`, `gender`, `max_mails`, `receive_mails`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                }
-               $content = SQL_FETCHARRAY($result, 0, false);
+
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
 
                // Translate some things
@@ -103,9 +109,6 @@ switch ($mode) {
                        $content['country'] = generateCountryInfo($content['country_code']);
                } // END - if
 
-               // Merge data in
-               $content = merge_array($content, $content);
-
                // Load template
                loadTemplate('member_mydata_overview', false, $content);
                break;
@@ -131,8 +134,12 @@ LIMIT 1",
                                array(getUserId()), __FILE__, __LINE__);
                }
 
-               $content = SQL_FETCHARRAY($result, 0, false);
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
+
                $content['update_check'] = $content['last_update'] + getConfig('profile_lock');
 
                // How far is last change on his profile away from now?
@@ -188,9 +195,6 @@ LIMIT 1",
                                $content['country'] = "<input type=\"text\" name=\"cntry\" class=\"member_normal\" size=\"2\" maxlength=\"3\" value=\"".$content['country']."\" />";
                        }
 
-                       // Merge data in
-                       $content = merge_array($content, $content);
-
                        // Load template
                        loadTemplate('member_mydata_edit', false, $content);
                }
@@ -200,8 +204,13 @@ LIMIT 1",
                // Load old email / password:      0          1           2
                $result = SQL_QUERY_ESC("SELECT `email`, `password`, `last_update` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
                        array(getUserId()), __FILE__, __LINE__);
-               $content = SQL_FETCHARRAY($result, 0, false);
+
+               // Get line
+               $content = merge_array($content, SQL_FETCHARRAY($result, 0, false));
+
+               // Free result
                SQL_FREERESULT($result);
+
                $content['last_change'] = $content['last_update'] + getConfig('profile_lock');
 
                // How far is last change on his profile away from now?
index 09c836ba704d2e53a9c0bbf73e38284134eba1ae..eaa939dc584e815308a8679cf361bee6af90e78f 100644 (file)
@@ -112,15 +112,6 @@ if ((!isInstalling()) && (!isInstallationPhase())) {
                                // Run the init filter chain
                                runFilterChain('init');
 
-                               // Is the extension sql_patches installed and at least 0.3.6?
-                               if ((isExtensionActive('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6')) {
-                                       // Generate random number
-                                       setConfigEntry('RAND_NUMBER', generateRandomCode(10, mt_rand(10000, 32766), getUserId(), ''));
-                               } else {
-                                       // Generate weak (!!!) code
-                                       setConfigEntry('RAND_NUMBER', mt_rand(1000000, 9999999));
-                               }
-
                                // Check module for permissions
                                $checkModule = checkModulePermissions();