Database rewrite, first half
[specialops2.git] / userlist.php
blob95a31ca14ee7848f9a6f6c07fb77830b3f9d681c
1 <?php
2 // $Id$
4 require 'con.php';
5 $page->title = _('User List');
7 if ( ! ($user instanceof authuser) ) {
8 $page->errorfooter('login');
11 $sql = array(
12 'online' => array('WHERE `last_active_date` > UNIX_TIMESTAMP() - 600', _('Online Users List')),
13 'banned' => array('WHERE `level` < '.LVL_RESTRICTED, _('Banned Users List'))
16 $where = '';
18 if ( isset($_GET['show']) && array_key_exists($_GET['show'], $sql) ) {
19 $where = $sql[$_GET['show']][0];
20 $page->title = $sql[$_GET['show']][1];
23 $user->userheader();
25 echo
26 '<table id="userlist">
27 <tr>
28 <th>',_('Username'),'</th>
29 <th>',_('Level'),'</th>
30 <th>',_('Points'),'</th>
31 <th>',_('Posts'),'</th>
32 <th>',_('Last Active'),"</th>\n",
33 ( LVL_ADMIN <= $user->level ?
34 ' <th>'._('Last IP')."</th>\n" : '' ),
35 "</tr>\n";
37 $q = $DB->query(
38 'SELECT `users`.`userid`, `alias`, `level`, `points`, `last_active_date`,
39 INET_NTOA(`last_ip`) AS `last_ip`, COUNT(`messageid`) AS `msgs`
40 FROM `users` NATURAL LEFT JOIN `messages`
41 '.$where.'
42 GROUP BY `userid` ASC');
44 $a = 1; //Shadebar variable
46 while ( $row = $q->fetch_assoc() ) {
47 echo '<tr class="content c',(++$a&1),'">
48 <td>',$user->namelink($row['userid'], $row['alias']),'</td>
49 <td>',$row['level'],'</td>
50 <td>',$row['points'],'</td>
51 <td>',$row['msgs'],'</td>
52 <td>',$user->fdate($row['last_active_date']),"</td>\n",
53 ( LVL_ADMIN <= $user->level ? "\t<td>".$row['last_ip']."</td>\n" : '' ),
54 "</tr>\n";
57 echo '</table>';
59 $page->pagefooter();