also prevent it in .htacces. You may want to add this to one of your files in /etc...
[mailer.git] / doubler.php
index 80b913e61e74076483032284995e540f7d39e943..c1b3b91a6ede2251280abda4083589d942a6fec9 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Punkteverdoppler                                 *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 require('inc/libs/security_functions.php');
 
 // Init start time
-$GLOBALS['startTime'] = microtime(true);
+$GLOBALS['__start_time'] = microtime(TRUE);
 
-// Set module
-$GLOBALS['module'] = 'doubler';
-$GLOBALS['output_mode'] = '0';
+// Set module and output mode
+$GLOBALS['__module']      = 'doubler';
+$GLOBALS['__output_mode'] = '0';
 
-// Load the required file(s)
-require('inc/config-global.php');
+// Initialize application
+require('inc/init.php');
 
 // Set content type
 setContentType('text/html');
@@ -76,7 +71,7 @@ if (isFormSent()) {
                }
 
                // Is the data valid?
-               if (!isUserDataValid()) {
+               if (!isValidUserData()) {
                        // Output message that the userid is not okay
                        displayMessage('{--DOUBLER_USERID_INVALID--}');
                } // END - if
@@ -85,10 +80,10 @@ if (isFormSent()) {
                setPostRequestElement('points', bigintval(round(convertCommaToDot(postRequestElement('points')))));
 
                // Probe for enough points
-               $probe_points = ((postRequestElement('points') >= getConfig('doubler_min')) && (postRequestElement('points') <= getConfig('doubler_max')));
+               $probe_points = ((postRequestElement('points') >= getDoublerMin()) && (postRequestElement('points') <= getDoublerMax()));
 
                // Check all together
-               if ((isUserDataValid()) && (getUserData('password') == generateHash(postRequestElement('password'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) {
+               if ((isValidUserData()) && (getUserData('password') == generateHash(postRequestElement('password'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) {
                        // Nickname resolved to a unique userid or direct userid entered by the member
                        $GLOBALS['local_doubler_userid'] = getUserData('userid');
 
@@ -96,33 +91,33 @@ if (isFormSent()) {
                        $points = getTotalPoints(getUserData('userid'));
 
                        // So let's continue with probing his points amount
-                       if (($points - getConfig('doubler_left') - postRequestElement('points') * getConfig('doubler_charge') / 100) >= 0) {
+                       if (($points - getConfig('doubler_left') - postRequestElement('points') * getDoublerCharge() / 100) >= 0) {
                                // Enough points are left so let's continue with the doubling process
                                // Create doubling "account" with *DOUBLED* points
-                               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`,`refid`,`points`,`remote_ip`,`timemark`,`completed`,`is_ref`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(), 'N','N')",
+                               sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(), 'N','N')",
                                        array(
                                                getUserData('userid'),
-                                               makeZeroToNull(determineReferralId()),
+                                               convertZeroToNull(determineReferralId()),
                                                bigintval(postRequestElement('points') * 2),
-                                               detectRemoteAddr()
+                                               determineRealRemoteAddress()
                                        ), __FILE__, __LINE__);
 
                                // Subtract entered points and ignore return status
                                subtractPoints('doubler', getUserData('userid'), postRequestElement('points'));
 
                                // Add points to "total payed" including charge
-                               $points = postRequestElement('points') - postRequestElement('points') * getConfig('doubler_charge') / 100;
+                               $points = postRequestElement('points') - postRequestElement('points') * getDoublerCharge() / 100;
                                updateConfiguration('doubler_points', $points, '+');
                                incrementConfigEntry('doubler_points', $points);
 
                                // Add second line for the referral but only when userid != refid
-                               if ((isValidUserId(determineReferralId())) && (determineReferralId() != getUserData('userid'))) {
+                               if ((isValidId(determineReferralId())) && (determineReferralId() != 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,'%s',UNIX_TIMESTAMP(),'N','Y')",
+                                       sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_doubler` (`userid`, `refid`, `points`, `remote_ip`, `timemark`, `completed`, `is_ref`) VALUES (%s,0,%s,'%s',UNIX_TIMESTAMP(),'N','Y')",
                                                array(
-                                                       makeZeroToNull(determineReferralId()),
-                                                       (postRequestElement('points') * 2 * getConfig('doubler_ref') / 100),
-                                                       detectRemoteAddr()
+                                                       convertZeroToNull(determineReferralId()),
+                                                       (postRequestElement('points') * 2 * getDoublerRef() / 100),
+                                                       determineRealRemoteAddress()
                                                ), __FILE__, __LINE__);
 
                                        // And that's why we don't want to you more than one referral level of doubler-points. ^^^
@@ -132,7 +127,7 @@ if (isFormSent()) {
                                updateConfiguration('doubler_counter', 1, '+');
 
                                // Set constant
-                               $content['message'] = loadTemplate('doubler_reflink', true, postRequestElement('userid'));
+                               $content['message'] = loadTemplate('doubler_reflink', TRUE, postRequestElement('userid'));
                        } else {
                                // Not enougth points left
                                $content['message'] = '{--DOUBLER_FORM_NO_POINTS_LEFT--}';
@@ -146,10 +141,10 @@ if (isFormSent()) {
                } elseif (getUserData('status') == 'LOCKED') {
                        // Account is locked by admin / holiday!
                        $content['message'] = '{--DOUBLER_FORM_STATUS_LOCKED--}';
-               } elseif (postRequestElement('points') < getConfig('doubler_min')) {
+               } elseif (postRequestElement('points') < getDoublerMin()) {
                        // Not enougth points entered
                        $content['message'] = '{--DOUBLER_FORM_POINTS_MIN--}';
-               } elseif (postRequestElement('points') > getConfig('doubler_max')) {
+               } elseif (postRequestElement('points') > getDoublerMax()) {
                        // Too much points entered
                        $content['message'] = '{--DOUBLER_FORM_POINTS_MAX--}';
                } elseif (isNicknameUsed(postRequestElement('userid'))) {
@@ -172,21 +167,14 @@ if (isFormSent()) {
 } // END - if (isFormSet())
 
 // Shall I check for points immediately?
-if (getConfig('doubler_send_mode') == 'DIRECT') {
+if (getDoublerSendMode() == 'DIRECT') {
        loadInclude('inc/mails/doubler_mails.php');
 } // END - if
 
 // Output header
-loadIncludeOnce('inc/header.php');
-
-// Banner in text
-$content['banner'] = loadTemplate('doubler_banner', true);
-
-// Load header/footer templates
-$content['header'] = loadTemplate('doubler_header', true);
-$content['footer'] = loadTemplate('doubler_footer', true);
+loadPageHeader();
 
-if (isUserDataValid()) {
+if (isValidUserData()) {
        // Transfer userid/nickname to constant
        $content['refid'] = getUserData('userid');
 } else {
@@ -204,16 +192,16 @@ if (isExtensionActive('nickname')) {
 }
 
 // Which mail-send-mode did the admin setup?
-$content['payout_time'] = '{--DOUBLER_PAYOUT_TIME_' . getConfig('doubler_send_mode') . '--}';
+$content['payout_time'] = '{--DOUBLER_PAYOUT_TIME_' . getDoublerSendMode() . '--}';
 
 // Generate table with already payed out doubles
 $content['payout_history'] = generateDoublerTable(0, 'Y', 'N', 'DESC');
 
 // Output neccessary form for this
-loadTemplate('doubler_index', false, $content);
+loadTemplate('doubler_index', FALSE, $content);
 
 // Output footer
-loadIncludeOnce('inc/footer.php');
+loadPageFooter();
 
 // [EOF]
 ?>