Added some class="" to pagelist code
[specialops2.git] / userlist.php
bloba37c5463336546ab53d4e775f9a1b13028b5c634
1 <?php
2 /**
3 * User Directory/Online Users/Top 50 page
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://COPYING
7 * @version $Id$
8 */
10 require 'con.php';
12 switch ( $_SERVER['QUERY_STRING'] ) {
13 case 'online':
14 $page->title = 'Currently Online Users';
15 $where = 'WHERE `last_active_date` > UNIX_TIMESTAMP() - 600 GROUP BY `userid` ASC';
16 break;
18 default:
19 if ( $DB->query('SELECT COUNT(*) AS `c` FROM `users`')->fetch_object()->c > 50 ) {
20 $page->title = 'Top 50 Users';
21 $where = 'GROUP BY `userid` ORDER BY `points` DESC LIMIT 50';
22 } else {
23 $page->title = 'User List';
24 $where = 'GROUP BY `userid` ASC';
28 $user->userheader();
31 <table id="userlist">
32 <col/><col/><col/><col/><col/>
33 <thead>
34 <tr><th>ID</th><th>Username</th><th>Points</th><th>Posts</th><th>Last Active</th><th>Idle Time</th></tr>
35 </thead>
36 <tbody>
37 <?php
38 $q = $DB->query('SELECT `users`.`userid`, `alias`, `points`, `last_active_date`, COUNT(`messageid`) AS `msgs`
39 FROM `users` NATURAL LEFT JOIN `messages` '.$where);
41 function idle($last)
43 // voodoo
44 $idle = time() - $last;
45 $idle -= ($time[2] = $idle % 60); $idle /= 60;
46 $idle -= ($time[1] = $idle % 60); $idle /= 60;
47 $idle -= ($time[0] = $idle % 24); $time[3] = $idle / 24;
49 ksort($time);
51 return ( $time[3] ? $time[3].' day'.( 1 != $time[3] ? 's ' : ' ' ) : '').vsprintf('%d:%02d:%02d', $time);
54 $a = 1;
56 while ( $row = $q->fetch_assoc() ) {
57 // mew
58 printf('<tr class="content c%d"><td>%d</td><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td></tr>'."\n",
59 (++$a&1),
60 $row['userid'],
61 $user->namelink($row['userid'], $row['alias']),
62 $row['points'],
63 $row['msgs'],
64 $user->fdate($row['last_active_date']),
65 idle($row['last_active_date'])
69 </tbody>
70 </table>
71 <?php
72 $page->pagefooter();