]> git.mxchange.org Git - mailer.git/blobdiff - mailid_top.php
Mailer project rwritten:
[mailer.git] / mailid_top.php
index ca8c3a57410b1e6f8d3039c303d6ee0d7b890861..e4ef0a812e992c0c5163b8dd9acd1ab3d97b9614 100644 (file)
@@ -41,7 +41,7 @@
 require('inc/libs/security_functions.php');
 
 // Init start time
-$GLOBALS['__start_time'] = microtime(true);
+$GLOBALS['__start_time'] = microtime(TRUE);
 
 // Tell everyone we are in this module
 $GLOBALS['__module']      = 'mailid';
@@ -77,8 +77,7 @@ if (isGetRequestElementSet('bonusid')) $bonusId = bigintval(getRequestElement('b
 if (isGetRequestElementSet('code'))    $code    = bigintval(getRequestElement('code'));
 if (isGetRequestElementSet('do'))      $do      = getRequestElement('do');
 
-// 01             2       21    12           2    2            21    1                      2210
-if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalErrorsDetected())) {
+if ((isValidId($userId)) && ((isValidId($mailId)) || (isValidId($bonusId))) && (!ifFatalErrorsDetected())) {
        // No image?
        if ($do != 'img') {
                // ... then output header
@@ -86,12 +85,12 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
        } // END - fi
 
        // Maybe he wants to confirm an email?
-       if ($mailId > 0) {
+       if (isValidId($mailId)) {
                $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
                        array($mailId, $userId), __FILE__, __LINE__);
                $type = 'mailid';
                $urlId = $mailId;
-       } elseif ($bonusId > 0) {
+       } elseif (isValidId($bonusId)) {
                $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
                        array($bonusId, $userId), __FILE__, __LINE__);
                $type = 'bonusid';
@@ -107,7 +106,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                $data = SQL_FETCHARRAY($result_main);
 
                // Init result here with invalid to avoid possible missing variable
-               $result_mailid = false;
+               $result_mailid = FALSE;
 
                // @TODO Rewrite this to a filter/function
                switch ($data['link_type']) {
@@ -117,7 +116,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                break;
 
                        case 'BONUS':
-                               $result_mailid = SQL_QUERY_ESC("SELECT `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+                               $result_mailid = SQL_QUERY_ESC("SELECT `id` AS `pool_id`, `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                                        array($urlId), __FILE__, __LINE__);
                                break;
 
@@ -138,11 +137,11 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
 
                        // Set sender to 0 when we have a bonus mail
                        if ($data['link_type'] == 'BONUS') {
-                               $data['sender'] = '0';
+                               $data['sender'] = NULL;
                        } // END - if
 
                        // Is the user id valid?
-                       if (fetchUserData($userId) === true) {
+                       if (fetchUserData($userId) === TRUE) {
                                // Is the user status CONFIRMED?
                                if (getUserData('status') == 'CONFIRMED') {
                                        // User has confirmed his account so we can procede...
@@ -154,10 +153,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
 
                                                        // Entry found?
                                                        if (SQL_NUMROWS($result) == 1) {
-                                                               list($pay) = SQL_FETCHROW($result);
-                                                               $time      = getPaymentData($pay, 'time');
-                                                               $payment   = getPaymentData($pay, 'payment');
-                                                               $isValid   = true;
+                                                               list($paymentId) = SQL_FETCHROW($result);
+                                                               $time      = getPaymentData($paymentId, 'time');
+                                                               $payment   = getPaymentData($paymentId, 'payment');
+                                                               $isValid   = TRUE;
                                                        } // END - if
 
                                                        // Free memory...
@@ -165,13 +164,13 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                        break;
 
                                                case 'BONUS':
-                                                       $result = SQL_QUERY_ESC("SELECT `time`,`points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+                                                       $result = SQL_QUERY_ESC("SELECT `time`, `points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                                                                array(bigintval($data['pool_id'])), __FILE__, __LINE__);
 
                                                        // Entry found?
                                                        if (SQL_NUMROWS($result) == 1) {
                                                                list($time, $payment) = SQL_FETCHROW($result);
-                                                               $isValid = true;
+                                                               $isValid = TRUE;
                                                        } // END - if
 
                                                        // Free memory...
@@ -184,8 +183,11 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                        } // END - switch
 
                                        // Is this entry valid?
-                                       if ($isValid === true) {
+                                       if ($isValid === TRUE) {
+                                               // Run at least one second
                                                if (($time == '0') && ($payment > 0)) $time = 1;
+
+                                               // Is time and payment set?
                                                if (($time > 0) && ($payment > 0)) {
                                                        $realCode = '0';
                                                        if (!empty($code)) {
@@ -232,7 +234,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                        } // END - switch
 
                                                                        // Export data into constants for the template
-                                                                       $content['banner'] = loadTemplate('mailid_banner', true);
+                                                                       $content['banner'] = loadTemplate('mailid_banner', TRUE);
 
                                                                        // Only when user extension = v0.1.2: Update mails-confirmed counter
                                                                        // @TODO Rewrite these blocks to filter
@@ -279,7 +281,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                        // Is an active-rallye running and this is not a notification mail?
                                                                                        if ((isBonusRallyeActive()) && ($data['is_notify'] != 'Y')) {
                                                                                                // Shall I exclude the webmaster's own userid from the active-rallye?
-                                                                                               if ((((getBonusUserid() == $userId) && (getConfig('bonus_include_own') == 'Y')) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) {
+                                                                                               if ((((getBonusUserid() == $userId) && (isBonusIncludeOwnEnabled())) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) {
                                                                                                        // Add points and remember ranking are done in this function....
                                                                                                        addTurboBonus($urlId, $userId, $type);
 
@@ -306,8 +308,8 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                $content['points'] = $payment;
 
                                                                                // Load template
-                                                                               loadTemplate($template, false, $content);
-                                                                       } elseif (isValidUserId($data['sender'])) {
+                                                                               loadTemplate($template, FALSE, $content);
+                                                                       } elseif (isValidId($data['sender'])) {
                                                                                // Wrong image code! So add points to sender's account
                                                                                initReferralSystem();
                                                                                addPointsThroughReferralSystem('mailid_payback', $data['sender'], $payment);
@@ -316,13 +318,13 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                $content['points'] = $payment;
 
                                                                                // Load template
-                                                                               loadTemplate('mailid_points_failed', false, $content);
+                                                                               loadTemplate('mailid_points_failed', FALSE, $content);
                                                                        } else {
                                                                                // Add payment points (again)
                                                                                $content['points'] = $payment;
 
                                                                                // Load template
-                                                                               loadTemplate('mailid_points_failed2', false, $content);
+                                                                               loadTemplate('mailid_points_failed2', FALSE, $content);
                                                                        }
 
                                                                        // Remove link from table
@@ -341,7 +343,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                $content['userid'] = $userId;
                                                                                $content['type']   = $type;
                                                                                $content['data']   = $urlId;
-                                                                               $content['banner'] = loadTemplate('mailid_banner', true);
+                                                                               $content['banner'] = loadTemplate('mailid_banner', TRUE);
                                                                                if (getCodeLength() > 0) {
                                                                                        // Generate Code
                                                                                        $content['image'] = generateCaptchaCode($code, $type, $urlId, $userId);
@@ -353,7 +355,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                                }
 
                                                                                // Load template
-                                                                               loadTemplate($templ, false, $content);
+                                                                               loadTemplate($templ, FALSE, $content);
                                                                        } else {
                                                                                // Cannot confirm!
                                                                                reportBug(__FILE__, __LINE__, 'No code given.');
@@ -368,11 +370,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                        $content['userid'] = $userId;
                                                                        $content['type']   = $type;
                                                                        $content['data']   = $urlId;
-                                                                       $content['rand']   = getRandomTan();
-                                                                       $content['banner'] = loadTemplate('mailid_banner', true);
+                                                                       $content['banner'] = loadTemplate('mailid_banner', TRUE);
 
                                                                        // Load template
-                                                                       loadTemplate('mailid_timer', false, $content);
+                                                                       loadTemplate('mailid_timer', FALSE, $content);
                                                                        break;
 
                                                                default: // Unknown mode
@@ -380,30 +381,30 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                                                        break;
                                                        } // END - switch
                                                } else {
-                                                       loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (6)');
+                                                       loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (6)');
                                                        $do = 'failed';
                                                }
                                        } else {
-                                               loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (5)');
+                                               loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (5)');
                                                $do = 'failed';
                                        }
                                } else {
-                                       loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (4)');
+                                       loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (4)');
                                        $do = 'failed';
                                }
                        } else {
-                               loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (3)');
+                               loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (3)');
                                $do = 'failed';
                        }
                } else {
-                       loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (2)');
+                       loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (2)');
                        $do = 'failed';
                }
 
                // Free result
                SQL_FREERESULT($result_mailid);
        } else {
-               loadTemplate('admin_settings_unsaved', false, '{--MAIL_ALREADY_CONFIRMED--} (1)');
+               loadTemplate('admin_settings_unsaved', FALSE, '{--MAIL_ALREADY_CONFIRMED--} (1)');
                $do = 'failed';
        }