Deprecated variables for templates removed, mor EL-rewrites, getMessage() rewritten:
[mailer.git] / doubler.php
index abcc79b..f539083 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 02/13/2005 *
- * ===============                              Last change: 02/13/2005 *
+ * Mailer v0.2.1-FINAL                                Start: 02/13/2005 *
+ * ===================                          Last change: 02/13/2005 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : doubler.php                                      *
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -63,36 +64,33 @@ $content = array(
 // Begin with doubler script...
 if (isFormSent()) {
        // Secure points (so only integer/double values are allowed
-       setRequestPostElement('points', bigintval(postRequestElement('points')));
+       setPostRequestParameter('points', bigintval(postRequestParameter('points')));
 
        // Begin with doubling process
-       if ((isPostRequestElementSet('userid')) && (isPostRequestElementSet('pass')) && (isPostRequestElementSet('points'))) {
+       if ((isPostRequestParameterSet('userid')) && (isPostRequestParameterSet('pass')) && (isPostRequestParameterSet('points'))) {
                // Probe for nickname extension and if a nickname was entered
-               if (isNickNameUsed(postRequestElement('userid'))) {
+               if (isNickNameUsed(postRequestParameter('userid'))) {
                        // Nickname in URL, so load the id
-                       fetchUserData(postRequestElement('userid'), 'nickname');
+                       fetchUserData(postRequestParameter('userid'), 'nickname');
                } else {
                        // Direct userid entered
-                       fetchUserData(postRequestElement('userid'));
+                       fetchUserData(postRequestParameter('userid'));
                }
 
                // Is the data valid?
                if (!isUserDataValid()) {
                        // Output message that the userid is not okay
-                       loadTemplate('admin_settings_saved', false, getMessage('DOUBLER_USERID_INVALID'));
+                       loadTemplate('admin_settings_saved', false, '{--DOUBLER_USERID_INVALID--}');
                } // END - if
 
-               // Free result
-               SQL_FREERESULT($result);
-
                // Remove any dots and unwanted chars from the points
-               setRequestPostElement('points', bigintval(round(convertCommaToDot(postRequestElement('points')))));
+               setPostRequestParameter('points', bigintval(round(convertCommaToDot(postRequestParameter('points')))));
 
                // Probe for enough points
-               $probe_points = ((postRequestElement('points') >= getConfig('doubler_min')) && (postRequestElement('points') <= getConfig('doubler_max')));
+               $probe_points = ((postRequestParameter('points') >= getConfig('doubler_min')) && (postRequestParameter('points') <= getConfig('doubler_max')));
 
                // Check all together
-               if ((isUserDataValid()) && (getUserData('password') == generateHash(postRequestElement('pass'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) {
+               if ((isUserDataValid()) && (getUserData('password') == generateHash(postRequestParameter('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'] = getUserData('userid');
 
@@ -100,17 +98,17 @@ if (isFormSent()) {
                        $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) {
+                       if (($points - getConfig('doubler_left') - postRequestParameter('points') * getConfig('doubler_charge') / 100) >= 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(getUserData('userid'), determineReferalId(), bigintval(postRequestElement('points') * 2)), __FILE__, __LINE__);
+                                       array(getUserData('userid'), determineReferalId(), bigintval(postRequestParameter('points') * 2)), __FILE__, __LINE__);
 
                                // Subtract entered points
-                               subtractPoints('doubler', getUserData('userid'), postRequestElement('points'));
+                               subtractPoints('doubler', getUserData('userid'), postRequestParameter('points'));
 
                                // Add points to "total payed" including charge
-                               $points = postRequestElement('points') - postRequestElement('points') * getConfig('doubler_charge');
+                               $points = postRequestParameter('points') - postRequestParameter('points') * getConfig('doubler_charge') / 100;
                                updateConfiguration('doubler_points', $points, '+');
                                incrementConfigEntry('doubler_points', $points);
 
@@ -120,7 +118,7 @@ if (isFormSent()) {
                                        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(
                                                        determineReferalId(),
-                                                       bigintval(postRequestElement('points') * 2 * getConfig('doubler_ref'))
+                                                       bigintval(postRequestParameter('points') * 2 * getConfig('doubler_ref') / 100)
                                                ), __FILE__, __LINE__);
 
                                        // And that's why we don't want to you more than one referal level of doubler-points. ^^^
@@ -130,7 +128,7 @@ if (isFormSent()) {
                                updateConfiguration('doubler_counter', 1, '+');
 
                                // Set constant
-                               $content['message'] = loadTemplate('doubler_reflink', true, postRequestElement('userid'));
+                               $content['message'] = loadTemplate('doubler_reflink', true, postRequestParameter('userid'));
                        } else {
                                // Not enougth points left
                                $content['message'] = getMessage('DOUBLER_FORM_NO_POINTS_LEFT');
@@ -144,26 +142,26 @@ if (isFormSent()) {
                } elseif (getUserData('status') == 'LOCKED') {
                        // Account is locked by admin / holiday!
                        $content['message'] = getMessage('DOUBLER_FORM_STATUS_LOCKED');
-               } elseif (postRequestElement('points') < getConfig('doubler_min')) {
+               } elseif (postRequestParameter('points') < getConfig('doubler_min')) {
                        // Not enougth points entered
                        $content['message'] = getMessage('DOUBLER_FORM_POINTS_MIN');
-               } elseif (postRequestElement('points') > getConfig('doubler_max')) {
+               } elseif (postRequestParameter('points') > getConfig('doubler_max')) {
                        // Too much points entered
                        $content['message'] = getMessage('DOUBLER_FORM_POINTS_MAX');
-               } elseif (isNickNameUsed(postRequestElement('userid'))) {
+               } elseif (isNickNameUsed(postRequestParameter('userid'))) {
                        // Cannot resolv nickname -> userid
                        $content['message'] = getMessage('DOUBLER_FORM_404_NICKNAME');
                } else {
                        // Wrong password or account not found
                        $content['message'] = getMessage('DOUBLER_FORM_404_MEMBER');
                }
-       } elseif (!isPostRequestElementSet('userid')) {
+       } elseif (!isPostRequestParameterSet('userid')) {
                // Login not entered
                $content['message'] = getMessage('DOUBLER_FORM_404_LOGIN');
-       } elseif (!isPostRequestElementSet('pass')) {
+       } elseif (!isPostRequestParameterSet('pass')) {
                // Password not entered
                $content['message'] = getMessage('DOUBLER_FORM_404_PASSWORD');
-       } elseif (!isPostRequestElementSet('points')) {
+       } elseif (!isPostRequestParameterSet('points')) {
                // points not entered
                $content['message'] = getMessage('DOUBLER_FORM_404_POINTS');
        }
@@ -190,13 +188,6 @@ if (isUserDataValid()) {
        $content['refid'] = determineReferalId();
 }
 
-// Percent values etc.
-$content['charge'] = translateComma(getConfig('doubler_charge') * 100);
-$content['ref']    = translateComma(getConfig('doubler_ref') * 100);
-$content['total']  = translateComma(getConfig('doubler_points'));
-$content['min']    = translateComma(getConfig('doubler_min'));
-$content['max']    = translateComma(getConfig('doubler_max'));
-
 // Text "Enter login"
 if (isExtensionActive('nickname')) {
        // Choose login/nickname
@@ -212,12 +203,6 @@ $content['payout_time'] = getMessage('DOUBLER_PAYOUT_TIME_' . getConfig('doubler
 // Generate table with already payed out doubles
 $content['payout_history'] = generateDoublerTable(0, 'Y', 'N', 'DESC');
 
-// Generate timemark
-$content['timeout_mark'] = createFancyTime(getConfig('doubler_timeout'));
-
-// Points left to doubler
-$content['left'] = translateComma(DOUBLER_GET_TOTAL_POINTS_LEFT());
-
 // Output neccessary form for this
 loadTemplate('doubler_index', false, $content);