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 0622a21..5f37270 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 209e8bb..a989e1f 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 89db1c6..70ee8d0 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 adb9b19..86e4cdb 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 8f1349c..4da8ef3 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 b1a99dd..59fe143 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 75459c7..1171583 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 {