X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=doubler.php;h=3a3cb93ba46aaf228ace04231e7d1b766a6a667f;hb=489ff30298f6e63d6bf2f2f42e3fbfd2148f8778;hp=2492b995d610197cbf992ec398b1acfbac045377;hpb=5071030af40e69ca4284642f44758964e18f5be8;p=mailer.git diff --git a/doubler.php b/doubler.php index 2492b995d6..3a3cb93ba4 100644 --- a/doubler.php +++ b/doubler.php @@ -39,10 +39,8 @@ // Load security stuff here require('inc/libs/security_functions.php'); -// Init "action" and "what" +// Init start time $GLOBALS['startTime'] = microtime(true); -$GLOBALS['what'] = ''; -$GLOBALS['action'] = ''; // Set module $GLOBALS['module'] = 'doubler'; @@ -56,85 +54,85 @@ require('inc/config-global.php'); redirectOnUninstalledExtension('doubler'); // Is the script installed? -if (isInstalled()) { - // Probe for referal ID - if (REQUEST_ISSET_GET(('refid'))) $GLOBALS['refid'] = REQUEST_GET(('refid')); +if (!isInstalled()) { + // You have to install first! + redirectToUrl('install.php'); +} // END - if + +// Probe for referal ID +if (REQUEST_ISSET_GET(('refid'))) $GLOBALS['refid'] = REQUEST_GET(('refid')); + +// Only check this if refid is provided! +if ($GLOBALS['refid'] > 0) { + // Do we have nickname or userid set? + if (isNicknameUsed($GLOBALS['refid'])) { + // 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); - // 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'])); + // Free memory + SQL_FREERESULT($result); +} // END - if - // Do we have nickname or userid set? - if ($probe_nickname === true) { +// Init userid +$uid = 0; + +// If no account was found set default refid and status to CONFIRMED +if (empty($GLOBALS['refid'])) { + $GLOBALS['refid'] = getConfig('def_refid'); + $status = 'CONFIRMED'; +} // END - if + +// Begin with doubler script... +if (isFormSent()) { + // Secure points (so only integer/double values are allowed + REQUEST_SET_POST('points', bigintval(REQUEST_POST('points'))); + + // Begin with doubling process + if ((REQUEST_ISSET_POST(('userid'))) && (REQUEST_ISSET_POST(('pass'))) && (REQUEST_ISSET_POST(('points')))) { + // Probe for nickname extension and if a nickname was entered + if (isNickNameUsed(REQUEST_POST('userid'))) { // 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__); + $result = SQL_QUERY_ESC("SELECT userid, status, password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1", + array(REQUEST_POST('userid')), __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__); + $result = SQL_QUERY_ESC("SELECT userid, status, password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", + array(bigintval(REQUEST_POST('userid'))), __FILE__, __LINE__); } // Load data - list($rid, $status_ref) = SQL_FETCHROW($result); - $GLOBALS['refid'] = bigintval($rid); + list($uid, $status, $password) = SQL_FETCHROW($result); + $uid = bigintval($uid); - // Free memory + // Free result SQL_FREERESULT($result); - } // END - if - - // Init userid - $uid = 0; - - // If no account was found set default refid and status to CONFIRMED - if (empty($GLOBALS['refid'])) { - $GLOBALS['refid'] = getConfig('def_refid'); - $status = 'CONFIRMED'; - } // END - if - - // Begin with doubler script... - if (IS_FORM_SENT()) { - // Secure points (so only integer/double values are allowed - REQUEST_SET_POST('points', bigintval(REQUEST_POST('points'))); - - // Begin with doubling process - if ((REQUEST_ISSET_POST(('userid'))) && (REQUEST_ISSET_POST(('pass'))) && (REQUEST_ISSET_POST(('points')))) { - // Probe for nickname extension and if a nickname was entered - $probe_nickname = ((EXT_IS_ACTIVE('nickname')) && ((''.round(REQUEST_POST('userid')).'') != REQUEST_POST('userid'))); - 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(REQUEST_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(REQUEST_POST('userid'))), __FILE__, __LINE__); - } - - // Load data - list($uid, $status, $password) = SQL_FETCHROW($result); - $uid = bigintval($uid); - // Free result - SQL_FREERESULT($result); + // Remove any dots and unwanted chars from the points + REQUEST_SET_POST('points', bigintval(round(convertCommaToDot(REQUEST_POST('points'))))); - // Remove any dots and unwanted chars from the points - REQUEST_SET_POST('points', bigintval(round(convertCommaToDot(REQUEST_POST('points'))))); + // Probe for enough points + $probe_points = ((REQUEST_POST('points') >= getConfig('doubler_min')) && (REQUEST_POST('points') <= getConfig('doubler_max'))); - // Probe for enough points - $probe_points = ((REQUEST_POST('points') >= getConfig('doubler_min')) && (REQUEST_POST('points') <= getConfig('doubler_max'))); + // Check all together + if ((!empty($uid)) && ($password == generateHash(REQUEST_POST('pass'), substr($password, 0, -40))) && ($status == 'CONFIRMED') && ($probe_points)) { + // Nickname resolved to a unique userid or direct userid entered by the member + $GLOBALS['doubler_uid'] = $uid; - // Check all together - if ((!empty($uid)) && ($password == generateHash(REQUEST_POST('pass'), substr($password, 0, -40))) && ($status == 'CONFIRMED') && ($probe_points)) { - // Nickname resolved to a unique userid or direct userid entered by the member - $GLOBALS['doubler_uid'] = $uid; + // Calulcate points + $points = GET_TOTAL_DATA($uid, 'user_points', 'points') - GET_TOTAL_DATA($uid, 'user_data', 'used_points'); - // Calulcate 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 - getConfig('doubler_left') - REQUEST_POST('points') * getConfig('doubler_charge')) >= 0) + // So let's continue with probing his points amount + if (($points - getConfig('doubler_left') - REQUEST_POST('points') * getConfig('doubler_charge')) >= 0) // Enough points are left so let's continue with the doubling process // Create doubling "account" width *DOUBLED* points SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_doubler` (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s','%s','%s','".detectRemoteAddr()."', UNIX_TIMESTAMP(), 'N','N')", @@ -153,8 +151,8 @@ if (isInstalled()) { // Okay add a refid line and apply refid percents SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_doubler` (userid, refid, points, remote_ip, timemark, completed, is_ref) VALUES ('%s',0,'%s','".detectRemoteAddr()."',UNIX_TIMESTAMP(),'N','Y')", array( - bigintval($GLOBALS['refid']), - bigintval(REQUEST_POST('points') * 2 * getConfig('doubler_ref')) + bigintval($GLOBALS['refid']), + bigintval(REQUEST_POST('points') * 2 * getConfig('doubler_ref')) ), __FILE__, __LINE__); // And that's why we don't want to you more than one referal level of doubler-points. ^^^ @@ -184,7 +182,7 @@ if (isInstalled()) { } elseif (REQUEST_POST('points') > getConfig('doubler_max')) { // Too much points entered define('__ERROR_MSG', getMessage('DOUBLER_FORM_POINTS_MAX')); - } elseif ($probe_nickname) { + } elseif (isNickNameUsed(REQUEST_POST('userid'))) { // Cannot resolv nickname -> userid define('__ERROR_MSG', getMessage('DOUBLER_FORM_404_NICKNAME')); } else { @@ -268,17 +266,11 @@ define('__DOUBLER_COUNTER', getConfig('doubler_counter')); define('__LEFT_VALUE', translateComma(DOUBLER_GET_TOTAL_POINTS_LEFT())); // Output neccessary form for this +// @TODO Rewrite all constants LOAD_TEMPLATE('doubler_index'); // Output footer loadIncludeOnce('inc/footer.php'); -} else { - // You have to install first! - redirectToUrl('install.php'); -} - -// Really all done here... ;-) -shutdown(); -// +// [EOF] ?>