]> git.mxchange.org Git - mailer.git/commitdiff
Code cleanup, more usage of API functions
authorRoland Häder <roland@mxchange.org>
Thu, 16 Sep 2010 22:38:44 +0000 (22:38 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 16 Sep 2010 22:38:44 +0000 (22:38 +0000)
inc/functions.php
inc/libs/online_functions.php
inc/modules/admin/what-list_sponsor.php
inc/modules/admin/what-unlock_sponsor.php
inc/template-functions.php
ref.php
sponsor_ref.php

index 0622a21253fab406f6936504702ebf86f0019418..5f3727065a6c36b0c7a2163add3d555586000bd8 100644 (file)
@@ -1950,7 +1950,7 @@ function determineReferalId () {
        }
 
        // Set cookie when default refid > 0
-       if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((!isValidUserId(getSession('refid'))) && (isConfigEntrySet('def_refid')) && (isValidUserId(getConfig('def_refid'))))) {
+       if (!isSessionVariableSet('refid') || (isValidUserId($GLOBALS['refid'])) || ((!isValidUserId(getSession('refid'))) && (isConfigEntrySet('def_refid')) && (isValidUserId(getConfig('def_refid'))))) {
                // Default is not found
                $found = false;
 
index 209e8bbe6d8814e5929db336b3f7d2dde3db21e8..a989e1f2a29be41dd08731557fc402900e5a277d 100644 (file)
@@ -95,7 +95,7 @@ LIMIT 1",
                        getModule(),
                        $action,
                        getWhat(),
-                       $userid,
+                       makeDatabaseUserId($userid),
                        makeDatabaseUserId(determineReferalId()),
                        $isMember,
                        $isAdmin,
@@ -109,7 +109,7 @@ LIMIT 1",
                                getModule(),
                                $action,
                                getWhat(),
-                               $userid,
+                               makeDatabaseUserId($userid),
                                makeDatabaseUserId(determineReferalId()),
                                $isMember,
                                $isAdmin,
index 89db1c6400e981f4625d30f1147e5e2fb66f6763..70ee8d05e06377e1482806ff9c32a7bb38a740ce 100644 (file)
@@ -131,7 +131,9 @@ ORDER BY
        `id`, `gender`, `surname`, `family`, `email`, `status`,
        UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
        UNIX_TIMESTAMP(`last_online`) AS `last_online`,
-       `points_amount`, `points_used`, `remote_addr`
+       `points_amount`, `points_used`,
+       (`points_amount` + `points_used`) AS `points`,
+       `remote_addr`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 ORDER BY
@@ -145,7 +147,6 @@ ORDER BY
                        $content['email']           = generateEmailLink($content['email'], 'sponsor_data');
                        $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
                        $content['last_online']     = generateDateTime($content['last_online'], 2);
-                       $content['points']          = ($content['points_amount'] - $content['points_used']);
 
                        // Load row template
                        $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
index adb9b19b47719e6af6b9dd30c990ac42fcfcf4bd..86e4cdba73a176554459f1a444ddf475976af393 100644 (file)
@@ -59,7 +59,9 @@ if (isFormSent()) {
                        $result_main = SQL_QUERY_ESC("SELECT
        `id`, `gender`, `surname`, `family`, `email`, `remote_addr`,
        UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
-       `points_amount`, `points_used`, `refid`
+       `points_amount`, `points_used`,
+       (`points_amount` + `points_used`) AS `points`,
+       `refid`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
@@ -73,9 +75,6 @@ LIMIT 1",
                                // Load data
                                $content = SQL_FETCHARRAY($result_main);
 
-                               // Add total amount
-                               $content['points'] = ($content['points_amount'] - $content['points_used']);
-
                                // Check for open payments and close them
                                $result = SQL_QUERY_ESC("SELECT
        so.admin_id, so.pay_count,
index 8f1349c454df6a6b5093b3c363c55b87b4b2dfc0..4da8ef31b200524115d5b34bb1e23de321738988 100644 (file)
@@ -276,7 +276,6 @@ function loadTemplate ($template, $return = false, $content = array()) {
 
                // Init some data
                $ret = '';
-               if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = '0';
 
                // Base directory
                $basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage());
diff --git a/ref.php b/ref.php
index b1a99dd2f0244892617e6d83699d6eb23829c987..59fe143ffc9056c664c9083a010df4155fef4c64 100644 (file)
--- a/ref.php
+++ b/ref.php
@@ -51,7 +51,7 @@ setContentType('text/html');
 // No refid by default
 $URL = 'modules.php?module=index';
 
-if (determineReferalId() != 0) {
+if (isValidUserId(determineReferalId())) {
        // Test if nickname or numeric id
        if (isExtensionActive('nickname')) {
                // Nickname in URL, so load the id
@@ -80,7 +80,7 @@ if (determineReferalId() != 0) {
        if (isValidUserId(determineReferalId())) {
                // Update ref counter
                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`=%s LIMIT 1",
-                       array(determineReferalId()), __FILE__, __LINE__);
+                       array(makeDatabaseUserId(determineReferalId())), __FILE__, __LINE__);
 
                // Base URL for redirection
                switch (getConfig('refid_target')) {
index 75459c79a924375bb8371891f0ddc86b5fdc29f3..1171583ceeb252ce7319ea47ae949c04d9060e6e 100644 (file)
@@ -53,7 +53,7 @@ setContentType('text/html');
 $URL = 'modules.php?module=index&amp;what=sponsor_reg&amp;refid=';
 
 // Do we have a referal id?
-if (!empty($GLOBALS['refid'])) {
+if (isValidUserId($GLOBALS['refid'])) {
        // We have an refid here. So we simply add it
        $URL .= $GLOBALS['refid'];
 } else {