0
|
1 |
<?php
|
|
2 |
/***********************************************************************
|
|
3 |
|
|
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
|
|
5 |
|
|
6 |
This file is part of PunBB.
|
|
7 |
|
|
8 |
PunBB is free software; you can redistribute it and/or modify it
|
|
9 |
under the terms of the GNU General Public License as published
|
|
10 |
by the Free Software Foundation; either version 2 of the License,
|
|
11 |
or (at your option) any later version.
|
|
12 |
|
|
13 |
PunBB is distributed in the hope that it will be useful, but
|
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
GNU General Public License for more details.
|
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License
|
|
19 |
along with this program; if not, write to the Free Software
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
21 |
MA 02111-1307 USA
|
|
22 |
|
|
23 |
************************************************************************/
|
|
24 |
|
|
25 |
|
|
26 |
define('PUN_ROOT', './');
|
|
27 |
require PUN_ROOT.'include/common.php';
|
|
28 |
|
|
29 |
|
|
30 |
if ($pun_user['g_read_board'] == '0')
|
|
31 |
message($lang_common['No view']);
|
|
32 |
|
|
33 |
|
|
34 |
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
|
35 |
if ($id < 1)
|
|
36 |
message($lang_common['Bad request']);
|
|
37 |
|
|
38 |
// Load the viewforum.php language file
|
|
39 |
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
|
|
40 |
|
|
41 |
// Fetch some info about the forum
|
|
42 |
$result = $db->query('SELECT f.forum_name, f.redirect_url, f.moderators, f.num_topics, f.sort_by, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
|
|
43 |
if (!$db->num_rows($result))
|
|
44 |
message($lang_common['Bad request']);
|
|
45 |
|
|
46 |
$cur_forum = $db->fetch_assoc($result);
|
|
47 |
|
|
48 |
// Is this a redirect forum? In that case, redirect!
|
|
49 |
if ($cur_forum['redirect_url'] != '')
|
|
50 |
{
|
|
51 |
header('Location: '.$cur_forum['redirect_url']);
|
|
52 |
exit;
|
|
53 |
}
|
|
54 |
|
|
55 |
// Sort out who the moderators are and if we are currently a moderator (or an admin)
|
|
56 |
$mods_array = array();
|
|
57 |
if ($cur_forum['moderators'] != '')
|
|
58 |
$mods_array = unserialize($cur_forum['moderators']);
|
|
59 |
|
|
60 |
$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
|
|
61 |
|
|
62 |
// Can we or can we not post new topics?
|
|
63 |
if (($cur_forum['post_topics'] == '' && $pun_user['g_post_topics'] == '1') || $cur_forum['post_topics'] == '1' || $is_admmod)
|
|
64 |
$post_link = "\t\t".'<p class="postlink conr"><a href="post.php?fid='.$id.'">'.$lang_forum['Post topic'].'</a></p>'."\n";
|
|
65 |
else
|
|
66 |
$post_link = '';
|
|
67 |
|
|
68 |
|
|
69 |
// Determine the topic offset (based on $_GET['p'])
|
|
70 |
$num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
|
|
71 |
|
|
72 |
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
|
|
73 |
$start_from = $pun_user['disp_topics'] * ($p - 1);
|
|
74 |
|
|
75 |
// Generate paging links
|
|
76 |
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'viewforum.php?id='.$id);
|
|
77 |
|
|
78 |
|
|
79 |
$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / '.$cur_forum['forum_name']);
|
|
80 |
define('PUN_ALLOW_INDEX', 1);
|
|
81 |
require PUN_ROOT.'header.php';
|
|
82 |
|
|
83 |
?>
|
|
84 |
<div class="linkst">
|
|
85 |
<div class="inbox">
|
|
86 |
<p class="pagelink conl"><?php echo $paging_links ?></p>
|
|
87 |
<?php echo $post_link ?>
|
|
88 |
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
|
|
89 |
<div class="clearer"></div>
|
|
90 |
</div>
|
|
91 |
</div>
|
|
92 |
|
|
93 |
<div id="vf" class="blocktable">
|
|
94 |
<h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2>
|
|
95 |
<div class="box">
|
|
96 |
<div class="inbox">
|
|
97 |
<table cellspacing="0">
|
|
98 |
<thead>
|
|
99 |
<tr>
|
|
100 |
<th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
|
|
101 |
<th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
|
|
102 |
<th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
|
|
103 |
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
|
|
104 |
</tr>
|
|
105 |
</thead>
|
|
106 |
<tbody>
|
|
107 |
<?php
|
|
108 |
|
|
109 |
// Fetch list of topics to display on this page
|
|
110 |
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
|
|
111 |
{
|
|
112 |
// Without "the dot"
|
|
113 |
$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
// With "the dot"
|
|
118 |
switch ($db_type)
|
|
119 |
{
|
|
120 |
case 'mysql':
|
|
121 |
case 'mysqli':
|
|
122 |
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
|
|
123 |
break;
|
|
124 |
|
|
125 |
case 'sqlite':
|
|
126 |
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
|
|
127 |
break;
|
|
128 |
|
|
129 |
default:
|
|
130 |
$sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
|
|
131 |
break;
|
|
132 |
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
|
|
137 |
|
|
138 |
// If there are topics in this forum.
|
|
139 |
if ($db->num_rows($result))
|
|
140 |
{
|
|
141 |
while ($cur_topic = $db->fetch_assoc($result))
|
|
142 |
{
|
|
143 |
$icon_text = $lang_common['Normal icon'];
|
|
144 |
$item_status = '';
|
|
145 |
$icon_type = 'icon';
|
|
146 |
|
|
147 |
if ($cur_topic['moved_to'] == null)
|
|
148 |
$last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';
|
|
149 |
else
|
|
150 |
$last_post = ' ';
|
|
151 |
|
|
152 |
if ($pun_config['o_censoring'] == '1')
|
|
153 |
$cur_topic['subject'] = censor_words($cur_topic['subject']);
|
|
154 |
|
|
155 |
if ($cur_topic['moved_to'] != 0)
|
|
156 |
$subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
|
|
157 |
else if ($cur_topic['closed'] == '0')
|
|
158 |
$subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
|
|
159 |
else
|
|
160 |
{
|
|
161 |
$subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
|
|
162 |
$icon_text = $lang_common['Closed icon'];
|
|
163 |
$item_status = 'iclosed';
|
|
164 |
}
|
|
165 |
|
|
166 |
if (!$pun_user['is_guest'] && $cur_topic['last_post'] > $pun_user['last_visit'] && $cur_topic['moved_to'] == null)
|
|
167 |
{
|
|
168 |
$icon_text .= ' '.$lang_common['New icon'];
|
|
169 |
$item_status .= ' inew';
|
|
170 |
$icon_type = 'icon inew';
|
|
171 |
$subject = '<strong>'.$subject.'</strong>';
|
|
172 |
$subject_new_posts = '<span class="newtext">[ <a href="viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]</span>';
|
|
173 |
}
|
|
174 |
else
|
|
175 |
$subject_new_posts = null;
|
|
176 |
|
|
177 |
// Should we display the dot or not? :)
|
|
178 |
if (!$pun_user['is_guest'] && $pun_config['o_show_dot'] == '1')
|
|
179 |
{
|
|
180 |
if ($cur_topic['has_posted'] == $pun_user['id'])
|
|
181 |
$subject = '<strong>·</strong> '.$subject;
|
|
182 |
else
|
|
183 |
$subject = ' '.$subject;
|
|
184 |
}
|
|
185 |
|
|
186 |
if ($cur_topic['sticky'] == '1')
|
|
187 |
{
|
|
188 |
$subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject;
|
|
189 |
$item_status .= ' isticky';
|
|
190 |
$icon_text .= ' '.$lang_forum['Sticky'];
|
|
191 |
}
|
|
192 |
|
|
193 |
$num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
|
|
194 |
|
|
195 |
if ($num_pages_topic > 1)
|
|
196 |
$subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]';
|
|
197 |
else
|
|
198 |
$subject_multipage = null;
|
|
199 |
|
|
200 |
// Should we show the "New posts" and/or the multipage links?
|
|
201 |
if (!empty($subject_new_posts) || !empty($subject_multipage))
|
|
202 |
{
|
|
203 |
$subject .= ' '.(!empty($subject_new_posts) ? $subject_new_posts : '');
|
|
204 |
$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
|
|
205 |
}
|
|
206 |
|
|
207 |
?>
|
|
208 |
<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
|
|
209 |
<td class="tcl">
|
|
210 |
<div class="intd">
|
|
211 |
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
|
|
212 |
<div class="tclcon">
|
|
213 |
<?php echo $subject."\n" ?>
|
|
214 |
</div>
|
|
215 |
</div>
|
|
216 |
</td>
|
|
217 |
<td class="tc2"><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_replies'] : ' ' ?></td>
|
|
218 |
<td class="tc3"><?php echo ($cur_topic['moved_to'] == null) ? $cur_topic['num_views'] : ' ' ?></td>
|
|
219 |
<td class="tcr"><?php echo $last_post ?></td>
|
|
220 |
</tr>
|
|
221 |
<?php
|
|
222 |
|
|
223 |
}
|
|
224 |
}
|
|
225 |
else
|
|
226 |
{
|
|
227 |
|
|
228 |
?>
|
|
229 |
<tr>
|
|
230 |
<td class="tcl" colspan="4"><?php echo $lang_forum['Empty forum'] ?></td>
|
|
231 |
</tr>
|
|
232 |
<?php
|
|
233 |
|
|
234 |
}
|
|
235 |
|
|
236 |
?>
|
|
237 |
</tbody>
|
|
238 |
</table>
|
|
239 |
</div>
|
|
240 |
</div>
|
|
241 |
</div>
|
|
242 |
|
|
243 |
<div class="linksb">
|
|
244 |
<div class="inbox">
|
|
245 |
<p class="pagelink conl"><?php echo $paging_links ?></p>
|
|
246 |
<?php echo $post_link ?>
|
|
247 |
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
|
|
248 |
<div class="clearer"></div>
|
|
249 |
</div>
|
|
250 |
</div>
|
|
251 |
<?php
|
|
252 |
|
|
253 |
$forum_id = $id;
|
|
254 |
$footer_style = 'viewforum';
|
|
255 |
require PUN_ROOT.'footer.php';
|
|
256 |
|