$AND = "";
}
if ((!isset($DEPTH)) && (!$return)) {
- $DEPTH = "0";
+ $DEPTH = 0;
$prefix = "<DIV class=\"you_are_here\">".YOU_ARE_HERE." <STRONG><A class=\"you_are_here\" href=\"".URL."/modules.php?module=".$GLOBALS['module'].$LINK_ADD."\">Home</A></STRONG>";
} else {
if (!$return) $DEPTH++;
//
function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false)
{
- $ret = "0";
+ $ret = 0;
if ($onlyRows) {
// Count rows
$result = SQL_QUERY_ESC("SELECT COUNT(%s) FROM "._MYSQL_PREFIX."_%s WHERE %s='%s'",
SQL_FREERESULT($result);
if (empty($ret)) {
if (($lookFor == "counter") || ($lookFor == "id")) {
- $ret = "0";
+ $ret = 0;
} else {
$ret = "0.00000";
}
// Count up referral depth
if (empty($DEPTH)) {
// Initialialize referral system
- $DEPTH = "0";
+ $DEPTH = 0;
} else {
// Increase referral level
$DEPTH++;
function UPDATE_REF_COUNTER($uid)
{
global $REF_LVL, $cacheInstance;
+
// Make it sure referral level zero (member him-/herself) is at least selected
- if (empty($REF_LVL)) $REF_LVL = "0";
+ if (empty($REF_LVL)) $REF_LVL = 0;
// Update counter
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_refsystem SET counter=counter+1 WHERE userid=%s AND level='%s' LIMIT 1",
if ($cacheInstance->cache_file("refsystem", true)) $cacheInstance->cache_destroy();
}
}
-//
-function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht)
-{
+// Updates/extends the online list
+function UPDATE_ONLINE_LIST($SID, $mod, $act, $wht) {
global $_CONFIG;
// Do not update online list when extension is deactivated
if (!EXT_IS_ACTIVE("online", true)) return;
+ // Empty session?
+ if (empty($SID)) {
+ // This is invalid here!
+ print "Invalid session. Backtrace:<pre>";
+ debug_print_backtrace();
+ die("</pre>");
+ } // END - if
+
// Initialize variables
- $uid = "0"; $rid = "0"; $MEM = "N"; $ADMIN = "N";
- if (!empty($GLOBALS['userid']))
- {
- // Update member status only when userid is valid
- if (($GLOBALS['userid'] > 0) && (IS_MEMBER()))
- {
- // Is valid user
- $uid = $GLOBALS['userid'];
- $MEM = "Y";
- }
- }
- if (IS_ADMIN())
- {
+ $uid = 0; $rid = 0; $MEM = "N"; $ADMIN = "N";
+
+ // Valid userid?
+ if ((!empty($GLOBALS['userid'])) && ($GLOBALS['userid'] > 0) && (IS_MEMBER())) {
+ // Is valid user
+ $uid = bigintval($GLOBALS['userid']);
+ $MEM = "Y";
+ } // END - if
+
+ if (IS_ADMIN()) {
// Is administrator
$ADMIN = "Y";
- }
+ } // END - if
+
if (isSessionVariableSet('refid')) {
// Check cookie
- if (get_session('refid') > 0) $rid = $GLOBALS['refid'];
- }
+ if (get_session('refid') > 0) $rid = bigintval($GLOBALS['refid']);
+ } // END - if
- // Now Read data
+ // Now search for the user
$result = SQL_QUERY_ESC("SELECT timestamp FROM "._MYSQL_PREFIX."_online
WHERE sid='%s' LIMIT 1",
array($SID), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
- SQL_FREERESULT($result);
- $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Then update it
+ SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_online SET
module='%s',
action='%s',
what='%s',
is_admin='%s',
timestamp=UNIX_TIMESTAMP()
WHERE sid='%s' LIMIT 1",
- array(
- $mod,
- $act,
- $wht,
- bigintval($uid),
- bigintval($rid),
- $MEM,
- $ADMIN,
- $SID
-), __FILE__, __LINE__);
- }
- else
- {
+ array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID), __FILE__, __LINE__
+ );
+ } else {
// No entry does exists so we simply add it!
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s', '%s', '%s', %s, %s, '%s', '%s', UNIX_TIMESTAMP(), '%s', '%s')",
- array($mod, $act, $wht, bigintval($uid), bigintval($rid), $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_online (module, action, what, userid, refid, is_member, is_admin, timestamp, sid, ip) VALUES ('%s', '%s', '%s', %s, %s, '%s', '%s', UNIX_TIMESTAMP(), '%s', '%s')",
+ array($mod, $act, $wht, $uid, $rid, $MEM, $ADMIN, $SID, getenv('REMOTE_ADDR')), __FILE__, __LINE__
+ );
}
+ // Free result
+ SQL_FREERESULT($result);
+
// Purge old entries
$result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_online WHERE timestamp <= (UNIX_TIMESTAMP() - %s)",
array($_CONFIG['online_timeout']), __FILE__, __LINE__);