From 34bd67db3a98d58e2c3aee64af4fcb2dca1029c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 16 Sep 2010 22:38:44 +0000 Subject: [PATCH] Code cleanup, more usage of API functions --- inc/functions.php | 2 +- inc/libs/online_functions.php | 4 ++-- inc/modules/admin/what-list_sponsor.php | 5 +++-- inc/modules/admin/what-unlock_sponsor.php | 7 +++---- inc/template-functions.php | 1 - ref.php | 4 ++-- sponsor_ref.php | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 0622a21253..5f3727065a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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; diff --git a/inc/libs/online_functions.php b/inc/libs/online_functions.php index 209e8bbe6d..a989e1f2a2 100644 --- a/inc/libs/online_functions.php +++ b/inc/libs/online_functions.php @@ -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, diff --git a/inc/modules/admin/what-list_sponsor.php b/inc/modules/admin/what-list_sponsor.php index 89db1c6400..70ee8d05e0 100644 --- a/inc/modules/admin/what-list_sponsor.php +++ b/inc/modules/admin/what-list_sponsor.php @@ -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); diff --git a/inc/modules/admin/what-unlock_sponsor.php b/inc/modules/admin/what-unlock_sponsor.php index adb9b19b47..86e4cdba73 100644 --- a/inc/modules/admin/what-unlock_sponsor.php +++ b/inc/modules/admin/what-unlock_sponsor.php @@ -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, diff --git a/inc/template-functions.php b/inc/template-functions.php index 8f1349c454..4da8ef31b2 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -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 b1a99dd2f0..59fe143ffc 100644 --- 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')) { diff --git a/sponsor_ref.php b/sponsor_ref.php index 75459c79a9..1171583cee 100644 --- a/sponsor_ref.php +++ b/sponsor_ref.php @@ -53,7 +53,7 @@ setContentType('text/html'); $URL = 'modules.php?module=index&what=sponsor_reg&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 { -- 2.30.2