Missing files added
[mailer.git] / doubler.php
index a630b2a4f484309aba4b47e28f3d1941311e1665..e8a088bc8cefdef9885e7ab482571898e9d1dcf1 100644 (file)
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
-global $what, $action;
+global $what, $action, $startTime;
+$GLOBALS['startTime'] = microtime(true);
 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
-if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']);
-if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);
 
 // Set module
 $GLOBALS['module'] = "doubler";
@@ -49,7 +48,7 @@ $CSS = "0";
 require ("inc/config.php");
 
 // Is the script installed?
-if (defined('mxchange_installed') && (mxchange_installed))
+if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
 {
        // Probe for referral ID
        if (!empty($_GET['refid'])) $GLOBALS['refid'] = bigintval($_GET['refid']);
@@ -78,7 +77,7 @@ if (defined('mxchange_installed') && (mxchange_installed))
        $uid = 0;
 
        // If no account was found set default refid and status to CONFIRMED
-       if (empty($GLOBALS['refid'])) { $GLOBALS['refid'] = $CONFIG['def_refid']; $status = "CONFIRMED"; }
+       if (empty($GLOBALS['refid'])) { $GLOBALS['refid'] = $_CONFIG['def_refid']; $status = "CONFIRMED"; }
 
        // Begin with doubler script...
        if (isset($_POST['ok']))
@@ -115,7 +114,7 @@ if (defined('mxchange_installed') && (mxchange_installed))
                        $_POST['points'] = bigintval(round(str_replace(",", ".", $_POST['points'])));
 
                        // Probe for enough points
-                       $probe_points = (($_POST['points'] >= $CONFIG['doubler_min']) && ($_POST['points'] <= $CONFIG['doubler_max']));
+                       $probe_points = (($_POST['points'] >= $_CONFIG['doubler_min']) && ($_POST['points'] <= $_CONFIG['doubler_max']));
 
                        // Check all together
                        if ((!empty($uid)) && ($password == generateHash($_POST['pass'], substr($password, 0, -40))) && ($status == "CONFIRMED") && ($probe_points))
@@ -124,10 +123,10 @@ if (defined('mxchange_installed') && (mxchange_installed))
                                $DOUBLER_UID = $uid;
 
                                // Calulcate points
-                               $POINTS = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
+                               $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
 
                                // So let's continue with probing his points amount
-                               if (($POINTS - $CONFIG['doubler_left'] - $_POST['points'] * $CONFIG['doubler_charge']) >= 0)
+                               if (($points - $_CONFIG['doubler_left'] - $_POST['points'] * $_CONFIG['doubler_charge']) >= 0)
                                {
                                        // Enough points are left so let's continue with the doubling process
                                        // Create doubling "account" width *DOUBLED* points
@@ -146,15 +145,15 @@ if (defined('mxchange_installed') && (mxchange_installed))
                                        }
 
                                        // 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",
+                                       $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__);
-                                       $CONFIG['doubler_points'] += $points;
+                                       $_CONFIG['doubler_points'] += $points;
 
                                        // Destroy cache
                                        if (GET_EXT_VERSION("cache") >= "0.1.2")
                                        {
-                                               if ($CACHE->cache_file("config", true)) $CACHE->cache_destroy();
+                                               if ($cacheInstance->cache_file("config", true)) $cacheInstance->cache_destroy();
                                        }
 
                                        // Add second line for the referral but only when uid != refid
@@ -162,14 +161,14 @@ if (defined('mxchange_installed') && (mxchange_installed))
                                        {
                                                // Okay add a refid line and apply refid percents
                                                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_doubler (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s', '0', '%s', '".$_SERVER['REMOTE_ADDR']."', UNIX_TIMESTAMP(), 'N', 'Y')",
-                                                array(bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2 * $CONFIG['doubler_ref'])), __FILE__, __LINE__);
+                                                array(bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2 * $_CONFIG['doubler_ref'])), __FILE__, __LINE__);
 
                                                // And that's why we dont't want to you more than one referral level of doubler-points. ^^^
                                        }
 
                                        // Update usage counter
-                                       $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET doubler_counter=doubler_counter+1 WHERE config='0' LIMIT 1", __FILE__, __LINE__);
-                                       $CONFIG['doubler_counter']++;
+                                       $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET doubler_counter=doubler_counter+1 WHERE config=0 LIMIT 1", __FILE__, __LINE__);
+                                       $_CONFIG['doubler_counter']++;
 
                                        // Set constant
                                        define('__DOUBLER_MSG', LOAD_TEMPLATE("doubler_reflink", true, $_POST['userid']));
