wernis extension is now alpha code (only listing in admin area is missing), naming...
[mailer.git] / inc / libs / bonus_functions.php
index 95ff13f09ce62375195c69c57e4ebeb1aaf16387..c52b7a9bbdb06b8e91abe77564de6aac08a891c2 100644 (file)
@@ -40,10 +40,10 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
 // This function must be run *BEFORE* a link is removed from table 'mxchange_user_links' !
 function BONUS_ADD_TURBO_POINTS($mid, $uid, $type)
 {
-       global $CONFIG;
+       global $_CONFIG;
 
        // Shall we add bonus points?
-       if ($CONFIG['bonus_active'] == 'N') return;
+       if ($_CONFIG['bonus_active'] == 'N') return;
 
        // Select SQL command
        $SQL = "";
@@ -69,12 +69,12 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type)
        {
                // First rank!
                $rank = 1;
-               $points = $CONFIG['turbo_bonus'];
+               $points = $_CONFIG['turbo_bonus'];
        }
         else
        {
                // Anything else so let's explode all entered rank points
-               $test = explode(";", $CONFIG['bonus_rates']);
+               $test = explode(";", $_CONFIG['bonus_rates']);
                if (!empty($test[$rank - 2]))
                {
                        // Level found
@@ -95,16 +95,16 @@ function BONUS_ADD_TURBO_POINTS($mid, $uid, $type)
        $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus_turbo (userid, mail_id, bonus_id, level, points, timemark) VALUES ('%s', '%s', '%s', '".$rank."', '".$points."', UNIX_TIMESTAMP())",
         array(bigintval($uid), bigintval($mail), bigintval($bonus)), __FILE__, __LINE__);
 
-       if ((GET_EXT_VERSION("bonus") >= "0.3.5") && ($CONFIG['bonus_mode'] != "ADD") && ($points > 0)) BONUS_POINTS_HANDLER($points);
+       if ((GET_EXT_VERSION("bonus") >= "0.3.5") && ($_CONFIG['bonus_mode'] != "ADD") && ($points > 0)) BONUS_POINTS_HANDLER($points);
 }
 //
 function BONUS_MAKE_RANK_ROWS($data, $type, $uid)
 {
-       global $CONFIG;
+       global $_CONFIG;
        $self = false; $OUT = "";
 
        // How many ranks do we have?
-       $ranks = sizeof(explode(";", $CONFIG['bonus_rates'])) + 1;
+       $ranks = sizeof(explode(";", $_CONFIG['bonus_rates'])) + 1;
 
        // Load current user's data
        $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s AND userid=%d LIMIT 1",
@@ -128,7 +128,7 @@ function BONUS_MAKE_RANK_ROWS($data, $type, $uid)
 
        // Load rankings
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_bonus_turbo WHERE %s=%s ORDER BY level LIMIT %s",
-        array($type, $data, $CONFIG['bonus_lines']), __FILE__, __LINE__);
+        array($type, $data, $_CONFIG['bonus_lines']), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0)
        {
                // Start generating the ranking list
@@ -183,44 +183,44 @@ function BONUS_MAKE_RANK_ROWS($data, $type, $uid)
 //
 function BONUS_POINTS_HANDLER($MODE)
 {
-       global $CONFIG;
+       global $_CONFIG;
 
        // Shall we add bonus points?
-       if ($CONFIG['bonus_active'] == 'N') return;
+       if ($_CONFIG['bonus_active'] == 'N') return;
 
        // Switch to jackpot-mode when no UID is supplied but userid-mode is selected
-       if (($CONFIG['bonus_mode'] == "UID") && ($CONFIG['bonus_uid'] == "0")) $CONFIG['bonus_mode'] = "JACKPOT";
+       if (($_CONFIG['bonus_mode'] == "UID") && ($_CONFIG['bonus_uid'] == "0")) $_CONFIG['bonus_mode'] = "JACKPOT";
 
        if ($MODE == "login_bonus")
        {
                // Login bonus detected
-               $POINTS = $CONFIG['login_bonus'];
+               $points = $_CONFIG['login_bonus'];
        }
         else
        {
                // Direct points supplied
-               $POINTS = $MODE;
+               $points = $MODE;
        }
 
        // Subtract points from...
-       switch ($CONFIG['bonus_mode'])
+       switch ($_CONFIG['bonus_mode'])
        {
        case "JACKPOT": // ... jackpot
-               if ((SUB_JACKPOT($POINTS) == -1) && ($CONFIG['bonus_uid'] > 0))
+               if ((SUB_JACKPOT($points) == -1) && ($_CONFIG['bonus_uid'] > 0))
                {
                        // Check points amount first...
-                       $TOTAL = GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_data", "used_points");
-                       if ($TOTAL >= $POINTS)
+                       $TOTAL = GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_data", "used_points");
+                       if ($TOTAL >= $points)
                        {
                                // Subtract points from userid's account
                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
-                                array(bigintval($POINTS), bigintval($CONFIG['bonus_uid'])), __FILE__, __LINE__);
+                                array(bigintval($points), bigintval($_CONFIG['bonus_uid'])), __FILE__, __LINE__);
 
                                // Update mediadata as well
                                if (GET_EXT_VERSION("mediadata") >= "0.0.4")
                                {
                                        // Update database
-                                       MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
+                                       MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
                                }
                        }
                }
@@ -228,24 +228,24 @@ function BONUS_POINTS_HANDLER($MODE)
 
        case "UID": // ... userid's account
                // Check his amount first
-               $TOTAL = GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($CONFIG['bonus_uid'], "user_data", "used_points");
-               if ($TOTAL >= $POINTS)
+               $TOTAL = GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_points", "points") - GET_TOTAL_DATA($_CONFIG['bonus_uid'], "user_data", "used_points");
+               if ($TOTAL >= $points)
                {
                        // Subtract points from userid's account
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
-                        array(bigintval($POINTS), bigintval($CONFIG['bonus_uid'])),  __FILE__, __LINE__);
+                        array(bigintval($points), bigintval($_CONFIG['bonus_uid'])),  __FILE__, __LINE__);
 
                        // Update mediadata as well
                        if (GET_EXT_VERSION("mediadata") >= "0.0.4")
                        {
                                // Update database
-                               MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $POINTS);
+                               MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $points);
                        }
                }
                 else
                {
                        // Try to subtract from jackpot
-                       $DUMMY = SUB_JACKPOT($POINTS);
+                       $DUMMY = SUB_JACKPOT($points);
                }
                break;
        }
@@ -253,9 +253,9 @@ function BONUS_POINTS_HANDLER($MODE)
 //
 function BONUS_PURGE_EXPIRED_TURBO_BONUS()
 {
-       global $CONFIG;
+       global $_CONFIG;
        // Remove entries
-       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < ".(time() - $CONFIG['bonus_timeout']), __FILE__, __LINE__);
+       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < ".(time() - $_CONFIG['bonus_timeout']), __FILE__, __LINE__);
        $DELETED = SQL_AFFECTEDROWS($result);
        if ($DELETED > 0)
        {