]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/rallye_functions.php
Ref link fixed, nickname fixed, several rewrites, TODOs.txt updated:
[mailer.git] / inc / libs / rallye_functions.php
index 3d3b2d3b12ea47659e26dd27508eecbbf280738e..c1e37c5812e87b306a53df13640720eabea71802 100644 (file)
@@ -99,7 +99,7 @@ WHERE d.`status`='CONFIRMED' AND d.max_mails > 0 AND d.mails_confirmed >= %s AND
                        list($cpoints) = SQL_FETCHROW($result_ref);
                        SQL_FREERESULT($result_ref);
 
-                       if (empty($cpoints)) $cpoints = "0.00000";
+                       if (empty($cpoints)) $cpoints = '0.00000';
 
                        // Add info line
                        SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_rallye_users` (rallye_id, userid, refs, curr_points)
@@ -207,7 +207,7 @@ LIMIT 1", array(bigintval($content['userid']), getConfig('ref_payout')), __FUNCT
                // Init userid for list
                $_uid = '---';
                // List only users with at least one ref!
-               //* DEBUG: */ echo "*".$cnt.'/'.$content['userid'].'/'.$content['curr_points'].'/'.$refpoints."*<br />\n";
+               //* DEBUG: */ OUTPUT_HTML("*".$cnt.'/'.$content['userid'].'/'.$content['curr_points'].'/'.$refpoints."*<br />");
                if (($cnt > 0) && ($refpoints > $content['curr_points'])) { $_uid = $content['userid']; } else { $cnt = ''; }
 
                // Save values to array
@@ -223,7 +223,7 @@ LIMIT 1", array(bigintval($content['userid']), getConfig('ref_payout')), __FUNCT
        array_pk_sort($DATA, array('ref', 'cpoints'), 0, 1, true);
 
        // Generate table
-       $OUT = LOAD_TEMPLATE("guest_rallye_header", true);
+       $OUT = LOAD_TEMPLATE('guest_rallye_header', true);
        $SW = 2;
        for ($idx = 0; $idx < $prices; $idx++) {
                if (empty($DATA['uid'][$idx])) $DATA['uid'][$idx] = '---';
@@ -495,7 +495,7 @@ function RALLYE_LOAD_PRICES_ARRAY ($rallye) {
 //
 function RALLYE_LOAD_USERS_ARRAY ($rallye) {
        // Fix zero points to 0.00000
-       if (getConfig('ref_payout') == '0') setConfigEntry('ref_payout', "0.00000");
+       if (getConfig('ref_payout') == '0') setConfigEntry('ref_payout', '0.00000');
 
        // Init multi array
        $users = array(
@@ -558,8 +558,8 @@ WHERE d.`status`='CONFIRMED' AND d.max_mails > 0 AND d.mails_confirmed >= %s AND
 //
 function RALLYE_LIST_WINNERS ($rallye, $default=0) {
        // First check how many prices are set
-       $result_prices = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_rallye_prices` WHERE rallye_id=%s ORDER BY price_level",
-       array(bigintval($rallye)), __FUNCTION__, __LINE__);
+       $result_prices = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_rallye_prices` WHERE `rallye_id`=%s ORDER BY `price_level` ASC",
+               array(bigintval($rallye)), __FUNCTION__, __LINE__);
        $prices = SQL_NUMROWS($result_prices);
        SQL_FREERESULT($result_prices);
 
@@ -567,16 +567,13 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
        $DATA = RALLYE_LOAD_USERS_ARRAY($rallye);
 
        // Generate table
-       $OUT = LOAD_TEMPLATE("guest_rallye_expired_header", true);
+       $OUT = LOAD_TEMPLATE('guest_rallye_expired_header', true);
        $SW = 2;
        for ($idx = 0; $idx < $prices; $idx++) {
                // Check status
                //   active = 1: account is still confirmed
                //   active = 0: account is deleted or locked
-               $result_active = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
-               array(bigintval($DATA['uid'][$idx])), __FUNCTION__, __LINE__);
-               list($active) = SQL_FETCHROW($result_active);
-               SQL_FREERESULT($result_active);
+               $active = GET_TOTAL_DATA($DATA['uid'][$idx], 'user_data', 'userid', 'userid', true, " AND `status`='CONFIRMED'");
 
                if (empty($DATA['uid'][$idx])) $DATA['uid'][$idx] = '---';
                if ((empty($DATA['ref'][$idx])) || ($DATA['ref'][$idx] == 0) || ($active == 0) || ("".round($DATA['cpoints'][$idx])."" == '0') || (empty($DATA['cpoints'][$idx]))) {
@@ -590,7 +587,7 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
                        $DATA['infos'][$idx] = $DATA['info'][$idx];
                } else {
                        // Take ppints
-                       $DATA['infos'][$idx] = $DATA['points'][$idx]." {!POINTS!}";
+                       $DATA['infos'][$idx] = $DATA['points'][$idx] . ' {!POINTS!}';
                }
 
                // Add row
@@ -719,14 +716,14 @@ function RALLYE_GET_REFCOUNT ($uid, $old = 0) {
                $cnt = 0;
                foreach ($GLOBALS['cache_array']['refsystem']['userid'] as $id => $uid) {
                        // Do we have a ref for this user?
-                       //* DEBUG: */ echo "id={$id},uid={$uid},uid={$uid},old={$old},level={$GLOBALS['cache_array']['refsystem']['level'][$id]}<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML("id={$id},uid={$uid},uid={$uid},old={$old},level={$GLOBALS['cache_array']['refsystem']['level'][$id]}<br />");
                        if (($uid == $uid) && ($GLOBALS['cache_array']['refsystem']['level'][$id] == 1)) {
-                               //* DEBUG: */ echo "uid matches!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML("uid matches!<br />");
                                foreach ($GLOBALS['cache_array']['ref_depths']['level'] as $level) {
                                        if (($level == $GLOBALS['cache_array']['refsystem']['level'][$id]) && ($level == 1)) {
                                                // Level does exist so abort here
                                                $cnt = $GLOBALS['cache_array']['refsystem']['counter'][$id];
-                                               //* DEBUG: */ echo "*".$uid.'/'.$cnt."*<br />";
+                                               //* DEBUG: */ OUTPUT_HTML("*".$uid.'/'.$cnt."*<br />");
                                                break;
                                        } elseif ($level > 1) {
                                                // Not interesting here...
@@ -739,17 +736,17 @@ function RALLYE_GET_REFCOUNT ($uid, $old = 0) {
                        } // END - if
                } // END - foreach
 
-               //* DEBUG: */ echo "<pre>";
-               //* DEBUG: */ print_r($GLOBALS['cache_array']['refsystem']);
-               //* DEBUG: */ echo "</pre>";
-               //* DEBUG: */ die();
+               //* DEBUG: */ OUTPUT_HTML("<pre>");
+               //* DEBUG: */ OUTPUT_HTML(print_r($GLOBALS['cache_array']['refsystem'], true));
+               //* DEBUG: */ OUTPUT_HTML("</pre>");
+               //* DEBUG: */ shutdown();
 
                if ($cnt > 0) {
                        // Count cache hits
                        incrementConfigEntry('cache_hits');
 
                        // Remove old refs
-                       //* DEBUG: */ echo '+'.$cnt.'/'.$old."+<br />";
+                       //* DEBUG: */ OUTPUT_HTML('+'.$cnt.'/'.$old."+<br />");
                        $cnt -= $old;
                } // END - if
        } else {
@@ -769,7 +766,7 @@ WHERE s.userid=%s AND s.level=1", array(bigintval($uid)), __FUNCTION__, __LINE__
        }
 
        // Return count
-       //* DEBUG: */ echo "*".$uid.'/'.$old.'/'.$cnt."*<br />";
+       //* DEBUG: */ OUTPUT_HTML("*".$uid.'/'.$old.'/'.$cnt."*<br />");
        return $cnt;
 }