@@ -196,12 +195,12 @@ if (defined('mxchange_installed') && (mxchange_installed))
                                // Account is locked by admin / holiday!
                                define('__ERROR_MSG', DOUBLER_FORM_STATUS_LOCKED);
                        }
-                        elseif ($_POST['points'] < $CONFIG['doubler_min'])
+                        elseif ($_POST['points'] < $_CONFIG['doubler_min'])
                        {
                                // Not enougth points entered
                                define('__ERROR_MSG', DOUBLER_FORM_POINTS_MIN);
                        }
-                        elseif ($_POST['points'] > $CONFIG['doubler_max'])
+                        elseif ($_POST['points'] > $_CONFIG['doubler_max'])
                        {
                                // Too much points entered
                                define('__ERROR_MSG', DOUBLER_FORM_POINTS_MAX);
@@ -239,7 +238,7 @@ if (defined('mxchange_installed') && (mxchange_installed))
        if (!defined('__ERROR_MSG'))   define('__ERROR_MSG'  , "");
 
        // Shall I check for points immediately?
-       if ($CONFIG['doubler_send_mode'] == "DIRECT") require(PATH."inc/doubler_send.php");
+       if ($_CONFIG['doubler_send_mode'] == "DIRECT") require(PATH."inc/doubler_send.php");
 
        // Output header
        include(PATH."inc/header.php");
@@ -264,15 +263,15 @@ if (defined('mxchange_installed') && (mxchange_installed))
         else
        {
                // Transfer default refid to constant
-               define('__REFID', $CONFIG['def_refid']);
+               define('__REFID', $_CONFIG['def_refid']);
        }
 
        // Percent values etc.
-       define('__CHARGE_VALUE', TRANSLATE_COMMA($CONFIG['doubler_charge'] * 100));
-       define('__REF_VALUE'   , TRANSLATE_COMMA($CONFIG['doubler_ref'] * 100));
-       define('__TOTAL_VALUE' , TRANSLATE_COMMA($CONFIG['doubler_points']));
-       define('__MIN_VALUE'   , TRANSLATE_COMMA($CONFIG['doubler_min']));
-       define('__MAX_VALUE'   , TRANSLATE_COMMA($CONFIG['doubler_max']));
+       define('__CHARGE_VALUE', TRANSLATE_COMMA($_CONFIG['doubler_charge'] * 100));
+       define('__REF_VALUE'   , TRANSLATE_COMMA($_CONFIG['doubler_ref'] * 100));
+       define('__TOTAL_VALUE' , TRANSLATE_COMMA($_CONFIG['doubler_points']));
+       define('__MIN_VALUE'   , TRANSLATE_COMMA($_CONFIG['doubler_min']));
+       define('__MAX_VALUE'   , TRANSLATE_COMMA($_CONFIG['doubler_max']));
 
        // Text "Enter login"
        if (EXT_IS_ACTIVE("nickname"))
@@ -287,7 +286,7 @@ if (defined('mxchange_installed') && (mxchange_installed))
        }
 
        // Which mail-send-mode did the admin setup?
-       switch ($CONFIG['doubler_send_mode'])
+       switch ($_CONFIG['doubler_send_mode'])
        {
        case "DIRECT":
                define('DOUBLER_PAYOUT_TIME', DOUBLER_PAYOUT_TIME_DIRECT);
@@ -299,13 +298,13 @@ if (defined('mxchange_installed') && (mxchange_installed))
        }
 
        // Generate table with already payed out doubles
-       define('__DOUBLER_PAYOUT_HISTORY', DOUBLER_GENERATE_TABLE("0", "Y", "N", "DESC"));
+       define('__DOUBLER_PAYOUT_HISTORY', DOUBLER_GENERATE_TABLE("0", 'Y', 'N', "DESC"));
 
        // Generate timemark
-       define('__TIMEOUT_MARK', CREATE_FANCY_TIME($CONFIG['doubler_timeout']));
+       define('__TIMEOUT_MARK', CREATE_FANCY_TIME($_CONFIG['doubler_timeout']));
 
        // Usage counter
-       define('__DOUBLER_COUNTER', $CONFIG['doubler_counter']);
+       define('__DOUBLER_COUNTER', $_CONFIG['doubler_counter']);
 
        // Points left to doubler
        define('__LEFT_VALUE', TRANSLATE_COMMA(DOUBLER_GET_TOTAL_POINTS_LEFT()));
@@ -319,7 +318,7 @@ if (defined('mxchange_installed') && (mxchange_installed))
  else
 {
        // You have to configure first!
-       LOAD_URL(URL."/install.php");
+       LOAD_URL("install.php");
 }
 
 // Really all done here... ;-)