// Sanity check on salt
if (strlen($salt) != getSaltLength()) {
// Not the same!
- debug_report_bug(__FUNCTION__, __LINE__, 'salt length mismatch! ('.strlen($salt).'/'.getSaltLength().')');
+ debug_report_bug(__FUNCTION__, __LINE__, 'salt length mismatch! (' . strlen($salt) . '/' . getSaltLength() . ')');
} // END - if
}
// Init
$scrambled = '';
- // Final check, in case of failture it will return unscrambled string
+ // Final check, in case of failure it will return unscrambled string
if (strlen($str) > 40) {
// The string is to long
return $str;
case getCode('ACCOUNT_LOCKED') : $message = '{--LOGIN_STATUS_LOCKED--}'; break;
case getCode('ACCOUNT_UNCONFIRMED'): $message = '{--LOGIN_STATUS_UNCONFIRMED--}'; break;
case getCode('COOKIES_DISABLED') : $message = '{--LOGIN_COOKIES_DISABLED--}'; break;
- case getCode('BEG_SAME_AS_OWN') : $message = '{--BEG_SAME_UID_AS_OWN--}'; break;
+ case getCode('BEG_SAME_AS_OWN') : $message = '{--BEG_SAME_USERID_AS_OWN--}'; break;
case getCode('LOGIN_FAILED') : $message = '{--GUEST_LOGIN_FAILED_GENERAL--}'; break;
case getCode('MODULE_MEMBER_ONLY') : $message = getMaskedMessage('MODULE_MEMBER_ONLY', getRequestParameter('mod')); break;
case getCode('OVERLENGTH') : $message = '{--MEMBER_TEXT_OVERLENGTH--}'; break;
} // END - if
// Check if refid is set
- if ((isset($GLOBALS['refid'])) && ($GLOBALS['refid'] > 0)) {
+ if (isReferalIdValid()) {
// This is fine...
} elseif (isPostRequestParameterSet('refid')) {
// Get referal id from POST element refid
- $GLOBALS['refid'] = secureString(postRequestParameter('refid'));
+ setReferalId(secureString(postRequestParameter('refid')));
} elseif (isGetRequestParameterSet('refid')) {
// Get referal id from GET parameter refid
- $GLOBALS['refid'] = secureString(getRequestParameter('refid'));
+ setReferalId(secureString(getRequestParameter('refid')));
} elseif (isGetRequestParameterSet('ref')) {
// Set refid=ref (the referal link uses such variable)
- $GLOBALS['refid'] = secureString(getRequestParameter('ref'));
+ setReferalId(secureString(getRequestParameter('ref')));
} elseif ((isGetRequestParameterSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) {
// The variable user comes from click.php
- $GLOBALS['refid'] = bigintval(getRequestParameter('user'));
+ setReferalId(bigintval(getRequestParameter('user')));
} elseif ((isSessionVariableSet('refid')) && (isValidUserId(getSession('refid')))) {
// Set session refid als global
- $GLOBALS['refid'] = bigintval(getSession('refid'));
+ setReferalId(bigintval(getSession('refid')));
} elseif (isRandomReferalIdEnabled()) {
// Select a random user which has confirmed enougth mails
- $GLOBALS['refid'] = determineRandomReferalId();
+ setReferalId(determineRandomReferalId());
} elseif ((isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid()))) {
// Set default refid as refid in URL
- $GLOBALS['refid'] = getDefRefid();
+ setReferalId(getDefRefid());
} else {
// No default id when sql_patches is not installed or none set
- $GLOBALS['refid'] = null;
+ setReferalId(null);
}
// Set cookie when default refid > 0
- if (!isSessionVariableSet('refid') || (isValidUserId($GLOBALS['refid'])) || ((!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;
// Do we have nickname or userid set?
- if ((isExtensionActive('nickname')) && (isNicknameUsed($GLOBALS['refid']))) {
+ if ((isExtensionActive('nickname')) && (isNicknameUsed(getReferalId()))) {
// Nickname in URL, so load the id
- $found = fetchUserData($GLOBALS['refid'], 'nickname');
- } elseif (isValidUserId($GLOBALS['refid'])) {
+ $found = fetchUserData(getReferalId(), 'nickname');
+
+ // If we found it, use the userid as referal id
+ if ($found === true) {
+ // Set the userid as 'refid'
+ setReferalId(getUserData('userid'));
+ } // END - if
+ } elseif (isValidUserId(getReferalId())) {
// Direct userid entered
- $found = fetchUserData($GLOBALS['refid']);
+ $found = fetchUserData(getReferalId());
}
// Is the record valid?
if ((($found === false) || (!isUserDataValid())) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2'))) {
// No, then reset referal id
- $GLOBALS['refid'] = getDefRefid();
+ setReferalId(getDefRefid());
} // END - if
// Set cookie
- setSession('refid', $GLOBALS['refid']);
- } // END - if
+ setSession('refid', getReferalId());
+ } elseif (!isReferalIdValid()) {
+ // Not valid!
+ setSession('refid', 0);
+ }
// Return determined refid
- return $GLOBALS['refid'];
+ return getReferalId();
}
// Enables the reset mode and runs it
return $keys;
}
+// Determines database column name from given subject and locked
+function determinePointsColumnFromSubjectLocked ($subject, $locked) {
+ // Default is 'normal' points
+ $pointsColumn = 'points';
+
+ // Which points, locked or normal?
+ if ($locked === true) {
+ $pointsColumn = 'locked_points';
+ } // END - if
+
+ // Prepare array for filter
+ $filterData = array(
+ 'subject' => $subject,
+ 'locked' => $locked,
+ 'column' => $pointsColumn
+ );
+
+ // Run the filter
+ $filterData = runFilterChain('determine_points_column_name', $filterData);
+
+ // Extract column name from array
+ $pointsColumn = $filterData['column'];
+
+ // Return it
+ return $pointsColumn;
+}
+
+// Setter for referal id (no bigintval, or nicknames will fail!)
+function setReferalId ($refid) {
+ $GLOBALS['refid'] = $refid;
+}
+
+// Checks if 'refid' is valid
+function isReferalIdValid () {
+ return ((isset($GLOBALS['refid'])) && (getReferalId() !== NULL) && (getReferalId() > 0));
+}
+
+// Getter for referal id
+function getReferalId () {
+ return $GLOBALS['refid'];
+}
+
//-----------------------------------------------------------------------------
// Automatically re-created functions, all taken from user comments on www.php.net
//-----------------------------------------------------------------------------