+// Determine which user hash no more points left
+function SURFBAR_DETERMINE_DEPLETED_USERIDS() {
+ // Init array
+ $UIDs = array();
+
+ // Do we have a current user id?
+ if (IS_LOGGED_IN()) {
+ // Then add this as well
+ $UIDs[] = $GLOBALS['userid'];
+
+ // Get all userid except logged in one
+ $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_surfbar_urls
+WHERE userid != %s AND status='CONFIRMED'
+GROUP BY userid
+ORDER BY userid ASC",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+ } else {
+ // Get all userid
+ $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_surfbar_urls
+WHERE status='CONFIRMED'
+GROUP BY userid
+ORDER BY userid ASC", __FILE__, __LINE__);
+ }
+
+ // Load all userid
+ while (list($uid) = SQL_FETCHROW($result)) {
+ // Get total points
+ $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
+ //DEBUG_LOG(__FUNCTION__.":uid={$uid},points={$points}");
+
+ // Shall we add this to ignore?
+ if ($points <= 0) {
+ // Ignore this one!
+ //DEBUG_LOG(__FUNCTION__.":uid={$uid} has depleted points amount!");
+ $UIDs[] = $uid;
+ } // END - if
+ } // END - while
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Debug message
+ //DEBUG_LOG(__FUNCTION__.":UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")");
+
+ // Return result
+ return $UIDs;
+}
+// Determine how many users are Online in surfbar
+function SURFBAR_DETERMINE_TOTAL_ONLINE () {
+ global $_CONFIG;
+
+ // Count all users in surfbar modue and return the value
+ $result = SQL_QUERY_ESC("SELECT COUNT(id) FROM "._MYSQL_PREFIX."_surfbar_stats WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_online)) <= %s",
+ array($_CONFIG['online_timeout']), __FILE__, __LINE__);
+
+ // Fetch count
+ list($cnt) = SQL_FETCHROW($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return result
+ return $cnt;
+}