X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=doubler.php;h=09d00fba02e5c7bab6c2772547509a44fb2a52e2;hp=34c7c7380cba253ff4d136a053006bf235ab1e98;hb=27f65d023a3388a8bd85be8ee5991f776f541847;hpb=f9a9c09e1ae257449bfd98f8854e321efba1dc3c diff --git a/doubler.php b/doubler.php index 34c7c7380c..09d00fba02 100644 --- a/doubler.php +++ b/doubler.php @@ -59,24 +59,31 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Probe for referal ID if (!empty($_GET['refid'])) $GLOBALS['refid'] = SQL_ESCAPE($_GET['refid']); - // Probe for nickname extension and if a nickname was supplied by URL - $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".round($GLOBALS['refid'])."") != $GLOBALS['refid'])); - if ($probe_nickname) { - // Nickname in URL, so load the ID - $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1", - array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); - } else { - // Direct userid entered - $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); - } + // Only check this if refid is provided! + if ($GLOBALS['refid'] > 0) { + // Probe for nickname extension and if a nickname was supplied by URL + $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".round($GLOBALS['refid'])."") != $GLOBALS['refid'])); + + // Do we have nickname or userid set? + if ($probe_nickname) { + // Nickname in URL, so load the ID + $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1", + array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); + } else { + // Direct userid entered + $result = SQL_QUERY_ESC("SELECT userid, status FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1", + array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); + } - // Load data - list($rid, $status_ref) = SQL_FETCHROW($result); - $GLOBALS['refid'] = bigintval($rid); + // Load data + list($rid, $status_ref) = SQL_FETCHROW($result); + $GLOBALS['refid'] = bigintval($rid); + + // Free memory + SQL_FREERESULT($result); + } // END - if - // Free memory - SQL_FREERESULT($result); + // Init userid $uid = 0; // If no account was found set default refid and status to CONFIRMED @@ -97,11 +104,11 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { if ($probe_nickname) { // Nickname in URL, so load the ID $result = SQL_QUERY_ESC("SELECT userid, status, password FROM `"._MYSQL_PREFIX."_user_data` WHERE nickname='%s' LIMIT 1", - array($_POST['userid']), __FILE__, __LINE__); + array($_POST['userid']), __FILE__, __LINE__); } else { // Direct userid entered $result = SQL_QUERY_ESC("SELECT userid, status, password FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1", - array(bigintval($_POST['userid'])), __FILE__, __LINE__); + array(bigintval($_POST['userid'])), __FILE__, __LINE__); } // Load data @@ -126,12 +133,11 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { $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 - getConfig('doubler_left') - $_POST['points'] * getConfig('doubler_charge')) >= 0) - { + if (($points - getConfig('doubler_left') - $_POST['points'] * getConfig('doubler_charge')) >= 0) // Enough points are left so let's continue with the doubling process // Create doubling "account" width *DOUBLED* points - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_doubler (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s','%s','%s','".GET_REMOTE_ADDR()."', UNIX_TIMESTAMP(), 'N','N')", - array($uid, bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2)), __FILE__, __LINE__); + SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_doubler (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s','%s','%s','".GET_REMOTE_ADDR()."', UNIX_TIMESTAMP(), 'N','N')", + array($uid, bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2)), __FILE__, __LINE__); // Subtract entered points SUB_POINTS("doubler", $uid, $_POST['points']); @@ -139,20 +145,23 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Add points to "total payed" including charge $points = $_POST['points'] - $_POST['points'] * getConfig('doubler_charge'); UPDATE_CONFIG("doubler_points", $points, "+"); - getConfig('doubler_points') += $points; + incrementConfigEntry('doubler_points', $points); // Add second line for the referal 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','".GET_REMOTE_ADDR()."',UNIX_TIMESTAMP(),'N','Y')", - array(bigintval($GLOBALS['refid']), bigintval($_POST['points'] * 2 * getConfig('doubler_ref'))), __FILE__, __LINE__); + SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_doubler (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s',0,'%s','".GET_REMOTE_ADDR()."',UNIX_TIMESTAMP(),'N','Y')", + array( + bigintval($GLOBALS['refid']), + bigintval($_POST['points'] * 2 * getConfig('doubler_ref')) + ), __FILE__, __LINE__); - // And that's why we dont't want to you more than one referal level of doubler-points. ^^^ + // And that's why we don't want to you more than one referal level of doubler-points. ^^^ } // END - if // Update usage counter UPDATE_CONFIG("doubler_counter", 1, "+"); - $_CONFIG['doubler_counter']++; + incrementCondigEntry('doubler_counter'); // Set constant define('__DOUBLER_MSG', LOAD_TEMPLATE("doubler_reflink", true, $_POST['userid']));