fooRequestElementBar() functions renamed, adding of request parameters added:
[mailer.git] / inc / mails / doubler_mails.php
index 718074fdcc702e65f2c2ba3c7e5b6f1f47be1ee9..d068ffd4cbae7320b54752a1bec8b5330797514d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 02/16/2005 *
- * ===============                              Last change: 01/21/2006 *
+ * Mailer v0.2.1-FINAL                                Start: 02/16/2005 *
+ * ===================                          Last change: 01/21/2006 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : doubler_mails.php                                 *
@@ -47,41 +47,61 @@ if (!defined('__SECURITY')) {
 if (getOutputMode() != 0) return;
 
 // Initialize variables
-$jackpot = 0; $user = 0;
+$jackpot = '0'; $user = '0';
 if (isExtensionActive('jackpot')) $jackpot = getJackpotPoints();
 
 // Get total points of the doubler itself
 $DOUBLER_POINTS = DOUBLER_GET_TOTAL_POINTS_LEFT();
-if ($DOUBLER_POINTS == 0) {
+if ($DOUBLER_POINTS == '0') {
        // Exit here to prevent some SQL errors (SQL_QUERY_ESC doen't insert zeros! We need to fix this...)
        return;
 } // END - if
 
 // If not currently doubled set it to zero
-unsetGetRequestElement('DOUBLER_UID');
-unsetPostRequestElement('DOUBLER_UID');
+unsetGetRequestParameter('DOUBLER_UID');
+unsetPostRequestParameter('DOUBLER_UID');
 setSession('DOUBLER_UID', '');
-if (empty($GLOBALS['doubler_userid'])) $GLOBALS['doubler_userid'] = 0;
+if (empty($GLOBALS['doubler_userid'])) $GLOBALS['doubler_userid'] = '0';
 
 // Check for doubles which we can pay out
-$result_total = SQL_QUERY_ESC("SELECT d.id, d.userid, d.points, d.remote_ip, d.timemark
-FROM `{?_MYSQL_PREFIX?}_doubler` AS d
-LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS u
-ON d.userid=u.userid
-WHERE u.`status`='CONFIRMED' AND d.points <= %s AND d.points >= %s AND d.completed='N' AND d.is_ref='N'
-ORDER BY d.timemark",
+$result_total = SQL_QUERY_ESC("SELECT
+       d.id, d.userid, d.points, d.remote_ip, d.timemark
+FROM
+       `{?_MYSQL_PREFIX?}_doubler` AS d
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_user_data` AS u
+ON
+       d.userid=u.userid
+WHERE
+       u.`status`='CONFIRMED' AND
+       d.points <= %s AND
+       d.points >= %s AND
+       d.completed='N' AND
+       d.is_ref='N'
+ORDER BY
+       d.timemark ASC",
        array(
                $DOUBLER_POINTS,
                getConfig(('doubler_min') * 2)
        ), __FILE__, __LINE__);
 
 // Check for accounts with limitation
-$result_main = SQL_QUERY_ESC("SELECT d.id, d.userid, d.points, d.remote_ip, d.timemark
-FROM `{?_MYSQL_PREFIX?}_doubler` AS d
-LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS u
-ON d.userid=u.userid
-WHERE u.`status`='CONFIRMED' AND d.points <= %s AND d.points >= %s AND d.completed='N' AND d.is_ref='N'
-ORDER BY d.timemark
+$result_main = SQL_QUERY_ESC("SELECT
+       d.id, d.userid, d.points, d.remote_ip, d.timemark
+FROM
+       `{?_MYSQL_PREFIX?}_doubler` AS d
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_user_data` AS u
+ON
+       d.userid=u.userid
+WHERE
+       u.`status`='CONFIRMED' AND
+       d.points <= %s AND
+       d.points >= %s AND
+       d.completed='N' AND
+       d.is_ref='N'
+ORDER BY
+       d.timemark ASC
 LIMIT %d",
        array(
                $DOUBLER_POINTS,
@@ -103,7 +123,7 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y'))
                        $ref = countSumTotalData($content['userid'], 'doubler', 'points', 'refid', false, " AND `completed`='N' AND `is_ref`='Y'");
 
                        // Zero refid when empty (might be helpful!)
-                       if (empty($ref)) $ref = 0;
+                       if (empty($ref)) $ref = '0';
 
                        if (($ref > 0) && ($GLOBALS['doubler_userid'] == $content['userid']) && (!empty($ref))) {
                                // Referal points found so add them and set line(s) to completed='Y'
@@ -112,7 +132,7 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y'))
                                        array(bigintval($content['userid'])), __FILE__, __LINE__);
                        } else {
                                // No referal points found
-                               $ref = 0;
+                               $ref = '0';
                        }
 
                        // Exclude webmaster from doubling...
@@ -137,7 +157,7 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y'))
                                $okay = true;
                        } // END - if
 
-                       // Exclude also webmaster's ID in taking points from webmaster's account
+                       // Exclude also webmaster's id in taking points from webmaster's account
                        if (($user > 0) && ($user >= $content['points']) && ($okay === false) && (getConfig('doubler_userid') > 0) && ($content['userid'] != getConfig('doubler_userid'))) {
                                // Add points to used points
                                subtractPoints('doubler_payout', getConfig('doubler_userid'), $content['points']);
@@ -158,7 +178,7 @@ if (((SQL_NUMROWS($result_total) > 0) && (getConfig('doubler_sent_all') == 'Y'))
 
                        // Prepare array
                        $content = array(
-                               // Doubler transmission ID
+                               // Doubler transmission id
                                'id'     => $content['id'],
                                // Doubled points
                                'points' => translateComma($content['points']),