4 $prefetch = array('`points`', '`msglist_layout`', '`msgs_page`');
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']);
14 if ( isset($topicid) ) {
15 $topic = $DB->query('SELECT `board_name`, `boards`.`boardid`, `topic_title`, `restrict`
17 NATURAL LEFT JOIN `topics`
18 WHERE `topicid` = '.$topicid)->fetch_row();
20 $page->errorfooter('topicid');
22 // Check for valid topic ID
23 if ( !is_array($topic) )
24 $page->errorfooter('topicid');
26 // Check whether or not they can view this board
27 if ( $topic[3] >= 3 && !defined('DEVELOPER') )
28 $page->errorfooter('level', $topic[3]);
30 $page->title
.= ': '.$topic[2];
32 $page->nav
['Topic List: '.$topic[0]] = 'topiclist?'.$topic[1];
33 if ( $topic[3] <= 1 ||
defined('DEVELOPER') )
34 $user->userlinks
['Post Message'] = 'post?topic='.$topicid;
38 $start = isset($_GET['page']) ?
intval($_GET['page']) : 0;
39 $posts = isset($_GET['length']) && ($_GET['length'] <= 100) ?
intval($_GET['length']) : $user->msgs_page
;
41 define('HERE', 'messagelist?topic='.$topicid.';page='.$start.';length='.$posts);
43 list($postcount) = $DB->query('SELECT COUNT(*) FROM `messages` WHERE `topicid` = '.$topicid)->fetch_row();
44 $tmpquery = 'SELECT `messages`.`userid`, `alias`, `mtime`, `mtext`, `replyto`,
45 `score`, `messages`.`messageid`, INET_NTOA(`origin_ip`) AS `ip`
47 NATURAL LEFT JOIN `messages`
48 NATURAL LEFT JOIN `users`
49 WHERE `topicid` = '.$topicid.'
50 ORDER BY `mtime` ASC';
52 if ( $user->msglist_layout
== messagelist_threaded
::ID
)
53 $msgs = $DB->query($tmpquery, MYSQLI_USE_RESULT
);
55 $msgs = $DB->query($tmpquery.' LIMIT '.($posts*$start).', '.$posts);
57 switch ( $user->msglist_layout
) {
58 case messagelist_flat
::ID
:
59 $mlist = new messagelist_flat
; break;
60 case messagelist_irc
::ID
:
61 $mlist = new messagelist_irc
; break;
62 case messagelist_frozenoven
::ID
:
63 $mlist = new messagelist_frozenoven
; break;
64 case messagelist_threaded
::ID
:
65 $mlist = new messagelist_threaded
; break;
68 $l = $mlist->pagelist($posts, $start, $topicid, $postcount);
71 echo '<dl id="pagelist-head" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";
73 echo '<div id="',get_class($mlist),"\">\n";
74 $mlist->display($msgs);
78 echo '<dl id="pagelist-foot" class="nl"><dt>Pages:</dt> '.$l."</dl>\n";