// Default is zero
$data['percents'] = '0';
- // Do we have cache?
+ // Is there cache?
if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) {
// First look for level
$key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']);
$result = SQL_QUERY_ESC("SELECT `id`,`subject`,`column_name`,`locked_mode`,`payment_method`,`notify_recipient` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s' LIMIT 1",
array($subject), __FUNCTION__, __LINE__);
- // Do we have an entry?
+ // Is there an entry?
if (SQL_NUMROWS($result) == 1) {
// Then load it
$pointsData = SQL_FETCHARRAY($result);
$GLOBALS['referral_result'][$userid] = SQL_QUERY_ESC('SELECT `level` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s ORDER BY `level` ASC',
array($userid), __FUNCTION__, __LINE__);
- // Do we have entries?
+ // Are there entries?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL_NUMROWS()=' . SQL_NUMROWS($GLOBALS['referral_result'][$userid]));
if (SQL_NUMROWS($GLOBALS['referral_result'][$userid]) > 0) {
// Then walk through all levels
$GLOBALS['referral_result_refs'][$userid] = SQL_QUERY_ESC('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC',
array($userid), __FUNCTION__, __LINE__);
- // Do we have entries?
+ // Are there entries?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',SQL_NUMROWS()=' . SQL_NUMROWS($GLOBALS['referral_result_refs'][$userid]));
if (SQL_NUMROWS($GLOBALS['referral_result_refs'][$userid]) > 0) {
// Then again walk through all
$refid
), __FUNCTION__, __LINE__));
- // Do we have no entry?
+ // Is there no entry?
if ($count == 0) {
// Then add it to the SQL
$SQL .= '(' . $userid . ',' . $level . ',' . $refid . '),';
// Determines referral id and sets it
function determineReferralId () {
- // Do we have it already detected?
+ // Is it already detected?
if (isReferralIdValid()) {
// Do not determine it, just return it
return getReferralId();
- } // END - if
-
- // Skip this in non-html-mode and outside ref.php
- if ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) {
+ } elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) {
+ // Skip this in non-html-mode and outside ref.php
return false;
- } // END - if
+ }
// Check if refid is set
if (isReferralIdValid()) {
setReferralId(secureString(getRequestElement('refid')));
} elseif (isGetRequestElementSet('ref')) {
// Set refid=ref (the referral link uses such variable)
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using ref from GET data (' . getRequestElement('refid') . ')');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using ref from GET data (' . getRequestElement('ref') . ')');
setReferralId(secureString(getRequestElement('ref')));
} elseif ((isGetRequestElementSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) {
// The variable user comes from click.php
// Default is not found
$found = false;
- // Do we have nickname or userid set?
+ // Is there nickname or userid set?
if ((isExtensionActive('nickname')) && (isNicknameUsed(getReferralId()))) {
// Nickname in URL, so load the id
$found = fetchUserData(getReferralId(), 'nickname');
setSession('refid', getReferralId());
}
+ // Run post validation filter chain
+ runFilterChain('post_refid_validation');
+
// Return determined refid
return getReferralId();
}