Bug fixed in referal system:
authorRoland Häder <roland@mxchange.org>
Sat, 22 Nov 2008 20:14:00 +0000 (20:14 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 22 Nov 2008 20:14:00 +0000 (20:14 +0000)
- Function ADD_DESCR() and ADD_POINTS_SYSTEM used both $DEPTH which is bad
  software design.
- We really need to rewrite the whole application! :-(
- This causes a bug in the referal system that all points are being booked
  to referal level one and not zero.

inc/databases.php
inc/libs/refback_functions.php
inc/modules/admin/what-add_points.php
inc/mysql-manager.php

index e13d1a80220f863465de1b56b8721d1c8094e507..40403a2eedc6ccec2eac7e303d9cd51130bebfbe 100644 (file)
@@ -114,7 +114,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', "542");
+define('CURR_SVN_REVISION', "543");
 
 // 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 c93d950d660d7d16f2cec57a1356bb4aca39bdcd..5d04dde4814bacde57e6cc1a47350eb9f6e3d136 100644 (file)
@@ -54,7 +54,7 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
        // "Walk" through all level
        while (list($level, $perc) = SQL_FETCHROW($result_refs)) {
                // Reset ref depths
        // "Walk" through all level
        while (list($level, $perc) = SQL_FETCHROW($result_refs)) {
                // Reset ref depths
-               $DEPTH = -1;
+               unset($DEPTH);
 
                // "Walk" through all refids
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},level={$level},points={$points}<br />\n";
 
                // "Walk" through all refids
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},level={$level},points={$points}<br />\n";
index 683da19824b61a92dcccfcd2093f09196bc7203c..87ed2594efd9109fe1109b7ace618f59ef8fb668 100644 (file)
@@ -58,6 +58,12 @@ if ($_GET['u_id'] == "all") {
                                SQL_FREERESULT($result);
 
                                if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
                                SQL_FREERESULT($result);
 
                                if ((isset($_POST['ok'])) && (!empty($_POST['points']))) {
+                                       global $DEPTH;
+                                       // Remove depth to prevent booking errors. This is a bad coding
+                                       // practice, thats also why we need to write this project from
+                                       // scratch...
+                                       unset($DEPTH);
+
                                        // Ok, add points and send an email to him...
                                        ADD_POINTS_REFSYSTEM($uid, bigintval($_POST['points']), false, "0", false, "direct");
 
                                        // Ok, add points and send an email to him...
                                        ADD_POINTS_REFSYSTEM($uid, bigintval($_POST['points']), false, "0", false, "direct");
 
index 093ea4ee8f24d6e8bf93e80b8acaf7c2bb14b8eb..684d43d3d8a1fab1474d42cdea62273be34a11b4 100644 (file)
@@ -190,7 +190,7 @@ function CHECK_MODULE($mod) {
 
 // Add menu description pending on given file name (without path!)
 function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
 
 // Add menu description pending on given file name (without path!)
 function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
-       global $DEPTH, $_CONFIG;
+       global $NAV_DEPTH, $_CONFIG;
        // Use only filename of the file ;)
        $file = basename($file);
 
        // Use only filename of the file ;)
        $file = basename($file);
 
@@ -249,11 +249,11 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
                $modCheck = $GLOBALS['module'];
                $AND = "";
        }
                $modCheck = $GLOBALS['module'];
                $AND = "";
        }
-       if ((!isset($DEPTH)) && (!$return)) {
-               $DEPTH = 0;
+       if ((!isset($NAV_DEPTH)) && (!$return)) {
+               $NAV_DEPTH = 0;
                $prefix = "<DIV class=\"you_are_here\">".YOU_ARE_HERE."&nbsp;<STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
        } else {
                $prefix = "<DIV class=\"you_are_here\">".YOU_ARE_HERE."&nbsp;<STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
        } else {
-               if (!$return) $DEPTH++;
+               if (!$return) $NAV_DEPTH++;
                $prefix = "";
        }
 
                $prefix = "";
        }
 
@@ -297,7 +297,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) {
 
                                // Add line-break tag
                                $OUT .= "<br />\n";
 
                                // Add line-break tag
                                $OUT .= "<br />\n";
-                               $DEPTH = "0";
+                               $NAV_DEPTH = "0";
 
                                // Handle failed logins here if not in guest
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):type={$type},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$ACC_LVL}<br />\n";
 
                                // Handle failed logins here if not in guest
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):type={$type},action={$GLOBALS['action']},what={$GLOBALS['what']},lvl={$ACC_LVL}<br />\n";
@@ -1159,7 +1159,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               for default value will cause no referal will get points ever!!!)
  */
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               for default value will cause no referal will get points ever!!!)
  */
-function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
+function ADD_POINTS_REFSYSTEM ($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
        //* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
        global $DEPTH, $_CONFIG, $DATA, $cacheArray;
 
        //* DEBUG: */ print "----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n";
        global $DEPTH, $_CONFIG, $DATA, $cacheArray;
 
@@ -1176,10 +1176,12 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
        // Count up referal depth
        if (!isset($DEPTH)) {
                // Initialialize referal system
        // Count up referal depth
        if (!isset($DEPTH)) {
                // Initialialize referal system
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />\n";
                $DEPTH = 0;
        } else {
                // Increase referal level
                $DEPTH++;
                $DEPTH = 0;
        } else {
                // Increase referal level
                $DEPTH++;
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$DEPTH}<br />\n";
        }
 
        // Default is "normal" points
        }
 
        // Default is "normal" points