From 47aa2e8f65fd62894c4d261b693b77b7d2d7a774 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 28 Jul 2011 21:53:11 +0000 Subject: [PATCH] Handling of invalid referal ids fixed --- inc/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index ac03d6e5cd..d5a1700813 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1690,7 +1690,7 @@ function determineReferalId () { } // Set cookie when default refid > 0 - if (!isSessionVariableSet('refid') || (!isValidUserId(getReferalId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) { + if ((!isSessionVariableSet('refid')) || (!isValidUserId(getReferalId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) { // Default is not found $found = false; @@ -1721,11 +1721,12 @@ function determineReferalId () { // Set cookie //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferalId() . ') #1'); setSession('refid', getReferalId()); - } elseif (!isReferalIdValid()) { + } elseif ((!isReferalIdValid()) || (!fetchUserData(getReferalId()))) { // Not valid! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not valid referal id (' . getReferalId() . '), setting NULL in session'); + setReferalId(NULL); setSession('refid', NULL); - } elseif ((!isSessionVariableSet('refid')) && (isValidUserId(getReferalId()))) { + } else { // Set it from GLOBALS array in session //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferalId() . ') #2'); setSession('refid', getReferalId()); -- 2.39.5