X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=doubler.php;h=53ee0682606feaf46f0c85fdc7c85c76fcc8ead3;hp=637bd4411df299debb54c0085b1cc1a3cfa81cc1;hb=ea2a5e6a7838127d2f9dec02ba68ec575188528b;hpb=e1653405d28923c78b2e292125306ccf61138f24 diff --git a/doubler.php b/doubler.php index 637bd4411d..53ee068260 100644 --- a/doubler.php +++ b/doubler.php @@ -35,10 +35,9 @@ 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']); @@ -65,7 +64,7 @@ if (defined('mxchange_installed') && (mxchange_installed)) 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__); } @@ -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'])) @@ -100,7 +99,7 @@ if (defined('mxchange_installed') && (mxchange_installed)) 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__); } @@ -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 @@ -135,41 +134,26 @@ if (defined('mxchange_installed') && (mxchange_installed)) 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__); - $CONFIG['doubler_points'] += $points; - - // Destroy cache - if (GET_EXT_VERSION("cache") >= "0.1.2") - { - if ($CACHE->cache_file("config", true)) $CACHE->cache_destroy(); - } + $points = $_POST['points'] - $_POST['points'] * $_CONFIG['doubler_charge']; + UPDATE_CONFIG("doubler_points", $points, "+"); + $_CONFIG['doubler_points'] += $points; // Add second line for the referral but only when uid != refid if (($GLOBALS['refid'] > 0) && ($GLOBALS['refid'] != $uid)) { // 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']++; + UPDATE_CONFIG("doubler_counter", 1, "+"); + $_CONFIG['doubler_counter']++; // Set constant define('__DOUBLER_MSG', LOAD_TEMPLATE("doubler_reflink", true, $_POST['userid'])); @@ -196,12 +180,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 +223,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 +248,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 +271,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); @@ -302,10 +286,10 @@ if (defined('mxchange_installed') && (mxchange_installed)) 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 +303,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... ;-)