X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=doubler.php;h=abcc79b9f3ae0370107203ea8eb56506d16d8558;hp=9b6745a31d70cf50ebfdfa030a2bdb9889e126cf;hb=9afd6ec5878544a7982c50ed9c0dd7de37606d5b;hpb=64c8349613addc3da2242c5cd6b99d64e3fb5f8e diff --git a/doubler.php b/doubler.php index 9b6745a31d..abcc79b9f3 100644 --- a/doubler.php +++ b/doubler.php @@ -44,7 +44,7 @@ $GLOBALS['startTime'] = microtime(true); // Set module $GLOBALS['module'] = 'doubler'; -$GLOBALS['output_mode'] = 0; +$GLOBALS['output_mode'] = '0'; // Load the required file(s) require('inc/config-global.php'); @@ -55,39 +55,6 @@ setContentType('text/html'); // Is the 'doubler' extension active? redirectOnUninstalledExtension('doubler'); -// Probe for referal ID -if (isGetRequestElementSet('refid')) $GLOBALS['refid'] = getRequestElement('refid'); - -// Only check this if refid is provided! -if (determineReferalId() > 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'])) { - $GLOBALS['refid'] = getConfig('def_refid'); - $status = 'CONFIRMED'; -} // END - if - // Init content array $content = array( 'message' => '', @@ -102,18 +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); + // 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 // Free result SQL_FREERESULT($result); @@ -125,22 +92,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'); @@ -148,7 +115,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( @@ -168,13 +135,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')) { @@ -200,7 +167,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'); @@ -215,9 +182,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(); @@ -235,7 +202,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'); } @@ -243,7 +210,7 @@ if (isExtensionActive('nickname')) { $content['payout_time'] = getMessage('DOUBLER_PAYOUT_TIME_' . getConfig('doubler_send_mode')); // Generate table with already payed out doubles -$content['payout_history'] = generateDoublerTable('0', 'Y', 'N', 'DESC'); +$content['payout_history'] = generateDoublerTable(0, 'Y', 'N', 'DESC'); // Generate timemark $content['timeout_mark'] = createFancyTime(getConfig('doubler_timeout'));