Fix for the fix... ;-)
[mailer.git] / doubler.php
index e8a088bc8cefdef9885e7ab482571898e9d1dcf1..87f177fc6e0f1b53fbf5c3ebc9e19f423f88cef7 100644 (file)
@@ -42,13 +42,13 @@ $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
 // Set module
 $GLOBALS['module'] = "doubler";
 $GLOBALS['refid'] = 0;
-$CSS = "0";
+$CSS = 0;
 
 // Load the required file(s)
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
+if (isBooleanConstantAndTrue('mxchange_installed'))
 {
        // Probe for referral ID
        if (!empty($_GET['refid'])) $GLOBALS['refid'] = bigintval($_GET['refid']);
@@ -64,7 +64,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
         else
        {
                // Direct userid entered
-               $result = SQL_QUERY_ESC("SELECT userid, status FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT userid, status FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
                 array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
        }
 
@@ -99,7 +99,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                         else
                        {
                                // Direct userid entered
-                               $result = SQL_QUERY_ESC("SELECT userid, status, password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
+                               $result = SQL_QUERY_ESC("SELECT userid, status, password FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
                                 array(bigintval($_POST['userid'])), __FILE__, __LINE__);
                        }
 
@@ -134,28 +134,13 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                                         array($uid, bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2)), __FILE__, __LINE__);
 
                                        // Subtract entered points
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s WHERE userid=%d LIMIT 1",
-                                        array($_POST['points'], $uid), __FILE__, __LINE__);
-
-                                       // Update mediadata as well
-                                       if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                                       {
-                                               // Update database
-                                               MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $_POST['points']);
-                                       }
+                                       SUB_POINTS($uid, $_POST['points']);
 
                                        // Add points to "total payed" including charge
                                        $points = $_POST['points'] - $_POST['points'] * $_CONFIG['doubler_charge'];
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET doubler_points=doubler_points+%s WHERE config=0 LIMIT 1",
-                                        array($points), __FILE__, __LINE__);
+                                       UPDATE_CONFIG("doubler_points", $points, "+");
                                        $_CONFIG['doubler_points'] += $points;
 
-                                       // Destroy cache
-                                       if (GET_EXT_VERSION("cache") >= "0.1.2")
-                                       {
-                                               if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
-                                       }
-
                                        // Add second line for the referral but only when uid != refid
                                        if (($GLOBALS['refid'] > 0) && ($GLOBALS['refid'] != $uid))
                                        {
@@ -167,7 +152,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                                        }
 
                                        // Update usage counter
-                                       $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET doubler_counter=doubler_counter+1 WHERE config=0 LIMIT 1", __FILE__, __LINE__);
+                                       UPDATE_CONFIG("doubler_counter", 1, "+");
                                        $_CONFIG['doubler_counter']++;
 
                                        // Set constant