|
1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2008 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 // if (!defined('PUN_ROOT')) |
|
27 // define('PUN_ROOT', './'); |
|
28 // require PUN_ROOT.'include/common.php'; |
|
29 |
|
30 // import globals (I really hope this isn't dangerous) |
|
31 foreach ( $GLOBALS as $key => $_ ) |
|
32 { |
|
33 $$key =& $GLOBALS[$key]; |
|
34 } |
|
35 |
|
36 ($hook = get_hook('vt_start')) ? eval($hook) : null; |
|
37 |
|
38 if ($pun_user['g_read_board'] == '0') |
|
39 message($lang_common['No view']); |
|
40 |
|
41 // Load the viewtopic.php language file |
|
42 require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php'; |
|
43 |
|
44 |
|
45 $action = isset($_GET['action']) ? $_GET['action'] : null; |
|
46 $id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
47 $pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0; |
|
48 if ($id < 1 && $pid < 1) |
|
49 message($lang_common['Bad request']); |
|
50 |
|
51 |
|
52 // If a post ID is specified we determine topic ID and page number so we can redirect to the correct message |
|
53 if ($pid) |
|
54 { |
|
55 $query = array( |
|
56 'SELECT' => 'p.topic_id, p.posted', |
|
57 'FROM' => 'posts AS p', |
|
58 'WHERE' => 'p.id='.$pid |
|
59 ); |
|
60 |
|
61 ($hook = get_hook('vt_qr_get_post_info')) ? eval($hook) : null; |
|
62 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
63 if (!$pun_db->num_rows($result)) |
|
64 message($lang_common['Bad request']); |
|
65 |
|
66 list($id, $posted) = $pun_db->fetch_row($result); |
|
67 |
|
68 // Determine on what page the post is located (depending on $pun_user['disp_posts']) |
|
69 $query = array( |
|
70 'SELECT' => '1', |
|
71 'FROM' => 'posts AS p', |
|
72 'WHERE' => 'p.topic_id='.$id.' AND p.posted<'.$posted |
|
73 ); |
|
74 |
|
75 ($hook = get_hook('vt_qr_get_post_page')) ? eval($hook) : null; |
|
76 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
77 $num_posts = $pun_db->num_rows($result) + 1; |
|
78 |
|
79 $_GET['p'] = ceil($num_posts / $pun_user['disp_posts']); |
|
80 } |
|
81 |
|
82 // If action=new, we redirect to the first new post (if any) |
|
83 else if ($action == 'new' && !$pun_user['is_guest']) |
|
84 { |
|
85 // We need to check if this topic has been viewed recently by the user |
|
86 $tracked_topics = get_tracked_topics(); |
|
87 $last_viewed = isset($tracked_topics['topics'][$id]) ? $tracked_topics['topics'][$id] : $pun_user['last_visit']; |
|
88 |
|
89 ($hook = get_hook('vt_find_new_post')) ? eval($hook) : null; |
|
90 |
|
91 $query = array( |
|
92 'SELECT' => 'MIN(p.id)', |
|
93 'FROM' => 'posts AS p', |
|
94 'WHERE' => 'p.topic_id='.$id.' AND p.posted>'.$last_viewed |
|
95 ); |
|
96 |
|
97 ($hook = get_hook('vt_qr_get_first_new_post')) ? eval($hook) : null; |
|
98 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
99 $first_new_post_id = $pun_db->result($result); |
|
100 |
|
101 if ($first_new_post_id) |
|
102 header('Location: '.str_replace('&', '&', pun_link($pun_url['post'], $first_new_post_id))); |
|
103 else // If there is no new post, we go to the last post |
|
104 header('Location: '.str_replace('&', '&', pun_link($pun_url['topic_last_post'], $id))); |
|
105 |
|
106 exit; |
|
107 } |
|
108 |
|
109 // If action=last, we redirect to the last post |
|
110 else if ($action == 'last') |
|
111 { |
|
112 $query = array( |
|
113 'SELECT' => 't.last_post_id', |
|
114 'FROM' => 'topics AS t', |
|
115 'WHERE' => 't.id='.$id |
|
116 ); |
|
117 |
|
118 ($hook = get_hook('vt_qr_get_last_post')) ? eval($hook) : null; |
|
119 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
120 $last_post_id = $pun_db->result($result); |
|
121 |
|
122 if ($last_post_id) |
|
123 { |
|
124 header('Location: '.str_replace('&', '&', pun_link($pun_url['post'], $last_post_id))); |
|
125 exit; |
|
126 } |
|
127 } |
|
128 |
|
129 |
|
130 // Fetch some info about the topic |
|
131 $query = array( |
|
132 'SELECT' => 't.subject, t.posted, t.poster, t.first_post_id, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies', |
|
133 'FROM' => 'topics AS t', |
|
134 'JOINS' => array( |
|
135 array( |
|
136 'INNER JOIN' => 'forums AS f', |
|
137 'ON' => 'f.id=t.forum_id' |
|
138 ), |
|
139 array( |
|
140 'LEFT JOIN' => 'forum_perms AS fp', |
|
141 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')' |
|
142 ) |
|
143 ), |
|
144 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL' |
|
145 ); |
|
146 |
|
147 if (!$pun_user['is_guest']) |
|
148 { |
|
149 $query['SELECT'] .= ', s.user_id AS is_subscribed'; |
|
150 $query['JOINS'][] = array( |
|
151 'LEFT JOIN' => 'subscriptions AS s', |
|
152 'ON' => '(t.id=s.topic_id AND s.user_id='.$pun_user['id'].')' |
|
153 ); |
|
154 } |
|
155 |
|
156 ($hook = get_hook('vt_qr_get_topic_info')) ? eval($hook) : null; |
|
157 $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
158 if (!$pun_db->num_rows($result)) |
|
159 message($lang_common['Bad request']); |
|
160 |
|
161 $cur_topic = $pun_db->fetch_assoc($result); |
|
162 |
|
163 // Sort out who the moderators are and if we are currently a moderator (or an admin) |
|
164 $mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array(); |
|
165 $pun_user['is_admmod'] = ($session->user_level >= USER_LEVEL_MOD || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false; |
|
166 |
|
167 // Can we or can we not post replies? |
|
168 if ($cur_topic['closed'] == '0' || $pun_user['is_admmod']) |
|
169 $pun_user['may_post'] = (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $pun_user['is_admmod']) ? true : false; |
|
170 else |
|
171 $pun_user['may_post'] = false; |
|
172 |
|
173 // Add/update this topic in our list of tracked topics |
|
174 if (!$pun_user['is_guest']) |
|
175 { |
|
176 $tracked_topics = get_tracked_topics(); |
|
177 $tracked_topics['topics'][$id] = time(); |
|
178 set_tracked_topics($tracked_topics); |
|
179 } |
|
180 |
|
181 // Determine the post offset (based on $_GET['p']) |
|
182 $pun_page['num_pages'] = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); |
|
183 $pun_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $pun_page['num_pages']) ? 1 : $_GET['p']; |
|
184 $pun_page['start_from'] = $pun_user['disp_posts'] * ($pun_page['page'] - 1); |
|
185 $pun_page['finish_at'] = min(($pun_page['start_from'] + $pun_user['disp_posts']), ($cur_topic['num_replies'] + 1)); |
|
186 |
|
187 // Navigation links for header and page numbering for title/meta description |
|
188 if ($pun_page['page'] < $pun_page['num_pages']) |
|
189 { |
|
190 $pun_page['nav'][] = '<link rel="last" href="'.pun_sublink($pun_url['topic'], $pun_url['page'], $pun_page['num_pages'], array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.$pun_page['num_pages'].'" />'; |
|
191 $pun_page['nav'][] = '<link rel="next" href="'.pun_sublink($pun_url['topic'], $pun_url['page'], ($pun_page['page'] + 1), array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.($pun_page['page'] + 1).'" />'; |
|
192 } |
|
193 if ($pun_page['page'] > 1) |
|
194 { |
|
195 $pun_page['nav'][] = '<link rel="prev" href="'.pun_sublink($pun_url['topic'], $pun_url['page'], ($pun_page['page'] - 1), array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' '.($pun_page['page'] - 1).'" />'; |
|
196 $pun_page['nav'][] = '<link rel="first" href="'.pun_link($pun_url['topic'], array($id, sef_friendly($cur_topic['subject']))).'" title="'.$lang_common['Page'].' 1" />'; |
|
197 } |
|
198 |
|
199 // Generate page information |
|
200 if ($pun_page['num_pages'] > 1) |
|
201 $pun_page['main_info'] = '<span>'.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' </span>'.sprintf($lang_common['Paged info'], $lang_common['Posts'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $cur_topic['num_replies'] + 1); |
|
202 else |
|
203 $pun_page['main_info'] = sprintf($lang_common['Page info'], $lang_common['Posts'], ($cur_topic['num_replies'] + 1)); |
|
204 |
|
205 // Generate paging and posting links |
|
206 $pun_page['page_post'][] = '<p class="paging"><strong>'.$lang_common['Pages'].'</strong> '.pun_paginate($pun_page['num_pages'], $pun_page['page'], $pun_url['topic'], array($id, sef_friendly($cur_topic['subject']))).'</p>'; |
|
207 |
|
208 if ($pun_user['may_post']) |
|
209 $pun_page['page_post'][] = '<p class="posting"><a class="newpost" href="'.pun_link($pun_url['new_reply'], $id).'"><span>'.$lang_topic['Post reply'].'</span></a></p>'; |
|
210 |
|
211 // Setup options for main header and footer |
|
212 $pun_page['main_head_options'] = array(); |
|
213 |
|
214 if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1') |
|
215 { |
|
216 if ($cur_topic['is_subscribed']) |
|
217 $pun_page['main_head_options'][] = '<a class="sub-option" href="'.pun_link($pun_url['unsubscribe'], $id).'"><em>'.$lang_topic['Cancel subscription'].'</em></a>'; |
|
218 else |
|
219 $pun_page['main_head_options'][] = '<a class="sub-option" href="'.pun_link($pun_url['subscribe'], $id).'">'.$lang_topic['Subscription'].'</a>'; |
|
220 } |
|
221 |
|
222 $pun_page['main_head_options'][] = '<a class="feed-option" href="'.pun_link($pun_url['topic_atom'], $id).'">'.$lang_common['ATOM Feed'].'</a>'; |
|
223 $pun_page['main_head_options'][] = '<a class="feed-option" href="'.pun_link($pun_url['topic_rss'], $id).'">'.$lang_common['RSS Feed'].'</a>'; |
|
224 |
|
225 $pun_page['main_foot_options'] = array(); |
|
226 if ($pun_user['is_admmod']) |
|
227 { |
|
228 $pun_page['main_foot_options'][] = '<a class="mod-option" href="'.pun_link($pun_url['move'], array($cur_topic['forum_id'], $id)).'">'.$lang_topic['Move'].'</a>'; |
|
229 $pun_page['main_foot_options'][] = '<a class="mod-option" href="'.pun_link($pun_url['delete'], $cur_topic['first_post_id']).'">'.$lang_topic['Delete topic'].'</a>'; |
|
230 $pun_page['main_foot_options'][] = (($cur_topic['closed'] == '1') ? '<a class="mod-option" href="'.pun_link($pun_url['open'], array($cur_topic['forum_id'], $id, generate_form_token('open'.$id))).'">'.$lang_topic['Open'].'</a>' : '<a class="mod-option" href="'.pun_link($pun_url['close'], array($cur_topic['forum_id'], $id, generate_form_token('close'.$id))).'">'.$lang_topic['Close'].'</a>'); |
|
231 $pun_page['main_foot_options'][] = (($cur_topic['sticky'] == '1') ? '<a class="mod-option" href="'.pun_link($pun_url['unstick'], array($cur_topic['forum_id'], $id, generate_form_token('unstick'.$id))).'">'.$lang_topic['Unstick'].'</a>' : '<a class="mod-option" href="'.pun_link($pun_url['stick'], array($cur_topic['forum_id'], $id, generate_form_token('stick'.$id))).'">'.$lang_topic['Stick'].'</a>'); |
|
232 |
|
233 if ($cur_topic['num_replies'] != 0) |
|
234 $pun_page['main_foot_options'][] = '<a class="mod-option" href="'.pun_sublink($pun_url['delete_multiple'], $pun_url['page'], $pun_page['page'], array($cur_topic['forum_id'], $id)).'">'.$lang_topic['Delete posts'].'</a>'; |
|
235 } |
|
236 |
|
237 if ($pun_user['is_guest'] && !$pun_user['may_post']) |
|
238 $pun_page['main_foot_options'][] = sprintf($lang_topic['Topic login nag'], '<a href="'.pun_link($pun_url['login']).'">'.strtolower($lang_common['Login']).'</a>', '<a href="'.pun_link($pun_url['register']).'">'.strtolower($lang_common['Register']).'</a>'); |
|
239 |
|
240 if ($pun_config['o_censoring'] == '1') |
|
241 $cur_topic['subject'] = censor_words($cur_topic['subject']); |
|
242 |
|
243 // Setup breadcrumbs |
|
244 $pun_page['crumbs'] = array( |
|
245 array($pun_config['o_board_title'], pun_link($pun_url['index'])), |
|
246 array($cur_topic['forum_name'], pun_link($pun_url['forum'], array($cur_topic['forum_id'], sef_friendly($cur_topic['forum_name'])))), |
|
247 array($cur_topic['subject'], pun_link($pun_url['topic'], array($id, sef_friendly($cur_topic['subject'])))), |
|
248 ); |
|
249 |
|
250 ($hook = get_hook('vt_pre_header_load')) ? eval($hook) : null; |
|
251 |
|
252 define('PUN_ALLOW_INDEX', 1); |
|
253 define('PUN_PAGE', 'viewtopic'); |
|
254 require PUN_ROOT.'header.php'; |
|
255 |
|
256 ?> |
|
257 <div id="pun-main" class="main paged"> |
|
258 |
|
259 <h1><span><a class="permalink" href="<?php echo pun_link($pun_url['topic'], array($id, sef_friendly($cur_topic['subject']))) ?>" rel="bookmark" title="<?php echo $lang_topic['Permalink topic'] ?>"><?php echo htmlspecialchars($cur_topic['subject']) ?></a></span></h1> |
|
260 |
|
261 <div class="paged-head"> |
|
262 <?php echo implode("\n\t\t", $pun_page['page_post'])."\n" ?> |
|
263 </div> |
|
264 |
|
265 <div class="main-head"> |
|
266 <p class="main-options"><?php echo implode(' ', $pun_page['main_head_options']) ?></p> |
|
267 <h2><span><?php echo $pun_page['main_info'] ?></span></h2> |
|
268 </div> |
|
269 |
|
270 <div id="forum<?php echo $cur_topic['forum_id'] ?>" class="main-content topic"> |
|
271 <?php |
|
272 |
|
273 require PUN_ROOT.'include/parser.php'; |
|
274 |
|
275 $pun_page['item_count'] = 0; // Keep track of post numbers |
|
276 |
|
277 // Retrieve the posts (and their respective poster/online status) |
|
278 $query = array( |
|
279 'SELECT' => 'u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online', |
|
280 'FROM' => 'posts AS p', |
|
281 'JOINS' => array( |
|
282 array( |
|
283 'INNER JOIN' => 'users AS u', |
|
284 'ON' => 'u.id=p.poster_id' |
|
285 ), |
|
286 array( |
|
287 'INNER JOIN' => 'groups AS g', |
|
288 'ON' => 'g.g_id=u.group_id' |
|
289 ), |
|
290 array( |
|
291 'LEFT JOIN' => 'online AS o', |
|
292 'ON' => '(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)' |
|
293 ), |
|
294 ), |
|
295 'WHERE' => 'p.topic_id='.$id, |
|
296 'ORDER BY' => 'p.id', |
|
297 'LIMIT' => $pun_page['start_from'].','.$pun_user['disp_posts'] |
|
298 ); |
|
299 |
|
300 ($hook = get_hook('vt_qr_get_posts')) ? eval($hook) : null; |
|
301 $result = $pun_db->query_build($query, true) or error(__FILE__, __LINE__); |
|
302 while ($cur_post = $pun_db->fetch_assoc($result)) |
|
303 { |
|
304 ($hook = get_hook('vt_post_loop_start')) ? eval($hook) : null; |
|
305 |
|
306 ++$pun_page['item_count']; |
|
307 |
|
308 $signature = ''; |
|
309 $pun_page['user_ident'] = array(); |
|
310 $pun_page['user_info'] = array(); |
|
311 $pun_page['post_options'] = array(); |
|
312 $pun_page['message'] = array(); |
|
313 |
|
314 // Generate the post heading |
|
315 $pun_page['item_ident'] = array( |
|
316 'num' => '<strong>'.($pun_page['start_from'] + $pun_page['item_count']).'</strong>', |
|
317 'user' => '<cite>'.($cur_topic['posted'] == $cur_post['posted'] ? sprintf($lang_topic['Topic by'], htmlspecialchars($cur_post['username'])) : sprintf($lang_topic['Reply by'], htmlspecialchars($cur_post['username']))).'</cite>', |
|
318 'date' => '<span>'.format_time($cur_post['posted']).'</span>' |
|
319 ); |
|
320 |
|
321 $pun_page['item_head'] = '<a class="permalink" rel="bookmark" title="'.$lang_topic['Permalink post'].'" href="'.pun_link($pun_url['post'], $cur_post['id']).'">'.implode(' ', $pun_page['item_ident']).'</a>'; |
|
322 |
|
323 // Generate author identification |
|
324 if ($cur_post['poster_id'] > 1 && $pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0') |
|
325 { |
|
326 if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif')) |
|
327 $pun_page['user_ident'][] = '<img src="'.$base_url.'/'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />'; |
|
328 else if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg')) |
|
329 $pun_page['user_ident'][] = '<img src="'.$base_url.'/'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />'; |
|
330 else if (file_exists($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png') && $img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png')) |
|
331 $pun_page['user_ident'][] = '<img src="'.$base_url.'/'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />'; |
|
332 } |
|
333 |
|
334 if ($cur_post['poster_id'] > 1) |
|
335 { |
|
336 $pun_page['user_ident'][] = '<strong class="username"><a title="'.sprintf($lang_topic['Go to profile'], htmlspecialchars($cur_post['username'])).'" href="'.pun_link($pun_url['user'], $cur_post['poster_id']).'">'.htmlspecialchars($cur_post['username']).'</a></strong>'; |
|
337 $pun_page['user_info'][] = '<li class="title"><span><strong>'.$lang_topic['Title'].'</strong> '.get_title($cur_post).'</span></li>'; |
|
338 |
|
339 if ($cur_post['is_online'] == $cur_post['poster_id']) |
|
340 $pun_page['user_info'][] = '<li class="status"><span><strong>'.$lang_topic['Status'].'</strong> '.$lang_topic['Online'].'</span></li>'; |
|
341 else |
|
342 $pun_page['user_info'][] = '<li class="status"><span><strong>'.$lang_topic['Status'].'</strong> '.$lang_topic['Offline'].'</span></li>'; |
|
343 } |
|
344 else |
|
345 { |
|
346 $pun_page['user_ident'][] = '<strong class="username">'.htmlspecialchars($cur_post['username']).'</strong>'; |
|
347 $pun_page['user_info'][] = '<li class="title"><span><strong>'.$lang_topic['Title'].'</strong> '.get_title($cur_post).'</span></li>'; |
|
348 } |
|
349 |
|
350 // Generate author information |
|
351 if ($cur_post['poster_id'] > 1 && $pun_config['o_show_user_info'] == '1') |
|
352 { |
|
353 |
|
354 $pun_page['user_info'][] = '<li><span><strong>'.$lang_topic['Registered'].'</strong> '.format_time($cur_post['registered'], true).'</span></li>'; |
|
355 |
|
356 if ($cur_post['location'] != '') |
|
357 { |
|
358 if ($pun_config['o_censoring'] == '1') |
|
359 $cur_post['location'] = censor_words($cur_post['location']); |
|
360 |
|
361 $pun_page['user_info'][] = '<li><span><strong>'.$lang_topic['From'].'</strong> '.htmlspecialchars($cur_post['location']).'</span></li>'; |
|
362 } |
|
363 |
|
364 if ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) |
|
365 $pun_page['user_info'][] = '<li><span><strong>'.$lang_topic['Posts'].'</strong> '.$cur_post['num_posts'].'</span></li>'; |
|
366 |
|
367 if ($pun_user['is_admmod']) |
|
368 { |
|
369 $pun_page['user_info'][] = '<li><span><strong>'.$lang_topic['IP'].'</strong> <a href="'.pun_link($pun_url['get_host'], $cur_post['id']).'">'.$cur_post['poster_ip'].'</a></span></li>'; |
|
370 |
|
371 if ($cur_post['admin_note'] != '') |
|
372 $pun_page['user_info'][] = '<li><span><strong>'.$lang_topic['Note'].'</strong> '.htmlspecialchars($cur_post['admin_note']).'</span></li>'; |
|
373 } |
|
374 } |
|
375 |
|
376 // Generate author contact details |
|
377 if ($pun_config['o_show_user_info'] == '1') |
|
378 { |
|
379 if ($cur_post['poster_id'] > 1) |
|
380 { |
|
381 if ($cur_post['url'] != '') |
|
382 $pun_page['post_options'][] = '<a class="contact external" href="'.htmlspecialchars($cur_post['url']).'"><span>'.sprintf($lang_topic['Visit website'], htmlspecialchars($cur_post['username'])).'</span></a>'; |
|
383 if (($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) || $pun_user['is_admmod']) |
|
384 $pun_page['post_options'][] = '<a class="contact" href="mailto:'.$cur_post['email'].'"><span>'.$lang_common['E-mail'].'<span> '.htmlspecialchars($cur_post['username']).'</span></span></a>'; |
|
385 else if ($cur_post['email_setting'] == '1' && !$pun_user['is_guest']) |
|
386 $pun_page['post_options'][] = '<a class="contact" href="'.pun_link($pun_url['email'], $cur_post['poster_id']).'"><span>'.$lang_common['E-mail'].'<span> '.htmlspecialchars($cur_post['username']).'</span></span></a>'; |
|
387 } |
|
388 else |
|
389 { |
|
390 if ($cur_post['poster_email'] != '' && !$pun_user['is_guest']) |
|
391 $pun_page['post_options'][] = '<a class="contact" href="mailto:'.$cur_post['poster_email'].'"><span>'.$lang_common['E-mail'].'<span> '.htmlspecialchars($cur_post['username']).'</span></span></a>'; |
|
392 } |
|
393 } |
|
394 |
|
395 // Generate the post options links |
|
396 if (!$pun_user['is_guest']) |
|
397 { |
|
398 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['report'], $cur_post['id']).'"><span>'.$lang_topic['Report'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
399 |
|
400 if (!$pun_user['is_admmod']) |
|
401 { |
|
402 if ($cur_topic['closed'] == '0') |
|
403 { |
|
404 if ($cur_post['poster_id'] == $pun_user['id']) |
|
405 { |
|
406 if (($pun_page['start_from'] + $pun_page['item_count']) == 1 && $pun_user['g_delete_topics'] == '1') |
|
407 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['delete'], $cur_topic['first_post_id']).'"><span>'.$lang_topic['Delete topic'].'</span></a>'; |
|
408 if (($pun_page['start_from'] + $pun_page['item_count']) > 1 && $pun_user['g_delete_posts'] == '1') |
|
409 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['delete'], $cur_post['id']).'"><span>'.$lang_topic['Delete'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
410 if ($pun_user['g_edit_posts'] == '1') |
|
411 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['edit'], $cur_post['id']).'"><span>'.$lang_topic['Edit'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
412 } |
|
413 |
|
414 if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1') |
|
415 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['quote'], array($id, $cur_post['id'])).'"><span>'.$lang_topic['Quote'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
416 } |
|
417 } |
|
418 else |
|
419 { |
|
420 if (($pun_page['start_from'] + $pun_page['item_count']) == 1) |
|
421 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['delete'], $cur_topic['first_post_id']).'">'.$lang_topic['Delete topic'].'</a>'; |
|
422 else |
|
423 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['delete'], $cur_post['id']).'"><span>'.$lang_topic['Delete'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
424 |
|
425 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['edit'], $cur_post['id']).'"><span>'.$lang_topic['Edit'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
426 $pun_page['post_options'][] = '<a href="'.pun_link($pun_url['quote'], array($id, $cur_post['id'])).'"><span>'.$lang_topic['Quote'].'<span> '.$lang_topic['Post'].' '.($pun_page['start_from'] + $pun_page['item_count']).'</span></span></a>'; |
|
427 } |
|
428 } |
|
429 |
|
430 // Give the post some class |
|
431 $pun_page['item_status'] = array( |
|
432 'post', |
|
433 ($pun_page['item_count'] % 2 == 0) ? 'odd' : 'even' |
|
434 ); |
|
435 |
|
436 if ($pun_page['item_count'] == 1) |
|
437 $pun_page['item_status'][] = 'firstpost'; |
|
438 |
|
439 if (($pun_page['start_from'] + $pun_page['item_count']) == $pun_page['finish_at']) |
|
440 $pun_page['item_status'][] = 'lastpost'; |
|
441 |
|
442 if ($cur_post['id'] == $cur_topic['first_post_id']) |
|
443 $pun_page['item_status'][] = 'topicpost'; |
|
444 else |
|
445 $pun_page['item_status'][] = 'replypost'; |
|
446 |
|
447 |
|
448 // Generate the post title |
|
449 if ($cur_post['id'] == $cur_topic['first_post_id']) |
|
450 $pun_page['item_subject'] = $lang_common['Topic'].': '.$cur_topic['subject']; |
|
451 else |
|
452 $pun_page['item_subject'] = $lang_common['Re'].' '.$cur_topic['subject']; |
|
453 |
|
454 // Perform the main parsing of the message (BBCode, smilies, censor words etc) |
|
455 $pun_page['message'][] = parse_message($cur_post['message'], $cur_post['hide_smilies']); |
|
456 |
|
457 if ($cur_post['edited'] != '') |
|
458 $pun_page['message'][] = '<p class="lastedit"><em>'.sprintf($lang_topic['Last edited'], htmlspecialchars($cur_post['edited_by']), format_time($cur_post['edited'])).'</em></p>'; |
|
459 |
|
460 // Do signature parsing/caching |
|
461 if ($cur_post['signature'] != '' && $pun_user['show_sig'] != '0' && $pun_config['o_signatures'] == '1') |
|
462 { |
|
463 if (!isset($signature_cache[$cur_post['poster_id']])) |
|
464 $signature_cache[$cur_post['poster_id']] = parse_signature($cur_post['signature']); |
|
465 |
|
466 $pun_page['message'][] = '<div class="sig-content">'."\n\t\t\t\t\t\t\t\t".'<span class="sig-line"><!-- --></span>'."\n\t\t\t\t\t\t\t\t".$signature_cache[$cur_post['poster_id']]."\n\t\t\t\t\t\t\t".'</div>'; |
|
467 } |
|
468 |
|
469 ($hook = get_hook('vt_row_pre_display')) ? eval($hook) : null; |
|
470 |
|
471 ?> |
|
472 <div class="<?php echo implode(' ', $pun_page['item_status']) ?>"> |
|
473 <div class="postmain"> |
|
474 <div id="p<?php echo $cur_post['id'] ?>" class="posthead"> |
|
475 <h3><?php echo $pun_page['item_head'] ?></h3> |
|
476 </div> |
|
477 <div class="postbody"> |
|
478 <div class="user<?php if ($cur_post['is_online'] == $cur_post['poster_id']) echo ' online' ?>"> |
|
479 <h4 class="user-ident"><?php echo implode(' ', $pun_page['user_ident']) ?></h4> |
|
480 <ul class="user-info"> |
|
481 <?php echo implode("\n\t\t\t\t\t\t\t", $pun_page['user_info'])."\n" ?> |
|
482 </ul> |
|
483 </div> |
|
484 <div class="post-entry"> |
|
485 <h4 class="entry-title"><?php echo $pun_page['item_subject'] ?></h4> |
|
486 <div class="entry-content"> |
|
487 <?php echo implode("\n\t\t\t\t\t\t\t", $pun_page['message'])."\n" ?> |
|
488 </div> |
|
489 </div> |
|
490 </div> |
|
491 <?php if (!empty($pun_page['post_options'])): ?> <div class="postfoot"> |
|
492 <div class="post-options"> |
|
493 <?php echo implode(' ', $pun_page['post_options'])."\n" ?> |
|
494 </div> |
|
495 </div> |
|
496 <?php endif; ?> </div> |
|
497 </div> |
|
498 <?php |
|
499 |
|
500 } |
|
501 |
|
502 ?> |
|
503 </div> |
|
504 |
|
505 <div class="main-foot"> |
|
506 <p class="h2"><strong><?php echo $pun_page['main_info'] ?></strong></p> |
|
507 <?php if (!empty($pun_page['main_foot_options'])): ?> <p class="main-options"><?php echo implode(' ', $pun_page['main_foot_options']) ?></p> |
|
508 <?php endif; ?> </div> |
|
509 |
|
510 <div class="paged-foot"> |
|
511 <?php echo implode("\n\t\t", array_reverse($pun_page['page_post']))."\n" ?> |
|
512 </div> |
|
513 |
|
514 </div> |
|
515 |
|
516 <div id="pun-crumbs-foot"> |
|
517 <p class="crumbs"><?php echo generate_crumbs(false) ?></p> |
|
518 </div> |
|
519 <?php |
|
520 |
|
521 |
|
522 // Display quick post if enabled |
|
523 if ($pun_config['o_quickpost'] == '1' && |
|
524 !$pun_user['is_guest'] && |
|
525 ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1')) && |
|
526 ($cur_topic['closed'] == '0' || $pun_user['is_admmod'])) |
|
527 { |
|
528 |
|
529 // Setup form |
|
530 $pun_page['form_action'] = pun_link($pun_url['new_reply'], $id); |
|
531 |
|
532 $pun_page['hidden_fields'] = array( |
|
533 '<input type="hidden" name="form_sent" value="1" />', |
|
534 '<input type="hidden" name="form_user" value="'.((!$pun_user['is_guest']) ? htmlspecialchars($pun_user['username']) : 'Guest').'" />' |
|
535 ); |
|
536 |
|
537 if ($pun_user['is_admmod']) |
|
538 $pun_page['hidden_fields'][] = '<input type="hidden" name="csrf_token" value="'.generate_form_token($pun_page['form_action']).'" />'; |
|
539 |
|
540 if (!$pun_user['is_guest'] && $pun_config['o_subscriptions'] == '1' && ($pun_user['auto_notify'] == '1' || $cur_topic['is_subscribed'])) |
|
541 $pun_page['hidden_fields'][] = '<input type="hidden" name="subscribe" value="1" />'; |
|
542 |
|
543 // Setup help |
|
544 $pun_page['main_head_options'] = array(); |
|
545 if ($pun_config['p_message_bbcode'] == '1') |
|
546 $pun_page['main_head_options'][] = '<a class="exthelp" href="'.pun_link($pun_url['help'], 'bbcode').'" title="'.sprintf($lang_common['Help page'], $lang_common['BBCode']).'">'.$lang_common['BBCode'].'</a>'; |
|
547 if ($pun_config['p_message_img_tag'] == '1') |
|
548 $pun_page['main_head_options'][] = '<a class="exthelp" href="'.pun_link($pun_url['help'], 'img').'" title="'.sprintf($lang_common['Help page'], $lang_common['Images']).'">'.$lang_common['Images'].'</a>'; |
|
549 if ($pun_config['o_smilies'] == '1') |
|
550 $pun_page['main_head_options'][] = '<a class="exthelp" href="'.pun_link($pun_url['help'], 'smilies').'" title="'.sprintf($lang_common['Help page'], $lang_common['Smilies']).'">'.$lang_common['Smilies'].'</a>'; |
|
551 |
|
552 ($hook = get_hook('vt_quickpost_pre_display')) ? eval($hook) : null; |
|
553 |
|
554 ?> |
|
555 <div id="pun-qpost" class="main"> |
|
556 |
|
557 <div class="main-head"> |
|
558 <h2><span><?php echo $lang_topic['Quick post'] ?></span></h2> |
|
559 <?php if (!empty($pun_page['main_head_options'])): ?> <p class="main-options"><?php printf($lang_common['You may use'], implode(' ', $pun_page['main_head_options'])) ?></p> |
|
560 <?php endif; ?> </div> |
|
561 |
|
562 <div class="main-content frm"> |
|
563 <div id="req-msg" class="frm-warn"> |
|
564 <p class="important"><?php printf($lang_common['Required warn'], '<em class="req-text">'.$lang_common['Required'].'</em>') ?></p> |
|
565 </div> |
|
566 <form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo $pun_page['form_action'] ?>"> |
|
567 <div class="hidden"> |
|
568 <?php echo implode("\n\t\t\t\t", $pun_page['hidden_fields'])."\n" ?> |
|
569 </div> |
|
570 <?php ($hook = get_hook('vt_quickpost_pre_fieldset')) ? eval($hook) : null; ?> |
|
571 <fieldset class="frm-set set1"> |
|
572 <legend class="frm-legend"><strong><?php echo $lang_common['Write message legend'] ?></strong></legend> |
|
573 <?php ($hook = get_hook('vt_quickpost_fieldset_start')) ? eval($hook) : null; ?> |
|
574 <div class="frm-fld text textarea required"> |
|
575 <label for="fld1"> |
|
576 <span class="fld-label"><?php echo $lang_common['Write message'] ?></span><br /> |
|
577 <span class="fld-input"><textarea id="fld1" name="req_message" rows="7" cols="95"></textarea></span> |
|
578 <em class="req-text"><?php echo $lang_common['Required'] ?></em> |
|
579 </label> |
|
580 </div> |
|
581 </fieldset> |
|
582 <?php ($hook = get_hook('vt_quickpost_post_fieldset')) ? eval($hook) : null; ?> |
|
583 <div class="frm-buttons"> |
|
584 <span class="submit"><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" title="<?php echo $lang_common['Submit title'] ?>" /></span> |
|
585 <span class="submit"><input type="submit" name="preview" value="<?php echo $lang_common['Preview'] ?>" accesskey="p" title="<?php echo $lang_common['Preview title'] ?>" /></span> |
|
586 </div> |
|
587 </form> |
|
588 </div> |
|
589 |
|
590 </div> |
|
591 <?php |
|
592 |
|
593 } |
|
594 |
|
595 // Increment "num_views" for topic |
|
596 if ($pun_config['o_topic_views'] == '1') |
|
597 { |
|
598 $query = array( |
|
599 'UPDATE' => 'topics', |
|
600 'SET' => 'num_views=num_views+1', |
|
601 'WHERE' => 'id='.$id, |
|
602 'PARAMS' => array( |
|
603 'LOW_PRIORITY' => 1 // MySQL only |
|
604 ) |
|
605 ); |
|
606 |
|
607 ($hook = get_hook('vt_qr_increment_num_views')) ? eval($hook) : null; |
|
608 $pun_db->query_build($query) or error(__FILE__, __LINE__); |
|
609 } |
|
610 |
|
611 $forum_id = $cur_topic['forum_id']; |
|
612 |
|
613 ($hook = get_hook('vt_end')) ? eval($hook) : null; |
|
614 |
|
615 require PUN_ROOT.'footer.php'; |