./inc/functions.php:1318: // @TODO Are these convertions still required?
./inc/functions.php:1336:// @TODO Rewrite this function to use readFromFile() and writeToFile()
./inc/functions.php:163:// @TODO Rewrite this to an extension 'smtp'
-./inc/functions.php:1918: // @TODO Find a way to cache this
-./inc/functions.php:2019: // @TODO This is still very static, rewrite it somehow
-./inc/functions.php:2199: // @TODO Rename column data_type to e.g. mail_status
+./inc/functions.php:1927: // @TODO Find a way to cache this
+./inc/functions.php:2028: // @TODO This is still very static, rewrite it somehow
+./inc/functions.php:2208: // @TODO Rename column data_type to e.g. mail_status
./inc/functions.php:92: // @TODO Extension 'msg' does not exist
./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter
./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
} // 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 $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
//-----------------------------------------------------------------------------
// No refid by default
$url = 'modules.php?module=index';
-if (isValidUserId(determineReferalId())) {
- // Test if nickname or numeric id
- if (isExtensionActive('nickname')) {
- // Nickname in URL, so load the id
- fetchUserData(determineReferalId(), 'nickname');
+// Check for determined referal id
+if ((isReferalIdValid()) && (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(makeDatabaseUserId(determineReferalId())), __FILE__, __LINE__);
- // Do we have an entry?
- if (isUserDataValid()) {
- // Load userid
- $GLOBALS['refid'] = getUserData('userid');
- } else {
- // So do we have a userid?
- fetchUserData(determineReferalId());
+ // Base URL for redirection
+ switch (getConfig('refid_target')) {
+ case 'register':
+ $url = 'modules.php?module=index&what=register';
+ break;
- // Do we have an entry?
- if (!isUserDataValid()) {
- // No entry, so no referal id
- $GLOBALS['refid'] = getDefRefid();
- } // END - if
- }
- } // END - if
-
- // Update session
- setSession('refid', determineReferalId());
-
- // Is the refid valid?
- 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(makeDatabaseUserId(determineReferalId())), __FILE__, __LINE__);
-
- // Base URL for redirection
- switch (getConfig('refid_target')) {
- case 'register':
- $url = 'modules.php?module=index&what=register';
- break;
-
- case 'index':
- $url = 'modules.php?module=index';
- break;
- } // END - switch
- } // END - if
+ case 'index':
+ $url = 'modules.php?module=index';
+ break;
+ } // END - switch
} // END - if
// Load the URL