Rewrites/fixes for handling config entries in SQLs
[mailer.git] / inc / modules / guest / what-confirm.php
index 166f2b8a5bc842b2d81abcb1bcf807d942a9e118..1121248be5ada1699a9be064fc6274e4e84de9cd 100644 (file)
@@ -56,11 +56,11 @@ if (isGetRequestParameterSet('hash')) {
        $userid = '0';
 
        // Search for an unconfirmed or confirmed account
-       $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid`,`gender` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
                array(getRequestParameter('hash')), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Ok, he want's to confirm now so we load some data
-               list($userid, $email, $rid, $gender) = SQL_FETCHROW($result);
+               list($userid, $email, $refid) = SQL_FETCHROW($result);
 
                // Fetch user data
                if (!fetchUserData($userid)) {
@@ -70,11 +70,18 @@ if (isGetRequestParameterSet('hash')) {
 
                // Load all data and add points
                $content = getUserDataArray();
-               $content['gender'] = translateGender($content['gender']);
-               $content['points'] = getConfig('points_register');
 
                // Unlock his account (but only when it is on UNCONFIRMED!)
-               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED', ref_payout={?ref_payout?}, `user_hash`=NULL WHERE `user_hash`='%s' AND `status`='UNCONFIRMED' LIMIT 1",
+               SQL_QUERY_ESC("UPDATE
+       `{?_MYSQL_PREFIX?}_user_data`
+SET
+       `status`='CONFIRMED',
+       `ref_payout`={?ref_payout?},
+       `user_hash`=NULL
+WHERE
+       `user_hash`='%s' AND
+       `status`='UNCONFIRMED'
+LIMIT 1",
                        array(getRequestParameter('hash')), __FILE__, __LINE__);
                if (SQL_AFFECTEDROWS() == 1) {
                        // Send email if updated
@@ -84,11 +91,11 @@ if (isGetRequestParameterSet('hash')) {
                        sendEmail($email, getMessage('GUEST_THANX_CONFIRM'), $message);
 
                        // Maybe he got "referaled"?
-                       if (($rid > 0) && ($rid != $userid)) {
+                       if (($refid > 0) && ($refid != $userid)) {
                                // Select the referal userid
-                               if (fetchUserData($rid)) {
+                               if (fetchUserData($refid)) {
                                        // Update ref counter...
-                                       updateReferalCounter($rid);
+                                       updateReferalCounter($refid);
 
                                        // Shall I 'pay' the referal points imidiately?
                                        if (getConfig('ref_payout') == '0') {
@@ -103,7 +110,7 @@ if (isGetRequestParameterSet('hash')) {
                                        if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (getConfig('bonus_active') == 'Y')) {
                                                // Add points (directly only!)
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1",
-                                                       array(bigintval($rid)), __FILE__, __LINE__);
+                                                       array(bigintval($refid)), __FILE__, __LINE__);
 
                                                // Subtract points from system
                                                handleBonusPoints(getConfig('bonus_ref'));
@@ -112,7 +119,7 @@ if (isGetRequestParameterSet('hash')) {
                                        // Add one-time referal bonus over referal system or directly
                                        // @TODO Try to rewrite the following unset()
                                        unset($GLOBALS['ref_level']);
-                                       addPointsThroughReferalSystem('referal_bonus', $rid, getConfig('points_ref'), true, bigintval($userid), $locked, getConfig('reg_points_mode'));
+                                       addPointsThroughReferalSystem('referal_bonus', $refid, getConfig('points_ref'), true, bigintval($userid), $locked, getConfig('reg_points_mode'));
                                } // END - if
                        } // END - if