SO 1-final
[specialops1.git] / viewboard.php
blob039ede302fc37e39ad76a843ca977ed1d09597bd
1 <?php
2 require 'config.php';
4 $boardinfo = mysql_fetch_row(mysql_query('SELECT `name`, `view_level`, `topic_level` FROM `boards`
5 WHERE `board` = '.intval($_GET['b'])));
7 if ( $boardinfo )
8 list($page_name, $level_restriction, $topic_level) = $boardinfo;
10 require 'top.inc.php';
12 if ( empty($boardinfo) )
13 printf('Invalid Board ID.') && footer();
15 $page = isset ($_GET['p']) ? intval($_GET['p']) : 1;
16 $pages = ($page - 1) * $userinfo['topics_page'];
17 $topic_count = $pages;
19 list($number_of_items) = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM `topics` WHERE `board` = '.intval($_GET['b'])));
21 if ( $number_of_items > $userinfo['topics_page'] ) {
22 $count = 0;
23 $pagelist = '<div class="c3">Page '.$page." | \n";
24 while ( $count < $number_of_items / $userinfo['topics_page'] ) {
25 $stuff = ' ';
26 $rel = '';
27 switch (++$count) {
28 case $page:
29 $stuff = '[]';
30 break;
31 case $page - 1:
32 $rel = 'previous';
33 break;
34 case $page + 1:
35 $rel = 'next';
36 break;
38 $pagelist .= '<a href="?p='.$count.URL_APPEND.'"'.( $rel ? ' rel="'.$rel.'"' : '' ).'>'.$stuff{0}.$count.$stuff{1}."</a>\n";
40 $pagelist .= "</div>\n";
42 else
43 $pagelist = null;
45 echo $pagelist.'
46 <table>
47 <thead>
48 <tr class="c3">
49 <th>Topic Name</th>
50 <th>Created By</th>
51 <th>Posts</th>
52 <th>Last Post</th>
53 </tr>
54 </thead>
55 <tbody>
58 $topic_list = mysql_query('SELECT `topics`.`topic`, `title`, `topics`.`visible`, `topics`.`user`,
59 UNIX_TIMESTAMP(`time`) AS `time`, COUNT(`message`) AS `msgs`
60 FROM `topics` LEFT JOIN `messages` USING(`topic`)
61 WHERE `board` = '.intval($_GET['b']).
62 ( $userinfo['level'] >= MOD ? '' : ' AND `topics`.`visible` >= 0 AND `messages`.`visible` >= 0' ).'
63 GROUP BY `topics`.`topic`
64 ORDER BY `time` DESC
65 LIMIT '.$pages.', '.$userinfo['topics_page']);
67 $n = 0;
68 $a = 'asdfg';
70 while ( $topic = mysql_fetch_assoc($topic_list) ) {
71 $newposts = ($topic['time'] > time() - 3600) ? true : false;
73 echo '<tr class=',colour(),'>
74 <td><a href="viewtopic?t=',$topic['topic'],'"',( $n < 5 ? ' accesskey="'.$a{$n++}.'"' : '' ),'>',
75 $topic['title'],'</a></td>
76 <td>',userlink($topic['user']),'</td>
77 <td>',$topic['msgs'],'</td>
78 <td',( $newposts ? ' class="newposts">' : '>' ),date2($topic['time']),"</td>\n",
79 "</tr>\n";
82 echo '</tbody>
83 </table>
84 '.$pagelist;
86 footer();