// Only check this if refid is provided!
if ($GLOBALS['refid'] > 0) {
- // Probe for nickname extension and if a nickname was supplied by URL
- $probe_nickname = ((EXT_IS_ACTIVE('nickname')) && ((''.round($GLOBALS['refid']).'') != $GLOBALS['refid']));
-
// Do we have nickname or userid set?
- if ($probe_nickname === true) {
+ if (isNicknameUsed($GLOBALS['refid'])) {
// Nickname in URL, so load the ID
$result = SQL_QUERY_ESC("SELECT userid, status FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
// Begin with doubling process
if ((REQUEST_ISSET_POST(('userid'))) && (REQUEST_ISSET_POST(('pass'))) && (REQUEST_ISSET_POST(('points')))) {
// Probe for nickname extension and if a nickname was entered
- $probe_nickname = ((EXT_IS_ACTIVE('nickname')) && ((''.round(REQUEST_POST('userid')).'') != REQUEST_POST('userid')));
- if ($probe_nickname) {
+ if (isNickNameUsed(REQUEST_POST('userid'))) {
// Nickname in URL, so load the ID
$result = SQL_QUERY_ESC("SELECT userid, status, password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
array(REQUEST_POST('userid')), __FILE__, __LINE__);
} elseif (REQUEST_POST('points') > getConfig('doubler_max')) {
// Too much points entered
define('__ERROR_MSG', getMessage('DOUBLER_FORM_POINTS_MAX'));
- } elseif ($probe_nickname) {
+ } elseif (isNickNameUsed(REQUEST_POST('userid'))) {
// Cannot resolv nickname -> userid
define('__ERROR_MSG', getMessage('DOUBLER_FORM_404_NICKNAME'));
} else {
if ((EXT_IS_ACTIVE('nickname')) && (NICKNAME_PROBE_ON_USERID($uid))) {
// Nickname entered
$result = SQL_QUERY_ESC("SELECT userid, password, last_online".$lastOnline." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' AND `status`='CONFIRMED' LIMIT 1",
- array($uid), __FUNCTION__, __LINE__);
+ array($uid), __FUNCTION__, __LINE__);
} else {
// Direct userid entered
$result = SQL_QUERY_ESC("SELECT userid, password, last_online".$lastOnline." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
- array($uid, $content['hash']), __FUNCTION__, __LINE__);
+ array($uid, $content['hash']), __FUNCTION__, __LINE__);
}
// Load entry
if (!empty($content['userid'])) $uid = bigintval($content['userid']);
// Is there an entry?
- if ((SQL_NUMROWS($result) == 1) && ((($probe_nickname) && (!empty($content['userid']))) || ($content['userid'] == $uid))) {
+ if ((SQL_NUMROWS($result) == 1) && ((isNicknameUsed($content['userid'] === true) && (!empty($content['userid']))) || ($content['userid'] == $uid))) {
// Free result
SQL_FREERESULT($result);
// Wrong password!
$URL = 'modules.php?module=index&what=login&login='.getCode('WRONG_PASS');
}
- } elseif ((($probe_nickname) && (!empty($content['userid']))) || ($content['userid'] == $uid)) {
+ } elseif (((isNicknameUsed($content['userid'])) && (!empty($content['userid']))) || ($content['userid'] == $uid)) {
// Other account status?
// @TODO Can this query be merged with above query?
$result = SQL_QUERY_ESC("SELECT status FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
// Initialize variables
$errorCode = 0;
-$probe_nickname = false;
$uid = false;
$hash = '';
$URL = '';
// Add design when extension sql_patches is v0.2.7 or greater
// @TODO Rewrite these all to a single filter
$ADD1 = ''; $ADD2 = '';
- if (GET_EXT_VERSION('sql_patches') >= '0.2.7') {
+ if (GET_EXT_VERSION('theme') >= '0.0.8') {
// Okay, add design here
$ADD1 = ", `curr_theme`";
$ADD2 = ", '".getCurrentTheme()."'";
return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
}
+// Checks wether a nickname or userid was entered and caches the result
+function isNicknameUsed ($userid) {
+ // Default is false
+ $isUsed = false;
+
+ // Is the cache there
+ if (isset($GLOBALS['cache_probe_nicknames'][$userid])) {
+ // Then use it
+ $isUsed = $GLOBALS['cache_probe_nicknames'][$userid];
+ } else {
+ // Determine it
+ $isUsed = ((EXT_IS_ACTIVE('nickname')) && ((''.round($userid).'') != $userid));
+
+ // And write it to the cache
+ $GLOBALS['cache_probe_nicknames'][$userid] = $isUsed;
+ }
+
+ // Return the result
+ return $isUsed;
+}
+
// [EOF]
?>