]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-payout.php
fooRequestElementBar() functions renamed, adding of request parameters added:
[mailer.git] / inc / modules / member / what-payout.php
index 3f8c23e43deec99f10a89c7264660b7e286cb1e6..3a7c048194f9b94eae3ec4ab7cc61cb739a7d850 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 04/12/2004 *
- * ================                             Last change: 12/01/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 04/12/2004 *
+ * ===================                          Last change: 12/01/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-payout.php                                  *
@@ -53,28 +53,8 @@ if ((!isExtensionActive('payout')) && (!isAdmin())) {
        return;
 } // END - if
 
-$result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY level", __FILE__, __LINE__);
-$totalPoints = '0';
-while ($content = SQL_FETCHARRAY($result_depths)) {
-       // Load referal points
-       $result_points = SQL_QUERY_ESC("SELECT `points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
-               array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
-
-       // Entry found?
-       if (SQL_NUMROWS($result_points) == 1) {
-               // Load points
-               list($points) = SQL_FETCHROW($result_points);
-
-               // Add them to total
-               $totalPoints += $points;
-       } // END - if
-
-       // Free result
-       SQL_FREERESULT($result_points);
-} // END - while
-
-// Free memory
-SQL_FREERESULT($result_depths);
+// Get total points
+$totalPoints = countSumTotalData(getMemberId(), 'user_points', 'points');
 
 // Get used points
 $usedPoints = countSumTotalData(getMemberId(), 'user_data', 'used_points');
@@ -85,7 +65,7 @@ $totalPoints = ($totalPoints - $usedPoints);
 // Sanity check...
 if (empty($totalPoints)) $totalPoints = '0.00000';
 
-if (!isGetRequestElementSet('payout')) {
+if (!isGetRequestParameterSet('payout')) {
        // Load payout types
        $result = SQL_QUERY_ESC("SELECT
        `id`, `type`, `rate`, `min_points`, `allow_url`
@@ -120,7 +100,7 @@ ORDER BY
                        while ($content = SQL_FETCHARRAY($result_payouts)) {
                                // Translate status
                                $content['status'] = getMessage('PAYOUT_MEMBER_STATUS_'.strtoupper($content['status']).'');
-                               $content['status'] = "<div class=\"member_failed\">".$content['status']."</div>";
+                               $content['status'] = '<div class="member_failed">' . $content['status'] . '</div>';
 
                                // Nothing entered must be secured in member/what-payputs.php !
                                if ($content['allow'] == 'Y') {
@@ -132,7 +112,7 @@ ORDER BY
                                                // Textlink
                                                $content['target_account'] = $content['alt'];
                                        }
-                                       $content['target_bank'] = "<a href=\"".generateDerefererUrl($content['url'])."\" target=\"_blank\">{--CLICK_HERE--}</a>";
+                                       $content['target_bank'] = '<a href="' . generateDerefererUrl($content['url']) . '" target="_blank">{--CLICK_HERE--}</a>';
                                } else {
                                        // e-currency payout request
                                        if (empty($content['target_account'])) $content['target_account'] = '---';
@@ -170,7 +150,7 @@ ORDER BY
 } else {
        // Chedk if he can get paid by selected type
        $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url AS allow FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
-               array(bigintval(getRequestElement('payout'))), __FILE__, __LINE__);
+               array(bigintval(getRequestParameter('payout'))), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result) == 1) {
                // id is valid so load the data
@@ -182,8 +162,8 @@ ORDER BY
 
                // Calulcate points from submitted amount
                $points = '0';
-               if (isPostRequestElementSet('payout')) {
-                       $points  = bigintval(postRequestElement('payout')) / $content['rate'];
+               if (isPostRequestParameterSet('payout')) {
+                       $points  = bigintval(postRequestParameter('payout')) / $content['rate'];
                        $PAY_MAX = $max / $content['rate'];
                }
 
@@ -192,8 +172,8 @@ ORDER BY
                        // Ok, he can get be paid
                        if ((isFormSent()) && ($points <= $PAY_MAX) && ($points >= $content['min_points'])) {
                                // Remember points in array
-                               setRequestPostElement('payout_points', translateComma($points));
-                               setRequestPostElement('type'         , $content['type']);
+                               setPostRequestParameter('payout_points', translateComma($points));
+                               setPostRequestParameter('type'         , $content['type']);
 
                                // Subtract points from member's account
                                subtractPoints('payout', getMemberId(), $points);
@@ -205,11 +185,11 @@ ORDER BY
 VALUES (%s,%s,%s, UNIX_TIMESTAMP(), 'NEW','%s','%s','%s')",
                                        array(
                                                getMemberId(),
-                                               bigintval(postRequestElement('payout')),
-                                               bigintval(getRequestElement('payout')),
-                                               postRequestElement('turl'),
-                                               postRequestElement('alt'),
-                                               postRequestElement('banner')
+                                               bigintval(postRequestParameter('payout')),
+                                               bigintval(getRequestParameter('payout')),
+                                               postRequestParameter('turl'),
+                                               postRequestParameter('alt'),
+                                               postRequestParameter('banner')
                                        ), __FILE__, __LINE__);
 
                                        // Load templates
@@ -225,11 +205,11 @@ VALUES (%s,%s,%s, UNIX_TIMESTAMP(), 'NEW','%s','%s','%s')",
 VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
                                        array(
                                                getMemberId(),
-                                               bigintval(postRequestElement('payout')),
-                                               bigintval(postRequestElement('account')),
-                                               postRequestElement('bank'),
-                                               bigintval(getRequestElement('payout')),
-                                               postRequestElement('pass')
+                                               bigintval(postRequestParameter('payout')),
+                                               bigintval(postRequestParameter('account')),
+                                               postRequestParameter('bank'),
+                                               bigintval(getRequestParameter('payout')),
+                                               postRequestParameter('pass')
                                        ), __FILE__, __LINE__);
 
                                        // Load templates
@@ -259,7 +239,7 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
                                $content = array(
                                        'max'    => $max,
                                        'type'   => $content['type'],
-                                       'payout' => bigintval(getRequestElement('payout'))
+                                       'payout' => bigintval(getRequestParameter('payout'))
                                );
 
                                // Generate banner order form
@@ -269,7 +249,7 @@ VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
                                $content = array(
                                        'max'    => $max,
                                        'type'   => $content['type'],
-                                       'payout' => bigintval(getRequestElement('payout'))
+                                       'payout' => bigintval(getRequestParameter('payout'))
                                );
 
                                // Generate normal form