]> git.mxchange.org Git - mailer.git/blobdiff - doubler.php
More rewrites to make use of (cached) wrapper functions
[mailer.git] / doubler.php
index 593f796f0ab2ce15f2280c8d8d3978f20f05da79..8685143cf2f2f935ab93a199e9f15c76424c3fe9 100644 (file)
@@ -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 *
@@ -79,7 +80,7 @@ if (isFormSent()) {
                // 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
 
                // Remove any dots and unwanted chars from the points
@@ -97,27 +98,31 @@ 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') - postRequestParameter('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(postRequestParameter('points') * 2)), __FILE__, __LINE__);
+                                       array(
+                                               getUserData('userid'),
+                                               makeDatabaseUserId(determineReferalId()),
+                                               bigintval(postRequestParameter('points') * 2)
+                                       ), __FILE__, __LINE__);
 
                                // Subtract entered points
                                subtractPoints('doubler', getUserData('userid'), postRequestParameter('points'));
 
                                // Add points to "total payed" including charge
-                               $points = postRequestParameter('points') - postRequestParameter('points') * getConfig('doubler_charge');
+                               $points = postRequestParameter('points') - postRequestParameter('points') * getConfig('doubler_charge') / 100;
                                updateConfiguration('doubler_points', $points, '+');
                                incrementConfigEntry('doubler_points', $points);
 
                                // Add second line for the referal but only when userid != refid
-                               if ((determineReferalId() > 0) && (determineReferalId() != getUserData('userid'))) {
+                               if ((isValidUserId(determineReferalId())) && (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(
-                                                       determineReferalId(),
-                                                       bigintval(postRequestParameter('points') * 2 * getConfig('doubler_ref'))
+                                                       makeDatabaseUserId(determineReferalId()),
+                                                       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,39 +135,39 @@ if (isFormSent()) {
                                $content['message'] = loadTemplate('doubler_reflink', true, postRequestParameter('userid'));
                        } else {
                                // Not enougth points left
-                               $content['message'] = getMessage('DOUBLER_FORM_NO_POINTS_LEFT');
+                               $content['message'] = '{--DOUBLER_FORM_NO_POINTS_LEFT--}';
                        }
                } elseif (getUserData('status') == 'CONFIRMED') {
                        // Account is unconfirmed!
-                       $content['message'] = getMessage('DOUBLER_FORM_WRONG_PASS');
+                       $content['message'] = '{--DOUBLER_FORM_WRONG_PASS--}';
                } elseif (getUserData('status') == 'UNCONFIRMED') {
                        // Account is unconfirmed!
-                       $content['message'] = getMessage('DOUBLER_FORM_STATUS_UNCONFIRMED');
+                       $content['message'] = '{--DOUBLER_FORM_STATUS_UNCONFIRMED--}';
                } elseif (getUserData('status') == 'LOCKED') {
                        // Account is locked by admin / holiday!
-                       $content['message'] = getMessage('DOUBLER_FORM_STATUS_LOCKED');
+                       $content['message'] = '{--DOUBLER_FORM_STATUS_LOCKED--}';
                } elseif (postRequestParameter('points') < getConfig('doubler_min')) {
                        // Not enougth points entered
-                       $content['message'] = getMessage('DOUBLER_FORM_POINTS_MIN');
+                       $content['message'] = '{--DOUBLER_FORM_POINTS_MIN--}';
                } elseif (postRequestParameter('points') > getConfig('doubler_max')) {
                        // Too much points entered
-                       $content['message'] = getMessage('DOUBLER_FORM_POINTS_MAX');
+                       $content['message'] = '{--DOUBLER_FORM_POINTS_MAX--}';
                } elseif (isNickNameUsed(postRequestParameter('userid'))) {
                        // Cannot resolv nickname -> userid
-                       $content['message'] = getMessage('DOUBLER_FORM_404_NICKNAME');
+                       $content['message'] = '{--DOUBLER_FORM_404_NICKNAME--}';
                } else {
                        // Wrong password or account not found
-                       $content['message'] = getMessage('DOUBLER_FORM_404_MEMBER');
+                       $content['message'] = '{--DOUBLER_FORM_404_MEMBER--}';
                }
        } elseif (!isPostRequestParameterSet('userid')) {
                // Login not entered
-               $content['message'] = getMessage('DOUBLER_FORM_404_LOGIN');
+               $content['message'] = '{--DOUBLER_FORM_404_LOGIN--}';
        } elseif (!isPostRequestParameterSet('pass')) {
                // Password not entered
-               $content['message'] = getMessage('DOUBLER_FORM_404_PASSWORD');
+               $content['message'] = '{--DOUBLER_FORM_404_PASSWORD--}';
        } elseif (!isPostRequestParameterSet('points')) {
                // points not entered
-               $content['message'] = getMessage('DOUBLER_FORM_404_POINTS');
+               $content['message'] = '{--DOUBLER_FORM_404_POINTS--}';
        }
 } // END - if (isFormSet())
 
@@ -187,34 +192,21 @@ 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
-       $content['enter_login'] = getMessage('GUEST_ENTER_LOGIN_NICKNAME');
+       $content['enter_login'] = '{--GUEST_ENTER_LOGIN_NICKNAME--}';
 } else {
        // Simple login id
-       $content['enter_login'] = getMessage('GUEST_ENTER_LOGIN');
+       $content['enter_login'] = '{--GUEST_ENTER_LOGIN--}';
 }
 
 // Which mail-send-mode did the admin setup?
-$content['payout_time'] = getMessage('DOUBLER_PAYOUT_TIME_' . getConfig('doubler_send_mode'));
+$content['payout_time'] = '{--DOUBLER_PAYOUT_TIME_' . getConfig('doubler_send_mode') . '--}';
 
 // 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);