Replaced the shitty old boardlist view control with something more readable
[specialops2.git] / messagelist.php
blob3deb50761b9d16a91c2dc804538e87a3fd879221
1 <?php
2 // $Id$
4 $prefetch = array('`points`', '`msglist_layout`', '`msgs_page`');
5 require 'con.php';
7 $page->title = 'Message List';
9 if ( is_numeric($_SERVER['QUERY_STRING']) ) {
10 $topicid = intval($_SERVER['QUERY_STRING']);
11 } elseif ( isset($_GET['topic']) ) {
12 $topicid = intval($_GET['topic']);
16 if ( isset($topicid) ) {
17 $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`, `topic_title`, `restrict`
18 FROM `boards` NATURAL LEFT JOIN `topics` WHERE `topicid` = '.$topicid)->fetch_row();
19 } else {
20 $page->errorfooter('topicid');
24 /* Error checks */
25 if ( !is_array($topic) ) { // Check for valid topic ID
26 $page->errorfooter('topicid');
28 if ( 3 == $topic[3] && !defined('DEVELOPER') ) { // Check whether or not they can view this board
29 $page->errorfooter('level', $topic[3]);
32 $page->title .= ': '.$topic[2];
33 $page->nav['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1];
34 if ( 1 >= $topic[3] || defined('DEVELOPER') ) {
35 $user->userlinks['Post Message'] = 'post?topic='.$topicid;
38 $user->userheader();
40 $start = isset($_GET['page']) ? intval($_GET['page']) : 0;
41 $posts = isset($_GET['length']) && ($_GET['length'] <= 100) ? intval($_GET['length']) : $user->msgs_page;
43 define('HERE', 'messagelist?topic='.$topicid.';page='.$start.';length='.$posts);
45 list($postcount) = $DB->query('SELECT COUNT(*) FROM `messages` WHERE `topicid` = '.$topicid)->fetch_row();
46 $tmpquery = 'SELECT `messages`.`userid`, `alias`, `mtime`, `mtext`, `replyto`,
47 `score`, `messages`.`messageid`, INET_NTOA(`origin_ip`) AS `ip`
48 FROM `message-data`
49 NATURAL LEFT JOIN `messages`
50 NATURAL LEFT JOIN `users`
51 WHERE `topicid` = '.$topicid.'
52 ORDER BY `mtime` ASC';
54 if ( messagelist_threaded::ID == $user->msglist_layout ) {
55 $msgs = $DB->query($tmpquery, MYSQLI_USE_RESULT);
56 } else {
57 $msgs = $DB->query($tmpquery.' LIMIT '.($posts*$start).', '.$posts);
60 switch ( $user->msglist_layout ) {
61 case messagelist_flat::ID:
62 $mlist = new messagelist_flat; break;
63 case messagelist_irc::ID:
64 $mlist = new messagelist_irc; break;
65 case messagelist_frozenoven::ID:
66 $mlist = new messagelist_frozenoven; break;
67 case messagelist_threaded::ID:
68 $mlist = new messagelist_threaded; break;
71 $l = $mlist->pagelist($posts, $start, $topicid, $postcount);
73 if ( $l ) {
74 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
77 echo '<div id="',get_class($mlist),"\">\n";
78 $mlist->display($msgs);
79 echo "</div>\n";
81 if ( $l ) {
82 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
85 $page->pagefooter();