Made default theme FO because I'm too lazy to make an original one
[specialops2.git] / userlist.php
blob47a4b073608736edb99ac45abe680236992bde18
1 <?php
2 // $Id$
4 require 'con.php';
6 switch ( $_SERVER['QUERY_STRING'] ) {
7 case 'online':
8 $page->title = 'Online Users';
9 $where = 'WHERE `last_active_date` > UNIX_TIMESTAMP() - 600';
10 break;
11 default:
12 $page->title = 'User List';
13 $where = '';
16 $user->userheader();
19 <table id="userlist">
20 <col/><col/><col/><col/>
21 <thead>
22 <tr>
23 <th>Username</th>
24 <th>Points</th>
25 <th>Posts</th>
26 <th>Last Active</th>
27 <th>Idle Time</th>
28 </tr>
29 </thead>
30 <tbody>
31 <?php
32 $q = $DB->query('SELECT `users`.`userid`, `alias`, `points`, `last_active_date`, COUNT(`messageid`) AS `msgs`
33 FROM `users`
34 NATURAL LEFT JOIN `messages`
35 '.$where.'
36 GROUP BY `userid` ASC');
38 function idle($last)
40 // voodoo
41 $idle = time() - $last;
42 $idle -= ($time[2] = $idle % 60); $idle /= 60;
43 $idle -= ($time[1] = $idle % 60); $idle /= 60;
44 $idle -= ($time[0] = $idle % 24); $time[3] = $idle / 24;
46 ksort($time);
48 return ( $time[3] ? $time[3].' day'.( $time[3] != 1 ? 's ' : ' ' ) : '').vsprintf('%d:%02d:%02d', $time);
51 $a = 1; // CSS class thing on alternating rows
53 while ( $row = $q->fetch_assoc() ) {
54 // This looks much nicer when rendered. Really.
55 printf("<tr class=\"content c%d\">\n\t<td>%s</td>\n\t<td>%d</td>\n\t<td>%d</td>\n\t<td>%s</td><td>%s</td>\n</tr>\n",
56 (++$a&1),
57 $user->namelink($row['userid'], $row['alias']),
58 $row['points'],
59 $row['msgs'],
60 $user->fdate($row['last_active_date']),
61 $user instanceof authuser && $row['userid'] == $user->userid ? '' : idle($row['last_active_date'])
65 </tbody>
66 </table>
67 <?php
68 $page->pagefooter();