Debug lines commented out
[mailer.git] / inc / mysql-manager.php
index 45f3a8ec42fbef38bd554009f49d106693d4bfc7..38ddd85c08c04581cd9e56b8707697f5d412c7ee 100644 (file)
@@ -1107,7 +1107,7 @@ function GET_REF_LEVEL_PERCENTS ($level) {
  */
 function ADD_POINTS_REFSYSTEM ($subject, $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;
+       global $_CONFIG, $DATA, $cacheArray;
 
        // Convert mode to lower-case
        $add_mode = strtolower($add_mode);
@@ -1126,14 +1126,14 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid
        } // END - if
 
        // Count up referal depth
-       if (!isset($DEPTH)) {
+       if (!isset($GLOBALS['ref_level'])) {
                // Initialialize referal system
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal system initialized!<br />\n";
-               $DEPTH = 0;
+               $GLOBALS['ref_level'] = 0;
        } else {
                // Increase referal level
-               $DEPTH++;
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$DEPTH}<br />\n";
+               $GLOBALS['ref_level']++;
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Referal level increased. DEPTH={$GLOBALS['ref_level']}<br />\n";
        }
 
        // Default is "normal" points
@@ -1153,32 +1153,32 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid
                $cacheArray['add_uid'][$ref] = $uid;
 
                // Get percents
-               $per = GET_REF_LEVEL_PERCENTS($DEPTH);
-               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},depth={$DEPTH},per={$per},mode={$add_mode}<br />\n";
+               $per = GET_REF_LEVEL_PERCENTS($GLOBALS['ref_level']);
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},depth={$GLOBALS['ref_level']},per={$per},mode={$add_mode}<br />\n";
 
                // Some percents found?
                if ($per > 0) {
                        // Calculate new points
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},per={$per},depth={$DEPTH}<br />\n";
+                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},points={$points},per={$per},depth={$GLOBALS['ref_level']}<br />\n";
                        $ref_points = $points * $per / 100;
 
                        // Pay refback here if level > 0 and in ref-mode
-                       if ((EXT_IS_ACTIVE("refback")) && ($DEPTH > 0) && ($per < 100) && ($add_mode == "ref") && (isset($cacheArray['add_uid'][$uid]))) {
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$DEPTH} - BEFORE!<br />\n";
+                       if ((EXT_IS_ACTIVE("refback")) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($add_mode == "ref") && (isset($cacheArray['add_uid'][$uid]))) {
+                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - BEFORE!<br />\n";
                                $ref_points = ADD_REFBACK_POINTS($cacheArray['add_uid'][$uid], $uid, $points, $ref_points);
-                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$DEPTH} - AFTER!<br />\n";
+                               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},data={$cacheArray['add_uid'][$uid]},ref_points={$ref_points},depth={$GLOBALS['ref_level']} - AFTER!<br />\n";
                        } // END - if
 
                        // Update points...
                        SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%s AND ref_depth='%s' LIMIT 1",
-                        array($data, $data, $ref_points, bigintval($uid), bigintval($DEPTH)), __FILE__, __LINE__);
-                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},uid={$uid},depth={$DEPTH},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
+                        array($data, $data, $ref_points, bigintval($uid), bigintval($GLOBALS['ref_level'])), __FILE__, __LINE__);
+                       //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},uid={$uid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
 
                        // No entry updated?
                        if (SQL_AFFECTEDROWS() < 1) {
                                // First ref in this level! :-)
                                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid,ref_depth,%s) VALUES (%s,%s,%s)",
-                                array($data, bigintval($uid), bigintval($DEPTH), $ref_points), __FILE__, __LINE__);
+                                array($data, bigintval($uid), bigintval($GLOBALS['ref_level']), $ref_points), __FILE__, __LINE__);
                        } // END - if
 
                        // Update mediadata as well
@@ -1192,7 +1192,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid
                                // Prepare content
                                $content = array(
                                        'percent' => $per,
-                                       'level'   => bigintval($DEPTH),
+                                       'level'   => bigintval($GLOBALS['ref_level']),
                                        'points'  => $ref_points,
                                        'refid'   => bigintval($ref)
                                );
@@ -1223,7 +1223,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify=false, $rid
                        if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
                                // Then let's credit him here...
                                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},ref={$ref},points={$points} - ADVANCE!<br />\n";
-                               ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $DEPTH), $ref, $points, $send_notify, $ref, $locked);
+                               ADD_POINTS_REFSYSTEM(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), $ref, $points, $send_notify, $ref, $locked);
                        } // END - if
                } // END - if
        } // END - if
@@ -1404,8 +1404,8 @@ function GET_ADMIN_EMAIL ($aid) {
        } elseif (!EXT_IS_ACTIVE("cache")) {
                // Load from database
                $result_aid = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1",
-                       array(bigintval($ret)), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1) {
+                       array(bigintval($aid)), __FILE__, __LINE__);
+               if (SQL_NUMROWS($result_aid) == 1) {
                        // Get data
                        list($ret) = SQL_FETCHROW($result_aid);
 
@@ -1562,7 +1562,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__);
 }
 //
 function META_DESCRIPTION ($mod, $wht) {
-       global $_CONFIG, $DEPTH;
+       global $_CONFIG;
 
        // Exclude admin and member's area
        if (($mod != "admin") && ($mod != "login")) {
@@ -1574,7 +1574,7 @@ function META_DESCRIPTION ($mod, $wht) {
        } // END - if
 
        // Remove depth
-       unset($DEPTH);
+       unset($GLOBALS['ref_level']);
 }
 //
 function ADD_JACKPOT($points) {