Fixes for rallye extension, refs are now no longer removed from rallye if ref was...
authorRoland Häder <roland@mxchange.org>
Sat, 4 Oct 2008 11:18:15 +0000 (11:18 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 4 Oct 2008 11:18:15 +0000 (11:18 +0000)
inc/check-reset.php
inc/databases.php
inc/libs/rallye_functions.php
inc/modules/admin/what-list_rallyes.php
inc/modules/member/what-order.php
inc/modules/member/what-transfer.php
inc/reset/reset_daily.php
inc/reset/reset_holiday.php

index ec19cb89525db351018557dda88790eb0c18faef..874c10985dca713855ee237b93f503531c4aa53e 100644 (file)
@@ -37,8 +37,8 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
        require($INC);
 }
 
-// 01    2                            2        2         3321    1                         2                     21    1                        2                    21    1                        2                  21    1      2                 21    1         1    1                         2            210
-if ((date("d", $_CONFIG['last_update']) != date("d", time())) && (!defined('mxchange_installing')) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (!isset($_GET['register'])) && ($CSS != 1) && (!defined('DEBUG_MODE'))) {
+// 01    2                            2        2         3321    12        3                     32    2                    21    1                        2                    21    1                        2                  21    1      2                 21    1         10
+if ((date("d", $_CONFIG['last_update']) != date("d", time())) && ((!defined('mxchange_installing')) || (!mxchange_installing)) && (isBooleanConstantAndTrue('mxchange_installed')) && (isBooleanConstantAndTrue('admin_registered')) && (!isset($_GET['register'])) && ($CSS != 1)) {
        // Do daily things in external PHP file but only when script is completely setup
        // Daily reset was run!
        define('__DAILY_RESET', true);
        // Do daily things in external PHP file but only when script is completely setup
        // Daily reset was run!
        define('__DAILY_RESET', true);
index 4fad9a95fbd7457afbc4a293a7dbc3ffbe741d18..3077e9822b41e6905a922886de49607bb7b412b7 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "437");
+define('CURR_SVN_REVISION', "438");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 643c53f29fc691232ee75868161593de0cfa73f7..cf06f007354efc5738e03a64088a0907d39cde21 100644 (file)
@@ -141,8 +141,7 @@ VALUES ('%s','%s','%s','%s')",
 function RALLYE_ADD_PRICES($rallye,$mode="email")
 {
        // Output mode
 function RALLYE_ADD_PRICES($rallye,$mode="email")
 {
        // Output mode
-       switch($mode)
-       {
+       switch($mode) {
                case "email": $mode = "\n";     break;
                case "html" : $mode = "<br />\n"; break;
        }
                case "email": $mode = "\n";     break;
                case "html" : $mode = "<br />\n"; break;
        }
@@ -186,11 +185,6 @@ function RALLYE_ADD_PRICES($rallye,$mode="email")
 function RALLYE_ADD_TOPUSERS($rallye,$default=0)
 {
        global $_CONFIG;
 function RALLYE_ADD_TOPUSERS($rallye,$default=0)
 {
        global $_CONFIG;
-       // Init variable
-       $since = 0;
-       if (EXT_IS_ACTIVE("autopurge")) {
-               $since = $_CONFIG['ap_inactive_since'];
-       } // END - if
 
        // First check how many prices are set
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%s ORDER BY price_level",
 
        // First check how many prices are set
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%s ORDER BY price_level",
@@ -221,18 +215,17 @@ WHERE u.rallye_id=%s AND r.counter > 0 ORDER BY u.refs DESC",
                $result_ref = SQL_QUERY_ESC("SELECT DISTINCT p.points FROM "._MYSQL_PREFIX."_user_points AS p
 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
 ON p.userid=d.userid
                $result_ref = SQL_QUERY_ESC("SELECT DISTINCT p.points FROM "._MYSQL_PREFIX."_user_points AS p
 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
 ON p.userid=d.userid
-WHERE d.userid=%s AND d.status='CONFIRMED' AND p.ref_depth=1 AND d.max_mails > 0 AND d.mails_confirmed >= %s AND d.last_online >= (UNIX_TIMESTAMP() - %s)
-LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout'], $since), __FILE__, __LINE__);
+WHERE d.userid=%s AND d.status='CONFIRMED' AND p.ref_depth=1 AND d.max_mails > 0 AND d.mails_confirmed >= %s
+LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout']), __FILE__, __LINE__);
                list($refpoints) = SQL_FETCHROW($result_ref);
                SQL_FREERESULT($result_ref);
 
                if (empty($refpoints)) $refpoints = 0;
 
                list($refpoints) = SQL_FETCHROW($result_ref);
                SQL_FREERESULT($result_ref);
 
                if (empty($refpoints)) $refpoints = 0;
 
-               // And subtract start refs
-               $cnt -= $refs;
-
+               // Init userid for list
                $_uid = "---";
                // List only users with at least one ref!
                $_uid = "---";
                // List only users with at least one ref!
+               //* DEBUG: */ echo "*".$cnt."/".$uid."/".$cpoints."/".$refpoints."*<br />\n";
                if (($cnt > 0) && ($refpoints > $cpoints)) { $_uid = $uid; } else { $cnt = ""; }
 
                // Save values to array
                if (($cnt > 0) && ($refpoints > $cpoints)) { $_uid = $uid; } else { $cnt = ""; }
 
                // Save values to array
@@ -357,12 +350,6 @@ function RALLYE_EXPIRE_RALLYES($result)
 {
        global $DATA, $_CONFIG;
 
 {
        global $DATA, $_CONFIG;
 
-       // Latest online time
-       $since = 0;
-       if (EXT_IS_ACTIVE("autopurge")) {
-               $since = $_CONFIG['ap_inactive_since'];
-       } // END - if
-
        // Load rallye data
        list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
        // Load rallye data
        list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
        SQL_FREERESULT($result);
@@ -387,8 +374,8 @@ function RALLYE_EXPIRE_RALLYES($result)
                //   active = 0: account is deleted or locked
                $result = SQL_QUERY_ESC("SELECT COUNT(userid) AS active
 FROM "._MYSQL_PREFIX."_user_data
                //   active = 0: account is deleted or locked
                $result = SQL_QUERY_ESC("SELECT COUNT(userid) AS active
 FROM "._MYSQL_PREFIX."_user_data
-WHERE userid=%s AND status='CONFIRMED' AND last_online >= (UNIX_TIMESTAMP() - %s)
-LIMIT 1", array(bigintval($uid), $since), __FILE__, __LINE__);
+WHERE userid=%s AND status='CONFIRMED'
+LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
                list($active) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
                list($active) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
@@ -749,33 +736,29 @@ function RALLYE_TEMPLATE_SELECTION($name="template", $default="")
        return $OUT;
 }
 //
        return $OUT;
 }
 //
-function RALLYE_GET_REFCOUNT($uid, $old=0)
-{
+function RALLYE_GET_REFCOUNT($uid, $old=0) {
        global $_CONFIG, $cacheArray;
        // Check current refs
        global $_CONFIG, $cacheArray;
        // Check current refs
-       if (GET_EXT_VERSION("cache") >= "0.1.2")
-       {
+       if (GET_EXT_VERSION("cache") >= "0.1.2") {
                // Get refs from cache
                $cnt = 0;
                // Get refs from cache
                $cnt = 0;
-               foreach ($cacheArray['ref_system']['userid'] as $id => $u_id)
-               {
-                       if (($u_id == $uid) && ($cacheArray['ref_system']['level'][$id] == 0))
-                       {
-                               foreach ($cacheArray['ref_depths']['level'] as $level)
-                               {
-                                       if (($level == $cacheArray['ref_system']['level'][$id]) && ($level == 0))
-                                       {
+               foreach ($cacheArray['ref_system']['userid'] as $id => $u_id) {
+                       // Do we have a ref for this user?
+                       //* DEBUG: */ echo "id={$id},u_id={$u_id},uid={$uid},old={$old},level={$cacheArray['ref_system']['level'][$id]}<br />\n";
+                       if (($u_id == $uid) && ($cacheArray['ref_system']['level'][$id] == 1)) {
+                               //* DEBUG: */ echo "uid matches!<br />\n";
+                               foreach ($cacheArray['ref_depths']['level'] as $level) {
+                                       if (($level == $cacheArray['ref_system']['level'][$id]) && ($level == 1)) {
                                                // Level does exist so abort here
                                                $cnt = $cacheArray['ref_system']['counter'][$id];
                                                //* DEBUG: */ echo "*".$uid."/".$cnt."*<br />";
                                                break;
                                                // Level does exist so abort here
                                                $cnt = $cacheArray['ref_system']['counter'][$id];
                                                //* DEBUG: */ echo "*".$uid."/".$cnt."*<br />";
                                                break;
-                                       }
-                                        elseif ($level > 0)
-                                       {
+                                       } elseif ($level > 1) {
                                                // Not interesting here...
                                                break;
                                        }
                                }
                                                // Not interesting here...
                                                break;
                                        }
                                }
+
                                // Abort also here!
                                if ($cnt > 0) break;
                        }
                                // Abort also here!
                                if ($cnt > 0) break;
                        }
@@ -785,8 +768,7 @@ function RALLYE_GET_REFCOUNT($uid, $old=0)
                //* DEBUG: */ echo "</PRE>";
                //* DEBUG: */ die();
 
                //* DEBUG: */ echo "</PRE>";
                //* DEBUG: */ die();
 
-               if ($cnt > 0)
-               {
+               if ($cnt > 0) {
                        // Count cache hits
                        $_CONFIG['cache_hits']++;
 
                        // Count cache hits
                        $_CONFIG['cache_hits']++;
 
@@ -794,9 +776,7 @@ function RALLYE_GET_REFCOUNT($uid, $old=0)
                        //* DEBUG: */ echo "+".$cnt."/".$old."+<br />";
                        $cnt -= $old;
                }
                        //* DEBUG: */ echo "+".$cnt."/".$old."+<br />";
                        $cnt -= $old;
                }
-       }
-        else
-       {
+       } else {
                // Load current refs from database
                $result_ref = SQL_QUERY_ESC("SELECT DISTINCT SUM(s.counter) AS cnt
 FROM "._MYSQL_PREFIX."_refsystem AS s
                // Load current refs from database
                $result_ref = SQL_QUERY_ESC("SELECT DISTINCT SUM(s.counter) AS cnt
 FROM "._MYSQL_PREFIX."_refsystem AS s
index ea81f49ffc776c039c17f5bd561781300a86c16b..d4e61658fa286837de54baa8440820531e89ed66 100644 (file)
@@ -218,9 +218,7 @@ if (isset($_POST['edit']))
                // Nothing selected to edit
                LOAD_TEMPLATE("admin_settings_saved", false, LOAD_TEMPLATE("admin_list_rallye_noselect", true));
        }
                // Nothing selected to edit
                LOAD_TEMPLATE("admin_settings_saved", false, LOAD_TEMPLATE("admin_list_rallye_noselect", true));
        }
-}
- elseif (($_GET['sub'] == "users") && ($_GET['rallye'] > 0))
-{
+} elseif (($_GET['sub'] == "users") && ($_GET['rallye'] > 0)) {
        // List users and their refs before start and current
        $result = SQL_QUERY_ESC("SELECT userid, refs, curr_points FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s ORDER BY userid",
         array(bigintval($_GET['rallye'])), __FILE__, __LINE__);
        // List users and their refs before start and current
        $result = SQL_QUERY_ESC("SELECT userid, refs, curr_points FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s ORDER BY userid",
         array(bigintval($_GET['rallye'])), __FILE__, __LINE__);
@@ -243,6 +241,9 @@ if (isset($_POST['edit']))
                                $cnt = ADMIN_USER_PROFILE_LINK($uid, $cnt, "list_refs");
                                $old = ADMIN_USER_PROFILE_LINK($uid, $old, "list_refs");
                        }
                                $cnt = ADMIN_USER_PROFILE_LINK($uid, $cnt, "list_refs");
                                $old = ADMIN_USER_PROFILE_LINK($uid, $old, "list_refs");
                        }
+
+                       // Get user points
+                       $points = GET_TOTAL_DATA($uid, "user_points", "points")  - GET_TOTAL_DATA($uid, "user_data", "used_points");
                        $content = array(
                                'sw'      => $SW ,
                                'uid'     => $uid,
                        $content = array(
                                'sw'      => $SW ,
                                'uid'     => $uid,
@@ -250,7 +251,7 @@ if (isset($_POST['edit']))
                                'bold_r'  => $Br ,
                                'old'     => $old,
                                'cnt'     => $cnt,
                                'bold_r'  => $Br ,
                                'old'     => $old,
                                'cnt'     => $cnt,
-                               'opoints' => TRANSLATE_COMMA($opoints),
+                               'opoints' => TRANSLATE_COMMA($points - $opoints),
                        );
                        $OUT .= LOAD_TEMPLATE("admin_list_rallye_usr_row", true, $content);
                        $SW = 3 - $SW;
                        );
                        $OUT .= LOAD_TEMPLATE("admin_list_rallye_usr_row", true, $content);
                        $SW = 3 - $SW;
index a85be7e4686e695d87866544fffe6f2ef4a6f76c..462f6bad3ca594836d96eb94ba61ee24a80a61b8 100644 (file)
@@ -96,16 +96,9 @@ if ($_CONFIG['order_max_full'] == "MAX") $ALLOWED = $MAXI;
 $HTML_EXT = EXT_IS_ACTIVE("html_mail");
 
 // Now check his points amount
 $HTML_EXT = EXT_IS_ACTIVE("html_mail");
 
 // Now check his points amount
-$result_p = SQL_QUERY_ESC("SELECT SUM(points) FROM "._MYSQL_PREFIX."_user_points WHERE userid=%s",
- array($GLOBALS['userid']), __FILE__, __LINE__);
-
-$TOTAL = 0;
-if (SQL_NUMROWS($result_p) > 0)
-{
-       // Load points
-       list($TOTAL) = SQL_FETCHROW($result_p);
-       SQL_FREERESULT($result_p);
+$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points");
 
 
+if ($TOTAL > 0) {
        // And subtract his used points...
        $TOTAL -= GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
 
        // And subtract his used points...
        $TOTAL -= GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
 
@@ -113,14 +106,11 @@ if (SQL_NUMROWS($result_p) > 0)
        if (!ereg(".", $TOTAL)) $TOTAL .= ".00000";
 }
 
        if (!ereg(".", $TOTAL)) $TOTAL .= ".00000";
 }
 
-if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3"))
-{
+if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
        // Holiday is active!
        SQL_FREERESULT($result_p);
        LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ORDER_NOT_POSSIBLE);
        // Holiday is active!
        SQL_FREERESULT($result_p);
        LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ORDER_NOT_POSSIBLE);
-}
- elseif ((!empty($_POST['frametester'])) && ($ALLOWED > 0) && ($_POST['receiver'] > 0))
-{
+} elseif ((!empty($_POST['frametester'])) && ($ALLOWED > 0) && ($_POST['receiver'] > 0)) {
        // Continue with the frametester, we first need to store the data temporary in the pool
        //
        // First we would like to store the data and get it's pool position back...
        // Continue with the frametester, we first need to store the data temporary in the pool
        //
        // First we would like to store the data and get it's pool position back...
index b546599246076dd3a274b2fe2d1b28b080a6c0c3..7e00b7a188e522c376bf255df98fb7bc5d90ce65 100644 (file)
@@ -63,19 +63,10 @@ switch ($MODE)
 {
 case "new": // Start new transfer
        // Get total points and subtract the balance amount from it = maximum transferable points
 {
 case "new": // Start new transfer
        // Get total points and subtract the balance amount from it = maximum transferable points
-       $result = SQL_QUERY_ESC("SELECT SUM(points) FROM "._MYSQL_PREFIX."_user_points WHERE userid=%s AND points > 0",
-        array($GLOBALS['userid']), __FILE__, __LINE__);
-       list($total) = SQL_FETCHROW($result);
-       SQL_FREERESULT($result);
-
-       // Get totally used points and password
-       $result = SQL_QUERY_ESC("SELECT used_points, password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
-        array($GLOBALS['userid']), __FILE__, __LINE__);
-       list($used, $pass) = SQL_FETCHROW($result);
-       SQL_FREERESULT($result);
+       $total = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points")  - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
 
        // Remember maximum value for template
 
        // Remember maximum value for template
-       define('__TRANSFER_MAX_VALUE', round($total - $used - $_CONFIG['transfer_balance'] - 0.5));
+       define('__TRANSFER_MAX_VALUE', round($total - $_CONFIG['transfer_balance'] - 0.5));
 
        if (isset($_POST['ok']))
        {
 
        if (isset($_POST['ok']))
        {
index c763c0ecc5176e2e73d5777cfa65fd6841cc43ae..9ae3f045b139dff97dfcb5912770ac1d299a3a1f 100644 (file)
@@ -49,19 +49,23 @@ if (GET_EXT_VERSION("order") >= "0.1.1") {
 // Transfer points from locked_points to points
 $result_daily = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE ref_payout=0 AND status='CONFIRMED' ORDER BY userid", __FILE__, __LINE__);
 
 // Transfer points from locked_points to points
 $result_daily = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE ref_payout=0 AND status='CONFIRMED' ORDER BY userid", __FILE__, __LINE__);
 
+//* DEBUG: */ echo basename(__FILE__).":payout=0;daily|numRows=".SQL_NUMROWS($result_daily)."<br />\n";
 if (SQL_NUMROWS($result_daily) > 0)
 {
        // Start checking accounts which are on 0 confirmed-to-go mails
        while (list($uid) = SQL_FETCHROW($result_daily))
        {
 if (SQL_NUMROWS($result_daily) > 0)
 {
        // Start checking accounts which are on 0 confirmed-to-go mails
        while (list($uid) = SQL_FETCHROW($result_daily))
        {
+               //* DEBUG: */ echo basename(__FILE__).":uid={$uid}<br />\n";
                $result_points = SQL_QUERY_ESC("SELECT ref_depth, locked_points FROM "._MYSQL_PREFIX."_user_points
 WHERE userid=%s AND locked_points != 0.00000 ORDER BY ref_depth",
                 array(bigintval($uid)), __FILE__, __LINE__);
                $result_points = SQL_QUERY_ESC("SELECT ref_depth, locked_points FROM "._MYSQL_PREFIX."_user_points
 WHERE userid=%s AND locked_points != 0.00000 ORDER BY ref_depth",
                 array(bigintval($uid)), __FILE__, __LINE__);
+               //* DEBUG: */ echo basename(__FILE__).":payout=0;points|numRows=".SQL_NUMROWS($result_points)."<br />\n";
                if (SQL_NUMROWS($result_points) > 0)
                {
                        // Ok transfer points
                        while (list($dep, $locked) = SQL_FETCHROW($result_points))
                        {
                if (SQL_NUMROWS($result_points) > 0)
                {
                        // Ok transfer points
                        while (list($dep, $locked) = SQL_FETCHROW($result_points))
                        {
+                       //* DEBUG: */ echo basename(__FILE__).":uid={$uid},depth={$dep},locked={$locked}<br />\n";
                                $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s, locked_points=0.00000
 WHERE userid=%s AND ref_depth=%d LIMIT 1",
                                 array($locked, bigintval($uid), $dep), __FILE__, __LINE__);
                                $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET points=points+%s, locked_points=0.00000
 WHERE userid=%s AND ref_depth=%d LIMIT 1",
                                 array($locked, bigintval($uid), $dep), __FILE__, __LINE__);
index 5d599857b33774073d1bc37a7421b96f5a780416..b323667ddd8ffff2d5afbcac2e230f65f0779fb3 100644 (file)
@@ -41,7 +41,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Do not execute when script is in CSS mode or no daily reset
 }
 
 // Do not execute when script is in CSS mode or no daily reset
-if (($CSS == 1) || ((!defined('__DAILY_RESET')) && ($_CONFIG['holiday_mode'] == "RESET"))) return;
+if (($CSS == 1) || (GET_EXT_VERSION("holiday") == "") || ((!defined('__DAILY_RESET')) && ($_CONFIG['holiday_mode'] == "RESET"))) return;
 
 // Check for holidays we need to enable and send email to user
 $result_main = SQL_QUERY("SELECT userid, holiday_activated FROM "._MYSQL_PREFIX."_user_data
 
 // Check for holidays we need to enable and send email to user
 $result_main = SQL_QUERY("SELECT userid, holiday_activated FROM "._MYSQL_PREFIX."_user_data