X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=doubler.php;h=590af15e0ad424177d56fd9a18f28d88acab023c;hp=791dc3e025881aefc00a0cef03c5d71397b34c3e;hb=eac9b7b757e50ad6536ccc00f46eae5d194a6b12;hpb=a2ca374f65976d21651fffb64a78d3a9678bb3b8 diff --git a/doubler.php b/doubler.php index 791dc3e025..590af15e0a 100644 --- a/doubler.php +++ b/doubler.php @@ -1,7 +1,7 @@ 0) { - // Do we have nickname or userid set? - if (isNicknameUsed(determineReferalId())) { - // 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(determineReferalId()), __FILE__, __LINE__); - } else { - // Direct userid entered - $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", - array(determineReferalId()), __FILE__, __LINE__); - } - - // Load data - list($rid, $status_ref) = SQL_FETCHROW($result); - $GLOBALS['refid'] = bigintval($rid); - - // Free memory - SQL_FREERESULT($result); -} // END - if - -// Init userid -$userid = 0; - -// If no account was found set default refid and status to CONFIRMED -if (empty($GLOBALS['refid'])) { - // Determine referal id again - $GLOBALS['refid'] = determineReferalId(); - $status = 'CONFIRMED'; -} // END - if - // Init content array $content = array( 'message' => '', @@ -103,21 +69,18 @@ if (isFormSent()) { if ((isPostRequestElementSet('userid')) && (isPostRequestElementSet('pass')) && (isPostRequestElementSet('points'))) { // Probe for nickname extension and if a nickname was entered if (isNickNameUsed(postRequestElement('userid'))) { - // 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(postRequestElement('userid')), __FILE__, __LINE__); + // Nickname in URL, so load the id + fetchUserData(postRequestElement('userid'), 'nickname'); } else { // Direct userid entered - $result = SQL_QUERY_ESC("SELECT `userid`, `status, `password` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", - array(bigintval(postRequestElement('userid'))), __FILE__, __LINE__); + fetchUserData(postRequestElement('userid')); } - // Load data - list($userid, $status, $password) = SQL_FETCHROW($result); - $userid = bigintval($userid); - - // Free result - SQL_FREERESULT($result); + // Is the data valid? + if (!isUserDataValid()) { + // Output message that the userid is not okay + loadTemplate('admin_settings_saved', false, getMessage('DOUBLER_USERID_INVALID')); + } // END - if // Remove any dots and unwanted chars from the points setRequestPostElement('points', bigintval(round(convertCommaToDot(postRequestElement('points'))))); @@ -126,22 +89,22 @@ if (isFormSent()) { $probe_points = ((postRequestElement('points') >= getConfig('doubler_min')) && (postRequestElement('points') <= getConfig('doubler_max'))); // Check all together - if ((!empty($userid)) && ($password == generateHash(postRequestElement('pass'), substr($password, 0, -40))) && ($status == 'CONFIRMED') && ($probe_points)) { + if ((isUserDataValid()) && (getUserData('password') == generateHash(postRequestElement('pass'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) { // Nickname resolved to a unique userid or direct userid entered by the member - $GLOBALS['doubler_userid'] = $userid; + $GLOBALS['doubler_userid'] = getUserData('userid'); // Calulcate points - $points = countSumTotalData($userid, 'user_points', 'points') - countSumTotalData($userid, 'user_data', 'used_points'); + $points = countSumTotalData(getUserData('userid'), 'user_points', 'points') - countSumTotalData(getUserData('userid'), 'user_data', 'used_points'); // So let's continue with probing his points amount if (($points - getConfig('doubler_left') - postRequestElement('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')", - array($userid, determineReferalId(), bigintval(postRequestElement('points') * 2)), __FILE__, __LINE__); + array(getUserData('userid'), determineReferalId(), bigintval(postRequestElement('points') * 2)), __FILE__, __LINE__); // Subtract entered points - subtractPoints('doubler', $userid, postRequestElement('points')); + subtractPoints('doubler', getUserData('userid'), postRequestElement('points')); // Add points to "total payed" including charge $points = postRequestElement('points') - postRequestElement('points') * getConfig('doubler_charge'); @@ -149,7 +112,7 @@ if (isFormSent()) { incrementConfigEntry('doubler_points', $points); // Add second line for the referal but only when userid != refid - if ((determineReferalId() > 0) && (determineReferalId() != $userid)) { + if ((determineReferalId() > 0) && (determineReferalId() != getUserData('userid'))) { // 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( @@ -169,13 +132,13 @@ if (isFormSent()) { // Not enougth points left $content['message'] = getMessage('DOUBLER_FORM_NO_POINTS_LEFT'); } - } elseif ($status == 'CONFIRMED') { + } elseif (getUserData('status') == 'CONFIRMED') { // Account is unconfirmed! $content['message'] = getMessage('DOUBLER_FORM_WRONG_PASS'); - } elseif ($status == 'UNCONFIRMED') { + } elseif (getUserData('status') == 'UNCONFIRMED') { // Account is unconfirmed! $content['message'] = getMessage('DOUBLER_FORM_STATUS_UNCONFIRMED'); - } elseif ($status == 'LOCKED') { + } elseif (getUserData('status') == 'LOCKED') { // Account is locked by admin / holiday! $content['message'] = getMessage('DOUBLER_FORM_STATUS_LOCKED'); } elseif (postRequestElement('points') < getConfig('doubler_min')) { @@ -201,7 +164,7 @@ if (isFormSent()) { // points not entered $content['message'] = getMessage('DOUBLER_FORM_404_POINTS'); } -} +} // END - if (isFormSet()) // Shall I check for points immediately? if (getConfig('doubler_send_mode') == 'DIRECT') loadInclude('inc/mails/doubler_mails.php'); @@ -216,9 +179,9 @@ $content['banner'] = loadTemplate('doubler_banner', true); $content['header'] = loadTemplate('doubler_header', true); $content['footer'] = loadTemplate('doubler_footer', true); -if (!empty($userid)) { +if (isUserDataValid()) { // Transfer userid/nickname to constant - $content['refid'] = $userid; + $content['refid'] = getUserData('userid'); } else { // Transfer userid/nickname to constant $content['refid'] = determineReferalId(); @@ -236,7 +199,7 @@ if (isExtensionActive('nickname')) { // Choose login/nickname $content['enter_login'] = getMessage('GUEST_ENTER_LOGIN_NICKNAME'); } else { - // Simple login ID + // Simple login id $content['enter_login'] = getMessage('GUEST_ENTER_LOGIN'); }