root/phpBB2/viewtopic.php

Revision 324, 60.7 kB (checked in by Nafania, 1 year ago)

Много мелких изменений. Если используется xbtt, то надо обязательно скачать новую версию на форуме.
Добавлен файл cron.php - если есть возможность, то пускайте cron таски через него. Особенно если используете массовую рассылку почты.

Line 
1 <?php
2 /***************************************************************************</span>
3 <span class="code-comment"> *                   viewtopic.php
4  *                -------------------
5  *   begin        : Saturday, Feb 13, 2001
6  *   copyright        : (C) 2001 The phpBB Group
7  *   email        : support@phpbb.com
8  *
9  *   $Id: viewtopic.php,v 1.186.2.45 2005/10/05 17:42:04 grahamje Exp $
10  *
11  *
12  ***************************************************************************/
13
14 /***************************************************************************
15  *
16  *   This program is free software; you can redistribute it and/or modify
17  *   it under the terms of the GNU General Public License as published by
18  *   the Free Software Foundation; either version 2 of the License, or
19  *   (at your option) any later version.
20  *
21  ***************************************************************************/
22
23 if ( !defined('IN_PHPBB2_BRIDGE') ) {</span>
24 <span class="code-keyword">    trigger_error('Invalid access');
25 }
26
27 define('IN_PHPBB', true);
28 $root_path = './';</span>
29 <span class="code-lang">include($root_path . 'extension.inc');
30 include($root_path . 'phpBB2/includes/bbcode.'.$phpEx);
31 include($root_path . 'include/bbcode/bbcode.lib.php');
32 include($root_path . 'include/functions_post.'.$phpEx);
33 include($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_printertopic.' . $phpEx);
34
35 //</span>
36 <span class="code-comment">// Start initial var setup
37 //
38 $topic_id = request_var(POST_TOPIC_URL, 0);
39 $topic_id = ( $topic_id ? $topic_id : request_var('topic', 0) );
40 $post_id = request_var(POST_POST_URL, 0);
41 $view = request_var('view', '');
42 $unwatch = request_var('unwatch', '');
43 $watch = request_var('watch', '');
44 $postdays = request_var('postdays', 0);
45 $postorder = request_var('postorder', 'asc');
46 $highlight = request_var('highlight', '');
47 $vote = request_var('vote', '');
48
49 $start = request_var('start', 0);
50 $start = ($start < 0) ? 0 : $start;
51
52 $start_rel = request_var('start_rel', 0);
53 $finish_rel = request_var('finish_rel', 0);</span>
54 <span class="code-lang">
55 if( isset($_GET['printertopic']) )
56 {
57
58     $start = ( $start_rel ? $start_rel - 1 : $start );
59     // $finish when positive indicates last message; when negative it indicates range; can't be 0
60     if( $finish_rel )
61     {
62         if( ($finish_rel >= 0) && ( ($finish_rel - $start) <= 0) ) {
63             $finish_rel = 0;
64         }
65     }
66 }
67
68 if (!$topic_id && !$post_id)
69 {
70     trigger_error('topic_post_not_exist');
71     return;
72 }
73
74 //</span>
75 <span class="code-comment">// Start session management
76 //
77 $userdata = session_pagestart($user_ip);
78 init_userprefs($userdata);
79 //</span>
80 <span class="code-comment">// End session management
81 //
82
83 /* */
84 $bb_code = new bbcode;
85 /* */</span>
86 <span class="code-comment">
87 //
88 // Find topic id if user requested a newer
89 // or older topic
90 //
91 if ( $view )</span>
92 <span class="code-keyword">{
93     if ( $view == 'newest' )
94     {
95         $sql = 'SELECT forum_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id;
96         $result = $db->sql_query($sql);
97         if ( !$row = $db->sql_fetchrow($result) ) {
98             trigger_error('topic_post_not_exist');
99         }
100         // Get topic tracking info
101         $topic_tracking_info = get_complete_topic_tracking($row['forum_id'], $topic_id);
102
103         $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : $userdata['session_time'];
104
105             $sql = "SELECT p.post_id
106                 FROM " . POSTS_TABLE . " p
107                 WHERE p.topic_id = $topic_id
108                  AND p.post_time >= " . $topic_last_read . "
109                 ORDER BY p.post_time ASC
110                  LIMIT 1";
111             $result = $db->sql_query($sql);
112
113             if ( !$row = $db->sql_fetchrow($result) ) {
114                 trigger_error('no_new_posts_last_visit');
115                 return;
116             }
117
118             // www.phpBB-SEO.com SEO TOOLKIT BEGIN
119             $seo->set_url('', $topic_id, $seo->seo_static['topic']);
120             // www.phpBB-SEO.com SEO TOOLKIT END
121
122            $post_id = $row['post_id'];
123            $url = append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id&" . POST_POST_URL . "=$post_id#$post_id");
124            redirect($url);
125     }
126     else if ( $view == 'next' || $view == 'previous' )
127     {
128         $sql_condition = ( $view == 'next' ) ? '>' : '<';
129         $sql_ordering = ( $view == 'next' ) ? 'ASC' : 'DESC';
130
131         $sql = "SELECT t.topic_id
132             FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
133             WHERE
134                 t2.topic_id = $topic_id
135                 AND t.forum_id = t2.forum_id
136                 AND t.topic_moved_id = 0
137                 AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
138             ORDER BY t.topic_last_post_id $sql_ordering
139             LIMIT 1";
140         $result = $db->sql_query($sql);
141
142         if ( $row = $db->sql_fetchrow($result) )
143         {
144             $topic_id = intval($row['topic_id']);
145         }
146         else
147         {
148             $message = ( $view == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
149             trigger_error($message);
150             return;
151         }
152     }
153 }
154
155 //</span>
156 <span class="code-comment">// This rather complex gaggle of code handles querying for topics but
157 // also allows for direct linking to a post (and the calculation of which
158 // page the post is on and the correct display of viewtopic)
159 //
160 $sql_array['SELECT'] = 't.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, t.topic_last_post_time, t.topic_first_post_id, t.topic_first_post_sticky, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments, f.forum_last_post_time';
161 $sql_array['FROM'] = array(</span>
162 <span class="code-lang">    TOPICS_TABLE    => 't',
163     FORUMS_TABLE    => 'f'
164 );
165 $sql_array['WHERE'] = "t.topic_id = $topic_id AND f.forum_id = t.forum_id";</span>
166 <span class="code-lang">
167
168 if ( $post_id ) {
169     $sql_array['SELECT'] .= ', COUNT(p2.post_id) AS prev_posts';
170     $sql_array['FROM'] += array(
171         POSTS_TABLE    => 'p',
172     );
173
174     $sql_array['LEFT_JOIN'] = array(
175         array(
176             'FROM' => array(POSTS_TABLE => 'p2'),
177             'ON' => "p2.topic_id = p.topic_id AND p2.post_id <= $post_id"
178     ));
179     $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id AND f.forum_id = t.forum_id";
180     $sql_array['ORDER_BY'] = 'p.post_id';
181     $sql_array['GROUP_BY'] = 'p2.topic_id';
182 }
183
184 $sql = $db->sql_build_query('SELECT', $sql_array);
185 $result = $db->sql_query($sql);</span>
186 <span class="code-lang">
187 if ( !$forum_topic_data = $db->sql_fetchrow($result) )
188 {
189     trigger_error('topic_post_not_exist');
190     return;
191 }
192 $forum_id = intval($forum_topic_data['forum_id']);
193
194 //</span>
195 <span class="code-comment">// Start auth check
196 //
197 $is_auth = array();
198 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);</span>
199 <span class="code-lang">
200 if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
201 {
202     if ( !$userdata['session_logged_in'] )
203     {
204         $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
205         $redirect .= ($start) ? "&start=$start" : '';
206         loggedinorreturn();
207         //redirect(append_sid($root_path . "login.php?returnto=" . rawurlencode("phpbb2.$phpEx?page=viewtopic&$redirect")));
208     }
209
210     $message = ( !$is_auth['auth_view'] ) ? $lang['topic_post_not_exist'] : sprintf($lang['sorry_auth_read'], $is_auth['auth_read_type']);
211
212     trigger_error($message);
213     return;
214 }
215 //</span>
216 <span class="code-comment">// End auth check
217 //
218
219 $forum_name = $forum_topic_data['forum_name'];
220 $topic_title = $forum_topic_data['topic_title'];
221 $topic_id = intval($forum_topic_data['topic_id']);
222 $topic_time = $forum_topic_data['topic_time'];</span>
223 <span class="code-lang">
224 if ($post_id)
225 {
226     $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($config['posts_per_page'])) * intval($config['posts_per_page']);
227 }
228
229 //</span>
230 <span class="code-comment">// Getting current category info
231 //
232
233 $sql = "SELECT f.*, c.cat_title, f2.forum_id AS p_forum_id, f2.forum_name AS p_forum_name</span>
234 <span class="code-lang">        FROM " . FORUMS_TABLE . " f
235         LEFT JOIN " . FORUMS_TABLE . " f2 ON ( f.forum_parent = f2.forum_id ),
236         " . FORUM_CATEGORIES_TABLE . " c
237         WHERE f.forum_id = $forum_id AND f.cat_id = c.cat_id";
238 $result = $db->sql_query($sql, 31536000);
239
240 $forum_row = $db->sql_fetchrow($result);
241 $cat_id = $forum_row['cat_id'];
242 $cat_title = $forum_row['cat_title'];
243
244 // www.phpBB-SEO.com SEO TOOLKIT BEGIN
245 $seo->set_url($cat_title, $cat_id, $seo->seo_static['forum_cat']);
246 //$seo->set_parent($forum_id, $seo->seo_static['forum'], $cat_id, $seo->seo_static['forum_cat']);
247
248 if ( !empty($forum_row['p_forum_id']) ) {</span>
249 <span class="code-keyword">    $seo->set_parent($forum_row['p_forum_id'], $seo->seo_static['forum'], $cat_id, $seo->seo_static['forum_cat']);
250     $seo->set_url($forum_row['p_forum_name'], $forum_row['p_forum_id'], $seo->seo_static['forum']);
251     $seo->set_parent($forum_id, $seo->seo_static['forum'], $forum_row['p_forum_id'], $seo->seo_static['forum']);
252 }
253 else {
254     $seo->set_parent($forum_id, $seo->seo_static['forum'], $cat_id, $seo->seo_static['forum_cat']);
255 }
256 $seo->set_url($forum_row['forum_name'], $forum_id, $seo->seo_static['forum']);
257
258 $seo->set_parent($topic_id, $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']);
259 $seo->set_url($topic_title, $topic_id, $seo->seo_static['topic']);</span>
260 <span class="code-lang">
261 if ( isset($_POST[POST_FORUM_URL]) ) {
262     redirect(append_sid($root_path . 'phpbb2.php?page=viewforum&f=' . $forum_id));
263 }
264 // www.phpBB-SEO.com SEO TOOLKIT END</span>
265 <span class="code-comment">
266
267 //
268 // Is user watching this thread?
269 //
270 if( $userdata['session_logged_in'] )</span>
271 <span class="code-keyword">{
272     $can_watch_topic = true;
273
274     $sql = "SELECT checkcomm_view_status, checkcomm_notify_status
275         FROM " . COMMENTS_NOTIFY_TABLE . "
276         WHERE checkcomm_for_id = $topic_id
277         AND checkcomm_type = " . TYPE_FORUM_POST . "
278             AND checkcomm_userid = " . $userdata['uid'];
279     $result = $db->sql_query($sql);
280
281     if ( $row = $db->sql_fetchrow($result) )
282     {
283         if ( $unwatch )
284         {
285             if ( $unwatch == 'topic' )
286             {
287                 $is_watching_topic = 0;
288
289                 $sql_priority = ($db_type == "mysql") ? "LOW_PRIORITY" : '';
290                 $sql = "DELETE $sql_priority FROM " . COMMENTS_NOTIFY_TABLE . "
291                     WHERE checkcomm_for_id = $topic_id
292                     AND checkcomm_type = " . TYPE_FORUM_POST . "
293                         AND checkcomm_userid = " . $userdata['uid'];
294                 $result = $db->sql_query($sql);
295             }
296
297             meta_refresh(3, append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id&start=$start"));
298
299             //$message = $lang['no_longer_watching'] . '<br /><br />' . sprintf($lang['click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
300             $message = $lang['no_longer_watching'] . '<br /><br />' . sprintf($lang['click_return_topic'], '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
301             trigger_error($message);
302             return;
303         }
304         else
305         {
306             $is_watching_topic = true;
307
308             $sql_priority = ($db_type == "mysql") ? "LOW_PRIORITY" : '';
309
310             if ( $row['checkcomm_view_status'] == VIEW_STATUS_NOT_VIEWED )
311             {
312                 $sql = "UPDATE $sql_priority " . COMMENTS_NOTIFY_TABLE . "
313                     SET checkcomm_view_status = " . VIEW_STATUS_VIEWED . ", checkcomm_notify_status = " . NOTIFY_STATUS_UN_NOTIFIED . "
314                     WHERE checkcomm_for_id = $topic_id
315                     AND checkcomm_type = " . TYPE_FORUM_POST . "
316                     AND checkcomm_userid = " . $userdata['uid'];
317                 $result = $db->sql_query($sql);
318             }
319             elseif ( $row['checkcomm_view_status'] == VIEW_STATUS_VIEWED && $row['checkcomm_notify_status'] == NOTIFY_STATUS_NOTIFIED ) {
320                 $sql = "UPDATE $sql_priority " . COMMENTS_NOTIFY_TABLE . "
321                     SET checkcomm_notify_status = " . NOTIFY_STATUS_UN_NOTIFIED . "
322                     WHERE checkcomm_for_id = $topic_id
323                     AND checkcomm_type = " . TYPE_FORUM_POST . "
324                     AND checkcomm_userid = " . $userdata['uid'];
325             }
326
327             $result = $db->sql_query($sql);
328         }
329     }
330     else
331     {
332         if ( $watch )
333         {
334             if ( $watch == 'topic' )
335             {
336                 $is_watching_topic = TRUE;
337
338                 $sql_priority = ($db_type == "mysql") ? "LOW_PRIORITY" : '';
339                 $sql = "INSERT $sql_priority INTO " . COMMENTS_NOTIFY_TABLE . " (checkcomm_userid, checkcomm_for_id, checkcomm_type, checkcomm_view_status, checkcomm_notify_status, checkcomm_last_comment_id)
340                     VALUES (" . $userdata['uid'] . ", $topic_id, " . TYPE_FORUM_POST . ", " . VIEW_STATUS_VIEWED . ", " . NOTIFY_STATUS_NOTIFIED . ", " . $forum_topic_data['topic_last_post_id'] . ")";
341                 $result = $db->sql_query($sql);
342             }
343
344             meta_refresh(3, append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id&start=$start"));
345
346             //$message = $lang['you_are_watching'] . '<br /><br />' . sprintf($lang['click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
347             $message = $lang['you_are_watching'] . '<br /><br />' . sprintf($lang['click_return_topic'], '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
348             trigger_error($message);
349             return;
350         }
351         else
352         {
353             $is_watching_topic = 0;
354         }
355     }
356 }
357 else
358 {
359     if ( $unwatch )
360     {
361         if ( $unwatch == 'topic' )
362         {
363             //FIXME:
364             //redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic"));
365             redirect(append_sid($root_path . "phpbb2.php?page=login&amp;redirect=" . rawurlencode("index.php?option=com_forum&amp;page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic")));
366         }
367     }
368     else
369     {
370         $can_watch_topic = 0;
371         $is_watching_topic = 0;
372     }
373 }
374
375 //</span>
376 <span class="code-comment">// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
377 // then get it's value, find the number of topics with dates newer than it (to properly
378 // handle pagination) and alter the main query
379 //
380 $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
381 $previous_days_text = array($lang['all_posts'], $lang['1_day'], $lang['7_days'], $lang['2_weeks'], $lang['1_month'], $lang['3_months'], $lang['6_months'], $lang['1_year']);</span>
382 <span class="code-lang">
383 if( $postdays )
384 {
385     $min_post_time = time() - ( $postdays * 86400);
386
387     $sql = "SELECT COUNT(p.post_id) AS num_posts
388         FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
389         WHERE t.topic_id = $topic_id
390             AND p.topic_id = t.topic_id
391             AND p.post_time >= $min_post_time";
392     $result = $db->sql_query($sql);
393
394     $total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0;
395
396     $limit_posts_time = "AND p.post_time >= $min_post_time ";
397
398     if ( $postdays )
399     {
400         $start = 0;
401     }
402 }
403 else
404 {
405     $total_replies = intval($forum_topic_data['topic_replies']) + 1;
406
407     $limit_posts_time = '';
408     $postdays = 0;
409 }
410
411 $select_post_days = '<select name="postdays">';</span>
412 <span class="code-lang">for($i = 0; $i < count($previous_days); $i++)
413 {
414     $selected = ($postdays == $previous_days[$i]) ? ' selected="selected"' : '';
415     $select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
416 }
417 $select_post_days .= '</select>';
418
419 // Get topic tracking info
420 if (!isset($topic_tracking_info))</span>
421 <span class="code-keyword">{
422     $topic_tracking_info = array();
423
424     // Get topic tracking info
425     if ($config['load_db_lastread'] && $userdata['session_logged_in'])
426     {
427         $tmp_topic_data = array($topic_id => $topic_data);
428         $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));
429         unset($tmp_topic_data);
430     }
431     else if ($config['load_anon_lastread'] || $userdata['session_logged_in'])
432     {
433         $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
434     }
435 }
436 //</span>
437 <span class="code-comment">// Decide how to order the post display
438 //
439
440 $post_time_order = ( $postorder == "asc" ? "asc" : "desc" );
441
442 $select_post_order = '<select name="postorder">';</span>
443 <span class="code-lang">if ( $post_time_order == 'asc' )
444 {
445     $select_post_order .= '<option value="asc" selected="selected">' . $lang['oldest_first'] . '</option><option value="desc">' . $lang['newest_first'] . '</option>';
446 }
447 else
448 {
449     $select_post_order .= '<option value="asc">' . $lang['oldest_first'] . '</option><option value="desc" selected="selected">' . $lang['newest_first'] . '</option>';
450 }
451 $select_post_order .= '</select>';
452
453 //</span>
454 <span class="code-comment">// Go ahead and pull all data for this topic
455 //
456 if ( $finish_rel ) {</span>
457 <span class="code-keyword">    $limit = ( ( $finish_rel - $start ) > 0 ? $finish_rel - $start : -$finish_rel );
458 }
459 else {
460     $limit = $config['posts_per_page'];
461 }
462
463 $sql_array = array();
464 $sql_array['SELECT'] = 'u.name AS username, u.uid, u.user_posts, u.email, u.user_session_time, u.user_lastvisit, p.*,  pt.post_text, pt.post_subject, u.gender, u.birthday, u.warneduntil, u.parked, u.donor, u.added AS user_regdate, u.uploaded, u.downloaded, u.avatar AS user_avatar, u.icq AS user_icq, u.msn, u.aim AS user_aim, u.yahoo AS user_yim, u.skype AS user_skype, u.title AS user_rank, u.privacy, u.class AS user_class, u.enabled, u.user_sig, u.user_reputation_level, u.user_rank_id, u.class, u.name_append, u.user_reputation';
465 $sql_array['FROM'] = array(</span>
466 <span class="code-lang">    POSTS_TABLE    => 'p',
467     USERS_TABLE    => 'u',
468     POSTS_TEXT_TABLE    => 'pt',
469 );
470 $sql_array['WHERE'] = "p.topic_id = $topic_id AND pt.post_id = p.post_id AND u.uid = p.poster_id $limit_posts_time";
471 $sql_array['ORDER_BY'] = 'p.post_time ' . $post_time_order;
472
473
474 $sql = $db->sql_build_query('SELECT', $sql_array);
475
476 //topic sticky or announce, let's do first post sticky and we view not a first page
477 $sql_array = array();</span>
478 <span class="code-lang">if ( $forum_topic_data['topic_first_post_sticky'] && $start ) {
479     $sql_array['SELECT'] = 'u.name AS username, u.uid, u.user_posts, u.email, u.user_session_time, u.user_lastvisit, p.*,  pt.post_text, pt.post_subject, u.gender, u.birthday, u.warneduntil, u.parked, u.donor, u.added AS user_regdate, u.uploaded, u.downloaded, u.avatar AS user_avatar, u.icq AS user_icq, u.msn, u.aim AS user_aim, u.yahoo AS user_yim, u.skype AS user_skype, u.title AS user_rank, u.privacy, u.class AS user_class, u.enabled, u.user_sig, u.user_reputation_level, u.user_rank_id, u.class, u.name_append, u.user_reputation';
480     $sql_array['FROM'] = array(
481         POSTS_TABLE    => 'p',
482         USERS_TABLE    => 'u',
483         POSTS_TEXT_TABLE    => 'pt',
484     );
485     $sql_array['WHERE'] = "p.post_id = " . $forum_topic_data['topic_first_post_id'] . " AND pt.post_id = p.post_id AND u.uid = p.poster_id";
486
487     //$limit -= 1;
488 }
489
490 $result = $db->sql_query_limit($sql, $limit, $start);
491
492 $postrow = array();
493 $posts_ary = array();
494 $simpaty_ary = array();</span>
495 <span class="code-lang">if ( $row = $db->sql_fetchrow($result) )
496 {
497     do
498     {
499         $postrow[] = $row;
500         $posts_ary[] = $row['post_id'];
501     }
502     while ($row = $db->sql_fetchrow($result));
503     $db->sql_freeresult($result);
504
505     if ( sizeof($sql_array) ) {
506         $sql = $db->sql_build_query('SELECT', $sql_array);
507         $result = $db->sql_query($sql);
508         $first_post_data = array($db->sql_fetchrow($result));
509         $postrow = array_merge($first_post_data, $postrow);
510     }
511
512     if ( sizeof($posts_ary) ) {
513         $sql = 'SELECT s.simpaty, u.name, u.uid, s.simpid
514                 FROM ' . SIMPATY_TABLE . ' s, ' . USERS_TABLE . ' u
515                 WHERE s.fromuserid = u.uid
516                 AND simpid IN (' . implode(', ', $posts_ary) . ')
517                 AND type = ' . SIMPATY_FORUM_POST;
518         $result = $db->sql_query($sql);
519
520         while ( $row = $db->sql_fetchrow($result) ) {
521             $simpaty_ary[$row['simpid']][] = $row;
522         }
523     }
524
525     $total_posts = sizeof($postrow);
526 }
527 else
528 {
529    require($root_path . 'include/functions_admin.'.$phpEx);
530    sync('topic', $topic_id);
531
532    trigger_error($lang['no_posts_topic']);
533    return;
534 }
535
536 $resync = FALSE;</span>
537 <span class="code-lang">if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow))
538 {
539    $resync = TRUE;
540 }
541 elseif ($start + $config['posts_per_page'] > $forum_topic_data['topic_replies'])
542 {
543    $row_id = intval($forum_topic_data['topic_replies']) % intval($config['posts_per_page']);
544    if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + sizeof($postrow) < $forum_topic_data['topic_replies'])
545    {
546       $resync = TRUE;
547    }
548 }
549 elseif (count($postrow) < $config['posts_per_page'])
550 {
551    $resync = TRUE;
552 }
553
554 if ($resync)
555 {
556    require($root_path . 'include/functions_admin.'.$phpEx);
557    sync('topic', $topic_id);
558
559    $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id);
560    $row = $db->sql_fetchrow($result);
561    $total_replies = $row['total'];
562 }
563
564 $topic_title = censor_text($topic_title);
565
566 //</span>
567 <span class="code-comment">// Was a highlight request part of the URI?
568 //
569 $highlight_match = $highlight = '';</span>
570 <span class="code-lang">if ( $highlight )
571 {
572     // Split words and phrases
573     $words = explode(' ', $highlight);
574
575     for($i = 0; $i < sizeof($words); $i++)
576     {
577         if (trim($words[$i]) != '')
578         {
579             $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
580         }
581     }
582     unset($words);
583
584     $highlight = urlencode($_GET['highlight']);
585     $highlight_match = phpbb_rtrim($highlight_match, "\\");
586 }
587
588 //</span>
589 <span class="code-comment">// Post, reply and other URL generation for
590 // templating vars
591 //
592 $printer_topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;printertopic=1&amp;" . POST_TOPIC_URL . "=$topic_id&amp;start=$start");
593 //$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id");
594 $new_topic_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id");
595 //$reply_topic_url = append_sid("posting.$phpEx?mode=reply&amp;" . POST_TOPIC_URL . "=$topic_id");
596 $reply_topic_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=reply&amp;" . POST_TOPIC_URL . "=$topic_id");
597 //$view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
598 $view_forum_url = append_sid($root_path . "phpbb2.php?page=viewforum&amp;" . POST_FORUM_URL . "=$forum_id");
599 //$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=previous");
600 $view_prev_topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=previous");
601 //$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=next");
602 $view_next_topic_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;view=next");
603 $view_cat_url = append_sid($root_path . "phpbb2.php?" . POST_CAT_URL . "=$cat_id");
604
605 $reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
606 $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['topic_locked'] : $lang['reply_to_topic'];
607 $post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
608 $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['forum_locked'] : $lang['post_new_topic'];
609 $printer_img = $images['printer'];
610 $printer_alt = $lang['printertopic_button'];
611
612 //</span>
613 <span class="code-comment">// Set a cookie for this topic
614 //
615 /*if ( $userdata['session_logged_in'] )
616 {
617     $tracking_topics = ( isset($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
618     $tracking_forums = ( isset($_COOKIE[$config['cookie_name'] . '_f']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
619
620     if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
621     {
622         $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
623     }
624     else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
625     {
626         $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
627     }
628     else
629     {
630         $topic_last_read = $userdata['user_lastvisit'];
631     }
632
633     if ( sizeof($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
634     {
635         asort($tracking_topics);
636         unset($tracking_topics[key($tracking_topics)]);
637     }
638
639     $tracking_topics[$topic_id] = time();
640
641     set_cookie('t', serialize($tracking_topics));
642 }*/
643 //make_jumpbox('viewforum.'.$phpEx, $forum_id);
644 //make_jumpbox('phpbb2.php?page=viewforum', $forum_id);
645 // Begin Simple Subforums MOD
646
647 //
648 // Load templates
649 //
650 if( isset($_GET['printertopic']) ) {</span>
651 <span class="code-keyword">    $template->set_filenames(array(
652         'body' => 'forum/printertopic_body.tpl')
653     );
654 }
655 else {
656     $template->set_filenames(array(
657         'body' => 'forum/viewtopic_body.tpl')
658     );
659 }
660 $all_forums = array();
661 make_jumpbox_ref('phpbb2.php?page=viewforum', $forum_id, $all_forums);</span>
662 <span class="code-lang">
663 if( $forum_row['forum_parent'] )
664 {
665     $template->assign_vars(array(
666         'PARENT_FORUM'            => 1,
667         'U_VIEW_PARENT_FORUM'    => append_sid($root_path . "phpbb2.$phpEx?page=viewforum&amp;" . POST_FORUM_URL .'=' . $forum_row['p_forum_id']),
668         'PARENT_FORUM_NAME'        => $forum_row['p_forum_name'],
669     ));
670 }
671 // End Simple Subforums MOD</span>
672 <span class="code-comment">
673 //
674 // Output page header
675 //
676 $page_title = $topic_title;</span>
677 <span class="code-lang">if(isset($_GET['printertopic']))
678 {
679     include($root_path . 'phpBB2/includes/page_header_printer.'.$phpEx);
680 } else
681 {
682     stdhead($lang['forums'] . ( isset($page_title) ? ' :: ' . $page_title : '' ), false);
683 }
684
685 //</span>
686 <span class="code-comment">// User authorisation levels output
687 //
688 $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['rules_post_can'] : $lang['rules_post_cannot'] ) . '<br />';
689 $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['rules_reply_can'] : $lang['rules_reply_cannot'] ) . '<br />';
690 $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['rules_edit_can'] : $lang['rules_edit_cannot'] ) . '<br />';
691 $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['rules_delete_can'] : $lang['rules_delete_cannot'] ) . '<br />';
692 $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['rules_vote_can'] : $lang['rules_vote_cannot'] ) . '<br />';
693
694 $topic_mod = '';</span>
695 <span class="code-lang">
696 if ( $is_auth['auth_mod'] )
697 {
698     //$s_auth_can .= sprintf($lang['rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
699     $s_auth_can .= sprintf($lang['rules_moderate'], "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
700
701     //$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['delete_topic'] . '" title="' . $lang['delete_topic'] . '" border="0" /></a>&nbsp;';
702     $topic_mod .= "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['delete_topic'] . '" title="' . $lang['delete_topic'] . '" border="0" /></a>&nbsp;';
703
704     //$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['move_topic'] . '" title="' . $lang['move_topic'] . '" border="0" /></a>&nbsp;';
705     $topic_mod .= "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['move_topic'] . '" title="' . $lang['move_topic'] . '" border="0" /></a>&nbsp;';
706
707     //$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['lock_topic'] . '" title="' . $lang['lock_topic'] . '" border="0" /></a>&nbsp;' : "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['unlock_topic'] . '" title="' . $lang['unlock_topic'] . '" border="0" /></a>&nbsp;';
708     $topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['lock_topic'] . '" title="' . $lang['lock_topic'] . '" border="0" /></a>&nbsp;' : "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['unlock_topic'] . '" title="' . $lang['unlock_topic'] . '" border="0" /></a>&nbsp;';
709
710     //$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['split_topic'] . '" title="' . $lang['split_topic'] . '" border="0" /></a>&nbsp;';
711     $topic_mod .= "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['split_topic'] . '" title="' . $lang['split_topic'] . '" border="0" /></a>&nbsp;';
712
713     // [begin] Mass Delete Posts (From Topic) Mod
714     $topic_mod .= "<a href=\"" . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete_posts&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['delete_posts'] . '" alt="' . $lang['delete_posts'] . '" title="' . $lang['delete_posts'] . '" border="0" /></a>&nbsp;';
715
716     $template->assign_block_vars('switch_topic_mod', array());
717     // [end] Mass Delete Posts (From Topic) Mod
718 }
719
720 //</span>
721 <span class="code-comment">// Topic watch information
722 //
723 $s_watching_topic = $s_watching_topic_img = '';</span>
724 <span class="code-lang">
725 if ( $can_watch_topic )
726 {
727     if ( $is_watching_topic )
728     {
729         //$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['stop_watching_topic'] . '</a>';
730         $s_watching_topic = "<a href=\"" . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['stop_watching_topic'] . '</a>';
731         //$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['stop_watching_topic'] . '" title="' . $lang['stop_watching_topic'] . '" border="0"></a>' : '';
732         $s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"" . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['stop_watching_topic'] . '" title="' . $lang['stop_watching_topic'] . '" border="0" /></a>' : '';
733     }
734     else
735     {
736         //$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['start_watching_topic'] . '</a>';
737         $s_watching_topic = "<a href=\"" . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['start_watching_topic'] . '</a>';
738         //$s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['start_watching_topic'] . '" title="' . $lang['start_watching_topic'] . '" border="0"></a>' : '';
739         $s_watching_topic_img = ( isset($images['topic_watch']) ) ? "<a href=\"" . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_watch'] . '" alt="' . $lang['start_watching_topic'] . '" title="' . $lang['start_watching_topic'] . '" border="0" /></a>' : '';
740     }
741 }
742
743 //</span>
744 <span class="code-comment">// If we've got a hightlight set pass it on to pagination,
745 // I get annoyed when I lose my highlight after the first page.
746 //
747 $pagination_printertopic = ( isset($_GET['printertopic']) ? 'printertopic=1&amp;' : '' );
748 $pagination_highlight = ( $highlight != '' ? "highlight=$highlight&amp;" : '' );
749 $pagination_ppp = $config['posts_per_page'];</span>
750 <span class="code-lang">
751 if( $finish_rel ) {
752     $pagination_ppp = ( $finish_rel < 0 ? -$finish_rel : $finish_rel - $start );
753     $pagination_finish_rel = "finish_rel=". -$pagination_ppp. "&amp";
754 }
755 else {
756     $pagination_finish_rel = '';
757 }
758
759 $pagination = generate_pagination($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;" . $pagination_printertopic . "postdays=$postdays&amp;postorder=$postorder&amp;" . $pagination_highlight . $pagination_finish_rel, $total_replies, $pagination_ppp, $start);</span>
760 <span class="code-lang">if($pagination != '' && $pagination_printertopic) {
761     $pagination .= " &nbsp;<a href=\"" . append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;" . $pagination_printertopic . "postdays=$postdays&amp;postorder=$postorder&amp;". $pagination_highlight. "start=0&amp;finish_rel=-10000") . "\" title=\"" . $lang['printertopic_cancel_pagination_desc'] . "\">" . $lang['printertopic_all_pages'] . "</a>";
762 }
763 //</span>
764 <span class="code-comment">// Output the data to the template (for MAIL.RU Keyboard)
765 //
766 $template->assign_vars(array(</span>
767 <span class="code-lang">    'S_VISIBILITY_RULES' => 'position:absolute;visibility:hidden;',
768     'S_VISIBILITY_KEYB' => 'position:absolute;visibility:hidden;',
769     'S_VISIBILITY_OFF' => '',
770     'S_SEARCH_IN_TOPIC_ACTION' => append_sid($root_path . 'phpbb2.php?page=search&amp;mode=results') )
771 );
772
773 //</span>
774 <span class="code-comment">// Send vars to template
775 //
776 $template->assign_vars(array(</span>
777 <span class="code-lang">    'START_REL' => ($start + 1),
778     'FINISH_REL' => ( $finish_rel ? intval($finish_rel) : ($config['posts_per_page'] - $start)),
779     'FORUM_ID' => $forum_id,
780     'FORUM_NAME' => $forum_name,
781     'CAT_TITLE' => $cat_title,
782     'TOPIC_ID' => $topic_id,
783     'TOPIC_TITLE' => $topic_title,
784     'PAGINATION' => $pagination,
785     'PAGE_NUMBER' => sprintf($lang['page_of'], ( floor( $start / $pagination_ppp ) + 1 ), ceil( $total_replies / $pagination_ppp )),
786
787
788     'POST_IMG' => $post_img,
789     'REPLY_IMG' => $reply_img,
790     'PRINTER_IMG' => $printer_img,
791
792     'L_POST_NEW_TOPIC' => $post_alt,
793     'L_POST_REPLY_TOPIC' => $reply_alt,
794     'L_PRINTER_TOPIC' => $printer_alt,
795
796     'L_BBCODE_CLOSE_TAGS' => $lang['close_tags'],
797     'L_SEARCH_THIS_TOPIC' => $lang['search_in_topic'],
798
799     'S_TOPIC_LINK' => POST_TOPIC_URL,
800     'S_SELECT_POST_DAYS' => $select_post_days,
801     'S_SELECT_POST_ORDER' => $select_post_order,
802     //'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&amp;start=$start"),
803     'S_POST_DAYS_ACTION' => append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . '=' . $topic_id . "&amp;start=$start"),
804     'S_AUTH_LIST' => $s_auth_can,
805     'S_TOPIC_ADMIN' => $topic_mod,
806     'S_WATCH_TOPIC' => $s_watching_topic,
807     'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
808     // [begin] Mass Delete Posts (From Topic) Mod
809     'S_DELETE_POSTS_ACTION' => append_sid($root_path . "phpbb2.php?page=modcp&amp;" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete_posts&amp;sid=" . $userdata['session_id']),
810     // [end] Mass Delete Posts (From Topic) Mod
811
812     //'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start&amp;postdays=$postdays&amp;postorder=$postorder&amp;highlight=$highlight"),
813     'U_VIEW_TOPIC' => append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;start=$start&amp;postdays=$postdays&amp;postorder=$postorder&amp;highlight=$highlight"),
814     'U_VIEW_FORUM' => $view_forum_url,
815     'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
816     'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
817     'U_VIEW_CAT' => $view_cat_url,
818     'U_POST_NEW_TOPIC' => $new_topic_url,
819     'U_PRINTER_TOPIC' => $printer_topic_url,
820
821     // Topic Search MOD
822     'U_TOPIC_SEARCH' => append_sid($root_path . 'phpbb2.php?page=search&amp;mode=results'),
823     // End Topic Search MOD
824     'U_POST_REPLY_TOPIC' => $reply_topic_url)
825 );
826 //</span>
827 <span class="code-comment">// Does this topic contain a poll?
828 //
829 if ( !empty($forum_topic_data['topic_vote']) )</span>
830 <span class="code-keyword">{
831     $s_hidden_fields = '';
832
833     $sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
834         FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
835         WHERE vd.topic_id = $topic_id
836             AND vr.vote_id = vd.vote_id
837         ORDER BY vr.vote_option_id ASC";
838     $result = $db->sql_query($sql);
839
840     if ( $vote_info = $db->sql_fetchrowset($result) )
841     {
842         $db->sql_freeresult($result);
843         $vote_options = count($vote_info);
844
845         $vote_id = $vote_info[0]['vote_id'];
846         $vote_title = $vote_info[0]['vote_text'];
847
848         $sql = "SELECT vote_id
849             FROM " . VOTE_USERS_TABLE . "
850             WHERE vote_id = $vote_id
851                 AND vote_user_id = " . intval($userdata['uid']);
852         $result = $db->sql_query($sql);
853
854         $user_voted = ( $row = $db->sql_fetchrow($result) ) ? true : 0;
855         $db->sql_freeresult($result);
856
857         if ( $vote )
858         {
859             $view_result = ( $vote == 'viewresult' ) ? true : 0;
860         }
861         else
862         {
863             $view_result = 0;
864         }
865
866         $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
867
868         if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
869         {
870             $template->set_filenames(array(
871                 'pollbox' => 'forum/viewtopic_poll_result.tpl')
872             );
873
874             $vote_results_sum = 0;
875
876             for($i = 0; $i < $vote_options; $i++)
877             {
878                 $vote_results_sum += $vote_info[$i]['vote_result'];
879             }
880
881             $vote_graphic = 0;
882             $vote_graphic_max = count($images['voting_graphic']);
883
884             for($i = 0; $i < $vote_options; $i++)
885             {
886                 $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
887                 $vote_graphic_length = round($vote_percent * $config['vote_graphic_length']);
888
889                 $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
890                 $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
891
892                 $vote_info[$i]['vote_option_text'] = censor_text($vote_info[$i]['vote_option_text']);
893
894                 $template->assign_block_vars("poll_option", array(
895                     'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
896                     'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
897                     'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
898
899                     'POLL_OPTION_IMG' => $vote_graphic_img,
900                     'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
901                 );
902             }
903
904             $template->assign_vars(array(
905                 'L_TOTAL_VOTES' => $lang['total_votes'],
906                 'TOTAL_VOTES' => $vote_results_sum)
907             );
908
909         }
910         else
911         {
912             $template->set_filenames(array(
913                 'pollbox' => 'forum/viewtopic_poll_ballot.tpl')
914             );
915
916             for($i = 0; $i < $vote_options; $i++)
917             {
918                     $vote_info[$i]['vote_option_text'] = censor_text($vote_info[$i]['vote_option_text']);
919
920                 $template->assign_block_vars("poll_option", array(
921                     'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
922                     'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
923                 );
924             }
925
926             $template->assign_vars(array(
927                 'L_SUBMIT_VOTE' => $lang['submit_vote'],
928                 'L_VIEW_RESULTS' => $lang['view_results'],
929
930                 //'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$postdays&amp;postorder=$postorder&amp;vote=viewresult"))
931                 'U_VIEW_RESULTS' => append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$postdays&amp;postorder=$postorder&amp;vote=viewresult"))
932             );
933
934             $s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
935         }
936
937         $vote_title = censor_text($vote_title);
938
939         $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
940
941         $template->assign_vars(array(
942             'POLL_QUESTION' => $vote_title,
943
944             'S_HIDDEN_FIELDS' => $s_hidden_fields,
945             //'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&amp;" . POST_TOPIC_URL . "=$topic_id"))
946             'S_POLL_ACTION' => append_sid($root_path . "phpbb2.php?page=posting&amp;mode=vote&amp;" . POST_TOPIC_URL . "=$topic_id"))
947         );
948
949         $tpl = $template->assign_display('pollbox');
950
951         $template->assign_vars(array(
952             'POLL_DISPLAY' => $tpl)
953         );
954     }
955 }
956
957 //</span>
958 <span class="code-comment">// Update the topic view counter
959 //
960 $sql = "UPDATE " . TOPICS_TABLE . "</span>
961 <span class="code-lang">    SET topic_views = topic_views + 1
962     WHERE topic_id = $topic_id";
963 $db->sql_query($sql);
964 // [begin] Extended Quick Reply Form mod
965 if ( ($is_auth['auth_reply'] && !(($forum_topic_data['forum_status'] == FORUM_LOCKED) || ($forum_topic_data['topic_status'] == TOPIC_LOCKED)) ) || ($userdata['user_level'] == ADMIN) )</span>
966 <span class="code-keyword">{
967     $quick_reply = true;
968 }
969 else
970 {
971     $quick_reply = false;
972 }
973 // [end] Extended Quick Reply Form mod
974
975 if ( !isset($ranks) ) {</span>
976 <span class="code-keyword">    $ranks = $cache->obtain_ranks();
977 }
978
979 //</span>
980 <span class="code-comment">// Okay, let's do the loop, yeah come on baby let's do the loop
981 // and it goes like this ...
982 //
983
984 $posts = array();
985 $max_post_time = 0;</span>
986 <span class="code-lang">
987 for($i = 0; $i < $total_posts; $i++)
988 {
989     $poster_id = $postrow[$i]['uid'];
990     $poster = ( $poster_id == ANONYMOUS ) ? ( !empty($postrow[$i]['post_username']) ? $postrow[$i]['post_username'] : $lang['guest'] ) : $postrow[$i]['username'];
991
992     $post_date = create_date($postrow[$i]['post_created']);
993
994     $poster_posts = ( $poster_id != ANONYMOUS ) ? $lang['posts'] . ': ' . $postrow[$i]['user_posts'] : '';
995
996     $poster_joined = ( $poster_id != ANONYMOUS ) ? $lang['joined'] . ': ' . create_date($postrow[$i]['user_regdate']) : '';
997
998     $poster_avatar_prefix = ( ( strpos($postrow[$i]['user_avatar'], 'user_avatar_' . $poster_id) === false && strpos($postrow[$i]['user_avatar'], '/') !== false ) || !$postrow[$i]['user_avatar'] ? '' : generate_base_url() . '/' . $config['avatar_path'] . '/' );
999
1000     $poster_avatar = ( $userdata['avatars'] && $postrow[$i]['user_avatar'] ? '<img src="' . $poster_avatar_prefix . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' :'' );
1001
1002     $post_unread = (isset($topic_tracking_info[$topic_id]) && $postrow[$i]['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
1003
1004     if ($postrow[$i]['post_time'] > $max_post_time)
1005     {
1006         $max_post_time = $postrow[$i]['post_time'];
1007     }
1008
1009     //
1010     // Define the little post icon
1011     //
1012     //if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
1013     if ( $post_unread )
1014     {
1015         $mini_post_img = $images['icon_minipost_new'];
1016         $mini_post_alt = $lang['new_post'];
1017     }
1018     else
1019     {
1020         $mini_post_img = $images['icon_minipost'];
1021         $mini_post_alt = $lang['post'];
1022     }
1023
1024     //$mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];
1025     $mini_post_url = append_sid($root_path . "phpbb2.php?page=viewtopic&amp;" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];
1026     $temp_url = '';
1027
1028     if ( $poster_id != ANONYMOUS )
1029     {
1030             // www.phpBB-SEO.com SEO TOOLKIT START
1031             $seo->set_user_url($postrow[$i]['username'], $postrow[$i]['uid']);
1032             // www.phpBB-SEO.com SEO TOOLKIT END
1033
1034         $temp_url = append_sid($root_path . "userdetails.php?id=" . $postrow[$i]['uid']);
1035         $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['read_profile'] . '" title="' . $lang['read_profile'] . '" border="0" /></a>';
1036         $profile = '<a href="' . $temp_url . '">' . $lang['read_profile'] . '</a>';
1037
1038         //$temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id");
1039         $temp_url = append_sid("message.php?action=send&amp;receiver=" . $postrow[$i]['uid']);
1040         $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['send_private_message'] . '" title="' . $lang['send_private_message'] . '" border="0" /></a>';
1041         $pm = '<a href="' . $temp_url . '">' . $lang['send_private_message'] . '</a>';
1042
1043         if ( $is_auth['auth_mod'] )
1044         {
1045             //$email_uri = ( $config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
1046             $email_uri = 'mailto:' . $postrow[$i]['email'];
1047
1048             $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['send_email'] . '" title="' . $lang['send_email'] . '" border="0" /></a>';
1049             $email = '<a href="' . $email_uri . '">' . $lang['send_email'] . '</a>';
1050         }
1051         else
1052         {
1053             $email_img = '';
1054             $email = '';
1055         }
1056
1057         if ( !empty($postrow[$i]['user_icq']) )
1058         {
1059             $icq_status_img = '<a href="http://www.icq.com/people/about_me.php?uin=' . $postrow[$i]['user_icq'] . '" target="_blank"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[$i]['user_icq'] . '&amp;img=5" width="18" height="18" border="0" /></a>';
1060             $icq_img = '<a href="http://www.icq.com/people/about_me.php?uin=' . $postrow[$i]['user_icq'] . '" target="_blank"><img src="' . $images['icon_icq'] . '" alt="' . $lang['icq'] . '" title="' . $lang['icq'] . '" border="0" /></a>';
1061             $icq '<a href="http://www.icq.com/people/about_me.php?uin=' . $postrow[$i]['user_icq'] . '" target="_blank">' . $lang['icq'] . '</a>';
1062         }
1063         else
1064         {
1065             $icq_status_img = '';
1066             $icq_img = '';
1067             $icq = '';
1068         }
1069
1070         //$aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['aim'] . '" title="' . $lang['aim'] . '" border="0" /></a>' : '';
1071         $aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['aim'] . '" title="' . $lang['aim'] . '" border="0" /></a>' : '';
1072         $aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['aim'] . '</a>' : '';
1073
1074         $skype_img = ( $postrow[$i]['user_skype'] ) ? '<a href="skype:' . $postrow[$i]['user_skype'] . '?call"><img src="' . $images['icon_skype'] . '" alt="' . $lang['skype'] . '" title="' . $lang['skype'] . '" border="0" /></a>' : '';
1075         $skype = ( $postrow[$i]['user_skype'] ) ? '<a href="skype:' . $postrow[$i]['user_skype'] . '?call">' . $lang['skype'] . '</a>' : '';
1076
1077         //$temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
1078         $temp_url = append_sid($root_path . "userdetails.php?id=" . $postrow[$i]['uid']);
1079         //$msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['msnm'] . '" title="' . $lang['msnm'] . '" border="0" /></a>' : '';
1080         $msn_img = ( $postrow[$i]['msn'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['msnm'] . '" title="' . $lang['msnm'] . '" border="0" /></a>' : '';
1081         $msn = ( $postrow[$i]['msn'] ) ? '<a href="' . $temp_url . '">' . $lang['msnm'] . '</a>' : '';
1082
1083         //$yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['yim'] . '" title="' . $lang['yim'] . '" border="0" /></a>' : '';
1084         $yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['yim'] . '" title="' . $lang['yim'] . '" border="0" /></a>' : '';
1085         $yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg">' . $lang['yim'] . '</a>' : '';
1086                 // Start add - Online/Offline/Hidden Mod
1087         if ( $postrow[$i]['user_session_time'] >= ( time() - $config['online_time']) )
1088         {
1089             $online_status_img = '<a href="' . append_sid($root_path . "index.php?viewonline=1") . '"><img src="' . $images['icon_online'] . '" alt="' . sprintf($lang['is_online'], $poster) . '" title="' . sprintf($lang['is_online'], $poster) . '" /></a>&nbsp;';
1090             $online_status = '<br />' . $lang['online_status'] . ': <strong><a href="' . append_sid("index.php?viewonline=1") . '" title="' . sprintf($lang['is_online'], $poster) . '">' . $lang['online'] . '</a></strong>';
1091         }
1092         else
1093         {
1094             $online_status_img = '<img src="' . $images['icon_offline'] . '" alt="' . sprintf($lang['is_offline'], $poster) . '" title="' . sprintf($lang['is_offline'], $poster) . '" />&nbsp;';
1095             $online_status = '<br />' . $lang['online_status'] . ': <span title="' . sprintf($lang['is_offline'], $poster) . '"><strong>' . $lang['offline'] . '</strong></span>';
1096         }
1097         // End add - Online/Offline/Hidden Mod
1098
1099         if ($userdata['uid'] != $poster_id && $userdata['session_logged_in'] && $forum_topic_data['topic_status'] == TOPIC_UNLOCKED) {
1100                      $u_respect = append_sid('simpaty.php?action=add&amp;simpaty=1&amp;targetid=' . $poster_id . '&amp;type=1&amp;simpid=' . $postrow[$i]['post_id']);
1101                      $u_antirespect = append_sid('simpaty.php?action=add&amp;simpaty=0&amp;targetid=' . $poster_id . '&amp;type=1&amp;simpid=' . $postrow[$i]['post_id']);
1102
1103         }
1104         else {
1105             $u_respect = '';
1106             $u_antirespect = '';
1107         }
1108
1109         $age = get_age($postrow[$i]['birthday']);
1110         $age = $lang['age']  . ': '. $age;
1111
1112         if ( !$postrow[$i]['gender'] ) {
1113             $gender = '<img src="' . $images['male'] . '" alt="" />';
1114         }
1115         else {
1116             $gender = '<img src="' . $images['female'] . '" alt="" />';
1117         }
1118         $gender = $lang['gender'] . ': ' . $gender;
1119
1120              if ( ( $postrow[$i]['user_class'] == UC_VIP || $postrow[$i]['privacy'] <> PRIVACY_LEVEL_LOW ) && ( $userdata['class'] < UC_MODERATOR && $userdata['uid'] != $postrow[$i]['uid'] ) ) {
1121             $ratio = '---';
1122         }
1123         else {
1124             $ratio = get_ratio($postrow[$i]['uploaded'], $postrow[$i]['downloaded']);
1125             $ratio = '<span style="color:' . get_ratio_color($ratio) . ';">' . $ratio . '</span>';
1126         }
1127         $ratio = $lang['ratio'] . ': ' . $ratio;
1128
1129         $poster_rank = ( $postrow[$i]['user_rank'] ? $postrow[$i]['user_rank'] . '<br />' : '' );
1130         $poster_rank .= ( isset($ranks[$postrow[$i]['user_rank_id']]['rank_name']) ? $ranks[$postrow[$i]['user_rank_id']]['rank_name'] : '' );
1131
1132     }
1133     else
1134     {
1135         $profile_img = '';
1136         $profile = '';
1137         $pm_img = '';
1138         $pm = '';
1139         $email_img = '';
1140         $email = '';
1141         $www_img = '';
1142         $www = '';
1143         $icq_status_img = '';
1144         $icq_img = '';
1145         $icq = '';
1146         $aim_img = '';
1147         $aim = '';
1148         $skype_img = '';
1149         $skype = '';
1150         $msn_img = '';
1151         $msn = '';
1152         $yim_img = '';
1153         $yim = '';
1154         $u_respect = '';
1155         $u_antirespect = '';
1156         // Start add - Online/Offline/Hidden Mod
1157         $online_status_img = '';
1158         $online_status = '';
1159         $age = '';
1160         $gender = '';
1161         $poster_respects = '';
1162         $ratio = '';
1163         $poster_rank = '';
1164         // End add - Online/Offline/Hidden Mod
1165     }
1166
1167     //$temp_url = append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
1168     $temp_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
1169     $quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['reply_with_quote'] . '" title="' . $lang['reply_with_quote'] . '" border="0" /></a>';
1170     $quote = '<a href="' . $temp_url . '">' . $lang['reply_with_quote'] . '</a>';
1171
1172     //FIXME:
1173     $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&amp;showresults=posts");
1174     $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . sprintf($lang['search_user_posts'], $postrow[$i]['username']) . '" title="' . sprintf($lang['search_user_posts'], $postrow[$i]['username']) . '" border="0" /></a>';
1175     $search = '<a href="' . $temp_url . '">' . sprintf($lang['search_user_posts'], $postrow[$i]['username']) . '</a>';
1176
1177     if ( ( $userdata['uid'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
1178     {
1179         //$temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
1180         $temp_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
1181         $edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['edit_delete_post'] . '" title="' . $lang['edit_delete_post'] . '" border="0" /></a>';
1182         $edit = '<a href="' . $temp_url . '">' . $lang['edit_delete_post'] . '</a>';
1183     }
1184     else
1185     {
1186         $edit_img = '';
1187         $edit = '';
1188     }
1189
1190     if ( $is_auth['auth_mod'] )
1191     {
1192         //$temp_url = "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id'];
1193         $temp_url = append_sid($root_path . "phpbb2.php?page=modcp&amp;mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id']);
1194         $ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['view_ip'] . '" title="' . $lang['view_ip'] . '" border="0" /></a>';
1195         $ip = '<a href="' . $temp_url . '">' . $lang['view_ip'] . '</a>';
1196
1197         //$temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
1198         $temp_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id']);
1199         $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['delete_post'] . '" title="' . $lang['delete_post'] . '" border="0" /></a>';
1200         $delpost = '<a href="' . $temp_url . '">' . $lang['delete_post'] . '</a>';
1201         // [begin] Mass Delete Posts (From Topic) Mod
1202         if ($postrow[$i]['post_id'] != $forum_topic_data['topic_first_post_id'])
1203         {
1204             $s_delete_post_checkbox = '<input type="checkbox" name="post_id_list[]" value="' . $postrow[$i]['post_id'] . '" />';
1205         }
1206         // [end] Mass Delete Posts (From Topic) Mod
1207     }
1208     else
1209     {
1210         $ip_img = '';
1211         $ip = '';
1212
1213         if ( $userdata['uid'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
1214         {
1215             //$temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
1216             $temp_url = append_sid($root_path . "phpbb2.php?page=posting&amp;mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id']);
1217             $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['delete_post'] . '" title="' . $lang['delete_post'] . '" border="0" /></a>';
1218             $delpost = '<a href="' . $temp_url . '">' . $lang['delete_post'] . '</a>';
1219         }
1220         else
1221         {
1222             $delpost_img = '';
1223             $delpost = '';
1224         }
1225         // [begin] Mass Delete Posts (From Topic) Mod
1226         $s_delete_post_checkbox = '';
1227         // [end] Mass Delete Posts (From Topic) Mod
1228     }
1229
1230     $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
1231
1232     $message = $postrow[$i]['post_text'];
1233     $user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
1234     //
1235     // Allow signatures? No (0) -- Yes (1) -- Yes, no images (2)
1236     //
1237     $user_sig = ( $config['allow_sig'] == 2 ) ? preg_replace('#((\r)+?(\n)+?)*(\[url(.*)\])?\[img.*?]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img.*?](\[/url\])?#i', '', $user_sig) : ( ($config['allow_sig'] == 1) ? $user_sig : '' );
1238     $user_icons = get_user_icons($postrow[$i]);
1239
1240     //
1241     // Note! The order used for parsing the message _is_ important, moving things around could break any
1242     // output
1243     //
1244
1245     //
1246     // If the board has HTML off but the post has HTML
1247     // on then we process it, else leave it alone
1248     //
1249     if ( !$config['allow_html'] )
1250     {
1251         if ( $user_sig != '' )
1252         {
1253             $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
1254         }
1255
1256         if ( $postrow[$i]['enable_html'] )
1257         {
1258             $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
1259         }
1260     }
1261
1262     //
1263     // Highlight active words (primarily for search)
1264     //
1265     if ($highlight_match)
1266     {
1267         // This has been back-ported from 3.0 CVS
1268         $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color:#'.$theme['fontcolor3'].'">\1</b>', $message);
1269     }
1270
1271     //
1272     // Replace naughty words
1273     //
1274     $post_subject = censor_text($post_subject);
1275
1276     if ($user_sig != '')
1277     {
1278             $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#s', "\\0", '>' . $user_sig . '<'), 1, -1));
1279
1280         $bb_code->parse($user_sig);
1281         $user_sig = $bb_code->get_html();
1282         $user_sig = censor_text($user_sig);
1283     }
1284
1285     $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#s', "\\0", '>' . $message . '<'), 1, -1));
1286
1287     if ( $postrow[$i]['enable_bbcode'] ) {
1288         $bb_code->parse($message);
1289         $message = $bb_code->get_html();
1290         $message = censor_text($message);
1291     }
1292
1293     //
1294     // Replace newlines (we use this rather than nl2br because
1295     // till recently it wasn't XHTML compliant)
1296     //
1297     if ( $user_sig != '' )
1298     {
1299         $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
1300     }
1301
1302     $message = str_replace("\n", "\n<br />\n", $message);
1303
1304     //
1305     // Editing information
1306     //
1307     if ( $postrow[$i]['post_edit_count'] )
1308     {
1309         $l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['edited_time_total'] : $lang['edited_times_total'];
1310
1311         $l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, create_date($postrow[$i]['post_edit_time']), $postrow[$i]['post_edit_count']);
1312     }
1313     else
1314     {
1315         $l_edited_by = '';
1316     }
1317
1318
1319     // [begin] Extended Quick Reply Form mod
1320     $quote_link = '';
1321
1322     if ( $quick_reply )
1323     {
1324         $poster = addslashes($poster);
1325     }
1326     // [end] Extended Quick Reply Form mod
1327
1328
1329     //
1330     // Again this will be handled by the templating
1331     // code at some point
1332     //
1333     $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1334     $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1335
1336     if ( $postrow[$i]['post_reputation'] > 0 ) {
1337         $current_reputation_show = '+' . $postrow[$i]['post_reputation'];
1338     }
1339     else {
1340         $current_reputation_show = $postrow[$i]['post_reputation'];
1341     }
1342
1343      $userList_ary = ( isset($simpaty_ary[$postrow[$i]['post_id']]) ? $simpaty_ary[$postrow[$i]['post_id']] : array() );
1344
1345     $userslist = '';
1346     foreach ( $userList_ary AS $_null => $users ) {
1347         $userslist .= ( $userslist ? ', ' : '' );
1348
1349         // www.phpBB-SEO.com SEO TOOLKIT START
1350         $seo->set_user_url($users['name'], $users['uid']);
1351         // www.phpBB-SEO.com SEO TOOLKIT END
1352
1353         $userslist .= '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $users['uid']) . '"><span class="' . ( $users['simpaty'] ? 'usergoodResp' : 'userbadResp' ) . '">' . $users['name'] . '</span></a>';
1354     }
1355
1356
1357     $template->assign_block_vars('postrow', array(
1358         'ROW_COLOR' => '#' . $row_color,
1359         'ROW_CLASS' => $row_class,
1360         'POSTER_NAME' => $poster,
1361         'POSTER_NAME_PARSED' => parse_username($postrow[$i], true, array('href'=>'javascript:;', 'onclick'=>'ins(\'' . $poster . '\');')),
1362         'POSTER_ICONS' => $user_icons,
1363         // [begin] Extended Quick Reply Form mod
1364         'QUOTE_LINK' => $quote_link,
1365         // [end] Extended Quick Reply Form mod
1366         'POSTER_RANK' => $poster_rank,
1367         'POSTER_JOINED' => $poster_joined,
1368         'POSTER_POSTS' => $poster_posts,
1369         'POSTER_AVATAR' => $poster_avatar,
1370         // Start add - Online/Offline/Hidden Mod
1371         'POSTER_ONLINE_STATUS_IMG' => $online_status_img,
1372         'POSTER_ONLINE_STATUS' => $online_status,
1373         // End add - Online/Offline/Hidden Mod
1374         'POST_DATE' => $post_date,
1375         'POST_NUMBER' => ($i + $start + 1),
1376         'POST_SUBJECT' => $post_subject,
1377                 'POSTER_RATIO' => $ratio,
1378                 'MESSAGE' => $message,
1379         'SIGNATURE' => $user_sig,
1380         'EDITED_MESSAGE' => $l_edited_by,
1381         //'SMILIES_STATUS' => $smilies_status,
1382
1383         'MINI_POST_IMG' => $mini_post_img,
1384         'PROFILE_IMG' => $profile_img,
1385         'PROFILE' => $profile,
1386         'SEARCH_IMG' => $search_img,
1387         'SEARCH' => $search,
1388         'PM_IMG' => $pm_img,
1389         'PM' => $pm,
1390         'EMAIL_IMG' => $email_img,
1391         'EMAIL' => $email,
1392         'ICQ_STATUS_IMG' => $icq_status_img,
1393         'ICQ_IMG' => $icq_img,
1394         'ICQ' => $icq,
1395         'AIM_IMG' => $aim_img,
1396         'AIM' => $aim,
1397         'SKYPE_IMG' => $skype_img,
1398         'SKYPE' => $skype,
1399         'MSN_IMG' => $msn_img,
1400         'MSN' => $msn,
1401         'YIM_IMG' => $yim_img,
1402         'YIM' => $yim,
1403         'EDIT_IMG' => $edit_img,
1404         'EDIT' => $edit,
1405         'QUOTE_IMG' => $quote_img,
1406         'QUOTE' => $quote,
1407         'IP_IMG' => $ip_img,
1408         'IP' => $ip,
1409         'DELETE_IMG' => $delpost_img,
1410         'DELETE' => $delpost,
1411         // [begin] Mass Delete Posts (From Topic) Mod
1412         'S_DELETE_POST_CHECKBOX' => ( isset($s_delete_post_checkbox) ? $s_delete_post_checkbox : '' ),
1413         // [end] Mass Delete Posts (From Topic) Mod
1414         'POSTER_AGE' => $age,
1415         'POSTER_GENDER' => $gender,
1416         'U_RESPECT' => $u_respect,
1417         'U_ANTIRESPECT' => $u_antirespect,
1418
1419         'L_MINI_POST_ALT' => $mini_post_alt,
1420
1421         'U_MINI_POST' => $mini_post_url,
1422         'U_POST_ID' => $postrow[$i]['post_id'],
1423
1424         'SIMPATY_TYPE' => SIMPATY_FORUM_POST,
1425         'CURRENT_REPUTATION' => $postrow[$i]['post_reputation'],
1426         'CURRENT_REPUTATION_SHOW' => $current_reputation_show,
1427
1428         'USER_REPUTATION_LEVEL' => $postrow[$i]['user_reputation_level'],
1429
1430         'USERLIST' => $userslist
1431     ));
1432 }
1433
1434 // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
1435 if (isset($topic_tracking_info[$topic_id]) && $forum_topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])</span>
1436 <span class="code-keyword">{
1437     markread('topic', $forum_id, $topic_id, $max_post_time);
1438
1439     // Update forum info
1440     $all_marked_read = update_forum_tracking_info($forum_id, $forum_topic_data['forum_last_post_time'], false, false);
1441 }
1442 else
1443 {
1444     $all_marked_read = true;
1445 }
1446
1447 // [begin] Extended Quick Reply Form mod
1448 include($root_path . 'phpBB2/quick_reply.'.$phpEx);
1449 // [end] Extended Quick Reply Form mod
1450
1451 if( isset($_GET['printertopic']) ) {</span>
1452 <span class="code-keyword">    $template->display('body');
1453 }
1454 ?>
Note: See TracBrowser for help on using the browser.