diff -r 2b2084ca1e60 -r 0b3a0aedfd53 plugins/WhosOnline.php
--- a/plugins/WhosOnline.php Wed Jun 13 16:59:00 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-sql_query('DROP TABLE IF EXISTS '.table_prefix.'online;')
- ) $db->_die('Could not clean out old who\'s-online table');
- // The key on username allows the REPLACE command later, to save queries
- if(!$db->sql_query('CREATE TABLE '.table_prefix.'online(
- entry_id int(12) UNSIGNED NOT NULL auto_increment,
- user_id int(12) NOT NULL,
- username varchar(63) NOT NULL,
- last_load int(12) NOT NULL,
- PRIMARY KEY ( entry_id ),
- KEY ( username )
- );')
- ) $db->_die('Could not create new who\'s-online table');
- if(!$db->sql_query('CREATE UNIQUE INDEX '.table_prefix.'onluser ON '.table_prefix.'online(username);'))
- $db->_die('Could not create index on username column.');
- setConfig('whos_online_version', '0.1');
-}
-
-$plugins->attachHook('session_started', '__WhosOnline_UserCount();');
-$plugins->attachHook('login_success', '__WhosOnline_logonhandler();');
-$plugins->attachHook('logout_success', '__WhosOnline_logoffhandler($ou, $oid, $level);');
-
-function __WhosOnline_UserCount()
-{
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $whos_online;
- $whos_online = Array();
- $whos_online['users'] = Array();
- $whos_online['guests'] = Array();
- $q = $db->sql_query('REPLACE INTO '.table_prefix.'online SET user_id='.$session->user_id.',username=\''.$db->escape($session->username).'\',last_load='.time().';'); if(!$q) $db->_die('');
- $q = $db->sql_query('DELETE FROM '.table_prefix.'online WHERE last_load<'.( time() - 60*60*24 ).';'); if(!$q) $db->_die('');
- $q = $db->sql_query('SELECT o.username,o.user_id,u.user_level FROM '.table_prefix.'online AS o
- LEFT JOIN '.table_prefix.'users AS u
- ON u.user_id=o.user_id
- WHERE last_load>'.( time() - 60*5 - 1 ).' ORDER BY username ASC'); if(!$q) $db->_die('');
- $num_guests = 0;
- $num_users = 0;
- $users = Array();
- while ( $row = $db->fetchrow() )
- {
- ( $row['user_id'] == 1 ) ? $num_guests++ : $num_users++;
- if($row['user_id'] > 1)
- {
- switch($row['user_level'])
- {
- case USER_LEVEL_MEMBER:
- default:
- $color = '303030';
- $weight = 'normal';
- break;
- case USER_LEVEL_MOD:
- $color = '00AA00';
- $weight = 'bold';
- break;
- case USER_LEVEL_ADMIN:
- $color = 'AA0000';
- $weight = 'bold';
- break;
- }
- $users[] = "{$row['username']}";
- $whos_online['users'][] = $row['username'];
- }
- else
- {
- $whos_online['guests'][] = $row['username'];
- }
- }
- $total = $num_guests + $num_users;
- $ms = ( $num_users == 1 ) ? '' : 's';
- $gs = ( $num_guests == 1 ) ? '' : 's';
- $ts = ( $total == 1 ) ? '' : 's';
- $is_are = ( $total == 1 ) ? 'is' : 'are';
- $users = implode(', ', $users);
- $online_main = ( $num_users > 0 ) ? "
- Users online right now:
-