From 4130013da63b89ebbd25b0c2720be9a0059b37da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 1 Aug 2010 07:30:16 +0000 Subject: [PATCH 1/1] More usage of isValidUserId() --- inc/libs/sponsor_functions.php | 6 ++++-- inc/mysql-manager.php | 2 +- inc/wrapper-functions.php | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index bba582eb3f..faca46db85 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -661,7 +661,7 @@ function fetchSponsorData ($sponsor_id, $column = 'id') { setCurrentSponsorId($sponsor_id); // Don't look for invalid sponsor_ids... - if ($sponsor_id < 1) { + if (!isValidUserId($sponsor_id)) { // Invalid, so abort here debug_report_bug(__FUNCTION__, __LINE__, 'Sponsor id ' . $sponsor_id . ' is invalid.'); } elseif (isSponsorDataValid()) { @@ -815,7 +815,9 @@ function isValidSponsorId ($sponsor_id) { // Getter for sponsor data function getSponsorData ($column) { // Sponsor id should not be zero - if (getCurrentSponsorId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'Sponsor id is zero.'); + if (!isValidUserId(getCurrentSponsorId())) { + debug_report_bug(__FUNCTION__, __LINE__, 'Sponsor id is zero.'); + } // END - if // Return the value return $GLOBALS['sponsor_data'][getCurrentSponsorId()][$column]; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 8fadc7f883..4ff3a8cd7b 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -442,7 +442,7 @@ function fetchUserData ($userid, $column = 'userid') { setCurrentUserId($userid); // Don't look for invalid userids... - if ($userid < 1) { + if (!isValidUserId($userid)) { // Invalid, so abort here debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.'); } elseif (isUserDataValid()) { diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index c6d6d4b1d8..8a85b56b5e 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -804,7 +804,10 @@ function setAdminHash ($adminId, $hash) { // Init user data array function initUserData () { // User id should not be zero - if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.'); + if (!isValidUserId(getCurrentUserId())) { + // Should be always valid + debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.'); + } // END - if // Init the user $GLOBALS['user_data'][getCurrentUserId()] = array(); @@ -813,7 +816,10 @@ function initUserData () { // Getter for user data function getUserData ($column) { // User id should not be zero - if (getCurrentUserId() < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.'); + if (!isValidUserId(getCurrentUserId())) { + // Should be always valid + debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.'); + } // END - if // Return the value return $GLOBALS['user_data'][getCurrentUserId()][$column]; @@ -822,18 +828,18 @@ function getUserData ($column) { // Geter for whole user data array function getUserDataArray () { // Get user id - $uid = getCurrentUserId(); + $userid = getCurrentUserId(); // Is the current userid valid? - if (!isValidUserId($uid)) { + if (!isValidUserId($userid)) { // Should be always valid - debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.'); + debug_report_bug(__FUNCTION__, __LINE__, 'User id is invalid.'); } // END - if // Get the whole array if found - if (isset($GLOBALS['user_data'][$uid])) { + if (isset($GLOBALS['user_data'][$userid])) { // Found, so return it - return $GLOBALS['user_data'][$uid]; + return $GLOBALS['user_data'][$userid]; } else { // Return empty array return array(); -- 2.39.2