Reduced the gfh2 background image contrast a bit since it was hard to read text with it.
[specialops2.git] / userlist.php
blobc33a75be2231f01599c05310fa664b1dc07513dc
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 GROUP BY `userid` ASC';
10 break;
11 default:
12 if ( $DB->query('SELECT COUNT(*) AS `c` FROM `users`')->fetch_object()->c > 50 ) {
13 $page->title = 'Top 50 Users';
14 $where = 'GROUP BY `userid` ORDER BY `points` DESC LIMIT 50';
15 } else {
16 $page->title = 'User List';
17 $where = 'GROUP BY `userid` ASC';
21 $user->userheader();
24 <table id="userlist">
25 <col/><col/><col/><col/>
26 <thead>
27 <tr>
28 <th>Username</th>
29 <th>Points</th>
30 <th>Posts</th>
31 <th>Last Active</th>
32 <th>Idle Time</th>
33 </tr>
34 </thead>
35 <tbody>
36 <?php
37 $q = $DB->query('SELECT `users`.`userid`, `alias`, `points`, `last_active_date`, COUNT(`messageid`) AS `msgs`
38 FROM `users`
39 NATURAL LEFT JOIN `messages`
40 '.$where);
42 function idle($last)
44 // voodoo
45 $idle = time() - $last;
46 $idle -= ($time[2] = $idle % 60); $idle /= 60;
47 $idle -= ($time[1] = $idle % 60); $idle /= 60;
48 $idle -= ($time[0] = $idle % 24); $time[3] = $idle / 24;
50 ksort($time);
52 return ( $time[3] ? $time[3].' day'.( $time[3] != 1 ? 's ' : ' ' ) : '').vsprintf('%d:%02d:%02d', $time);
55 $a = 1; // CSS class thing on alternating rows
57 while ( $row = $q->fetch_assoc() ) {
58 // This looks much nicer when rendered. Really.
59 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",
60 (++$a&1),
61 $user->namelink($row['userid'], $row['alias']),
62 $row['points'],
63 $row['msgs'],
64 $user->fdate($row['last_active_date']),
65 $user instanceof authuser && $row['userid'] == $user->userid ? '' : idle($row['last_active_date'])
69 </tbody>
70 </table>
71 <?php
72 $page->pagefooter();