Dragonfly CMS logo Server sponsored and hosted by
DedicatedNOW
CVS logo  
.:: Home :: Dev. Resources :: Forums ::.
Dragonfly CMS CVS Repository
 Location: / cvs / html / modules / Forums / viewtopic.php
This is a web interface to the Dragonfly CMS CVS tree. You can browse the file hierarchy by picking directories. If you pick a file, you will see the revision history for that file.
Selecting a revision number will show that revision of the file. There are links at each revision to display diffs, annotate and download.
Note: Info about CVS and our commits can be found at our CVS Info Forum
File name: html/modules/Forums/viewtopic.php
Revision : 9.37.2.3 (6 years 4 months 3 days 2 hours 8 minutes 28 seconds ago) by djmaze
Changed : +3 -3 lines
Comment: Replaced all occurences of the deprecated ereg* functions for the faster str* and preg* functions


# Author Rev Line
1 djmaze 1.1 <?php
2 djmaze 8.2 /***************************************************************************
3 djmaze 9.5 * index.php
4 djmaze 9.5 * -------------------
5 trevor 9.6 * begin : Saturday, Feb 13, 2001
6 trevor 9.6 * copyright : (C) 2001 The phpBB Group
7 trevor 9.6 * email : support@phpbb.com
8 djmaze 8.2 *
9 djmaze 1.30 Last modification notes:
10 akamu 8.3 $Source: /cvs/html/modules/Forums/viewtopic.php,v $
11 djmaze 9.37.2.3 $Revision: 9.37.2.2 $
12 djmaze 9.37.2.2 $Author: djmaze $
13 djmaze 9.37.2.3 $Date: 2007/12/16 22:17:40 $
14 djmaze 8.2 *
15 djmaze 8.2 ***************************************************************************/
16 djmaze 8.2 /***************************************************************************
17 djmaze 8.2 *
18 trevor 9.6 * This program is free software; you can redistribute it and/or modify
19 trevor 9.6 * it under the terms of the GNU General Public License as published by
20 trevor 9.6 * the Free Software Foundation; either version 2 of the License, or
21 trevor 9.6 * (at your option) any later version.
22 djmaze 8.2 *
23 djmaze 8.2 ***************************************************************************/
24 trevor 8.11 if (!defined('CPG_NUKE')) { exit; }
25 akamu 1.18 require_once('modules/'.$module_name.'/nukebb.php');
26 djmaze 9.17 require_once('includes/nbbcode.php');
27 djmaze 1.1  
28 djmaze 1.1 //
29 djmaze 1.1 // Start initial var setup
30 djmaze 1.1 //
31 djmaze 1.1 $topic_id = $post_id = 0;
32 djmaze 1.1 if ( isset($_GET[POST_TOPIC_URL]) ) {
33 djmaze 9.5 $topic_id = intval($_GET[POST_TOPIC_URL]);
34 djmaze 1.1 } else if ( isset($_GET['topic']) ) {
35 djmaze 9.5 $topic_id = intval($_GET['topic']);
36 djmaze 1.1 }
37 djmaze 1.1  
38 djmaze 1.1 if ( isset($_GET[POST_POST_URL])) {
39 djmaze 9.5 $post_id = intval($_GET[POST_POST_URL]);
40 djmaze 1.1 }
41 akamu 1.39 //
42 akamu 1.39 // Start session management
43 akamu 1.39 //
44 djmaze 8.16 $userdata = session_pagestart();
45 akamu 1.39 init_userprefs($userdata);
46 akamu 1.39 //
47 akamu 1.39 // End session management
48 akamu 1.39 //
49 akamu 1.39  
50 djmaze 1.30 if ( !isset($topic_id) && !isset($post_id) ) {
51 djmaze 9.5 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
52 djmaze 1.30 }
53 djmaze 1.1  
54 djmaze 1.1 $start = ( isset($_GET['start']) ) ? intval($_GET['start']) : 0;
55 djmaze 1.1  
56 djmaze 1.1 if (isset($_GET['printertopic'])) {
57 djmaze 9.5 $start = ( isset($_GET['start_rel']) && isset($_GET['printertopic']) ) ? intval($_GET['start_rel']) - 1 : $start;
58 djmaze 9.5 // $finish when positive indicates last message; when negative it indicates range; can't be 0
59 djmaze 9.5 if(isset($_GET['finish_rel'])) {
60 djmaze 9.5 $finish = intval($_GET['finish_rel']);
61 djmaze 9.5 }
62 djmaze 9.5 if($finish >= 0 && ($finish - $start) <=0) {
63 djmaze 9.5 unset($finish);
64 djmaze 9.5 }
65 djmaze 1.1 }
66 djmaze 1.1  
67 djmaze 1.1 //
68 djmaze 1.1 // Find topic id if user requested a newer or older topic
69 djmaze 1.1 //
70 djmaze 1.1 if ( isset($_GET['view']) && empty($_GET[POST_POST_URL]) ) {
71 djmaze 9.5 if ( $_GET['view'] == 'newest' ) {
72 djmaze 9.5 if (is_user()) {
73 djmaze 9.25 $sql = "SELECT p.post_id FROM ".POSTS_TABLE." p
74 djmaze 9.5 WHERE p.topic_id = $topic_id
75 djmaze 9.25 AND p.post_time >= ".$userinfo['user_lastvisit']."
76 djmaze 9.5 ORDER BY p.post_time ASC LIMIT 0,1";
77 djmaze 9.25 $result = $db->sql_query($sql);
78 djmaze 9.37.2.2 if ( !($row = $db->sql_fetchrow($result, SQL_ASSOC)) ) {
79 djmaze 9.5 message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
80 djmaze 9.5 }
81 djmaze 9.5 $post_id = $row['post_id'];
82 djmaze 9.25 url_redirect(getlink("&file=viewtopic&".POST_POST_URL."=$post_id")."#$post_id");
83 djmaze 9.5 }
84 djmaze 9.25 url_redirect(getlink("&file=viewtopic&".POST_TOPIC_URL."=$topic_id"));
85 djmaze 9.5 } else if ( $_GET['view'] == 'next' || $_GET['view'] == 'previous' ) {
86 djmaze 9.5 $sql_condition = ( $_GET['view'] == 'next' ) ? '>' : '<';
87 djmaze 9.5 $sql_ordering = ( $_GET['view'] == 'next' ) ? 'ASC' : 'DESC';
88 phoenix 9.32 $sql = "SELECT t.topic_id FROM ".TOPICS_TABLE." t, ".TOPICS_TABLE." t2
89 djmaze 9.5 WHERE t2.topic_id = $topic_id
90 djmaze 9.5 AND t.forum_id = t2.forum_id
91 djmaze 9.5 AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
92 djmaze 9.5 ORDER BY t.topic_last_post_id $sql_ordering LIMIT 0,1";
93 djmaze 9.25 $result = $db->sql_query($sql);
94 djmaze 9.37.2.2 if ( $row = $db->sql_fetchrow($result, SQL_ASSOC) ) {
95 djmaze 9.5 $topic_id = intval($row['topic_id']);
96 djmaze 9.37.2.2 $db->sql_freeresult($result);
97 djmaze 9.5 } else {
98 djmaze 9.5 $message = ( $_GET['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
99 djmaze 9.5 message_die(GENERAL_MESSAGE, $message);
100 djmaze 9.5 }
101 djmaze 9.5 }
102 djmaze 1.1 }
103 djmaze 1.1  
104 djmaze 1.1 //
105 djmaze 1.1 // This rather complex gaggle of code handles querying for topics but
106 djmaze 1.1 // also allows for direct linking to a post (and the calculation of which
107 djmaze 1.1 // page the post is on and the correct display of viewtopic)
108 djmaze 1.1 //
109 djmaze 9.25 $join_sql_table = ( empty($post_id) ) ? '' : ", ".POSTS_TABLE." p, ".POSTS_TABLE." p2 ";
110 djmaze 1.1 $join_sql = ( empty($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
111 djmaze 1.1 $count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
112 djmaze 9.30 $order_sql = ( empty($post_id) ) ? '' : "GROUP BY p.post_id, 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,
113 djmaze 9.30 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.auth_download, f.forum_desc,
114 djmaze 9.30 t.topic_attachment, c.cat_title ORDER BY p.post_id ASC";
115 djmaze 1.1  
116 djmaze 9.25 $sql = "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, f.forum_name, f.forum_desc, 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.auth_download, t.topic_attachment, c.cat_title ".$count_sql."
117 phoenix 9.32 FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f, ".CATEGORIES_TABLE." c ". $join_sql_table."
118 djmaze 9.5 WHERE $join_sql
119 djmaze 9.5 AND f.forum_id = t.forum_id
120 djmaze 9.5 AND f.cat_id = c.cat_id
121 djmaze 9.5 $order_sql";
122 djmaze 9.25 $result = $db->sql_query($sql);
123 djmaze 9.37.2.2 if ( !($forum_topic_data = $db->sql_fetchrow($result, SQL_ASSOC)) ) {
124 djmaze 9.5 message_die(GENERAL_MESSAGE, $lang['Topic_post_not_exist']);
125 djmaze 1.1 }
126 djmaze 9.37.2.2 $db->sql_freeresult($result);
127 djmaze 1.1  
128 djmaze 1.1 $forum_id = intval($forum_topic_data['forum_id']);
129 djmaze 1.1  
130 akamu 1.39  
131 djmaze 1.1  
132 djmaze 1.1 //
133 djmaze 1.1 // Start auth check
134 djmaze 1.1 //
135 djmaze 1.1 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
136 djmaze 9.10 if (!$is_auth['auth_view'] || !$is_auth['auth_read']) {
137 djmaze 9.10 if (!is_user()) { url_redirect(getlink('Your_Account'), true); }
138 djmaze 9.5 $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
139 djmaze 9.5 message_die(GENERAL_MESSAGE, $message);
140 djmaze 1.1 }
141 djmaze 1.1 //
142 djmaze 1.1 // End auth check
143 djmaze 1.1 //
144 djmaze 1.1  
145 djmaze 1.1 $forum_name = $forum_topic_data['forum_name'];
146 akamu 8.17 $forum_desc = $forum_topic_data['forum_desc'];
147 djmaze 1.1 $topic_title = $forum_topic_data['topic_title'];
148 djmaze 1.1 $topic_id = intval($forum_topic_data['topic_id']);
149 djmaze 1.1 $topic_time = $forum_topic_data['topic_time'];
150 djmaze 1.1  
151 djmaze 1.1 if ( !empty($post_id) ) {
152 djmaze 9.5 $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
153 djmaze 1.1 }
154 djmaze 1.1  
155 djmaze 1.1 //
156 djmaze 1.1 // Is user watching this thread?
157 djmaze 1.1 //
158 djmaze 1.1 $is_watching_topic = $can_watch_topic = 0;
159 djmaze 9.10 if (is_user()) {
160 djmaze 9.5 $can_watch_topic = TRUE;
161 djmaze 9.5 $sql = "SELECT notify_status
162 djmaze 9.25 FROM ".TOPICS_WATCH_TABLE."
163 djmaze 9.5 WHERE topic_id = $topic_id
164 djmaze 9.25 AND user_id = ".$userdata['user_id'];
165 djmaze 9.25 $result = $db->sql_query($sql);
166 djmaze 9.5  
167 djmaze 9.5 if ( $row = $db->sql_fetchrow($result) ) {
168 djmaze 9.5 if ( isset($_GET['unwatch']) ) {
169 djmaze 9.5 if ( $_GET['unwatch'] == 'topic' ) {
170 djmaze 9.5 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
171 djmaze 9.25 $db->sql_query("DELETE $sql_priority FROM ".TOPICS_WATCH_TABLE."
172 djmaze 9.5 WHERE topic_id = $topic_id
173 djmaze 9.25 AND user_id = ".$userdata['user_id']);
174 djmaze 9.5 }
175 djmaze 9.25 url_refresh(getlink("&file=viewtopic&".POST_TOPIC_URL."=$topic_id&start=$start"));
176 djmaze 9.25 $message = $lang['No_longer_watching'].'<br /><br />'.sprintf($lang['Click_return_topic'], '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;start=$start").'">', '</a>');
177 djmaze 9.5 message_die(GENERAL_MESSAGE, $message);
178 djmaze 9.5 } else {
179 djmaze 9.5 $is_watching_topic = TRUE;
180 djmaze 9.5 if ( $row['notify_status'] ) {
181 djmaze 9.5 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
182 djmaze 9.25 $sql = "UPDATE $sql_priority ".TOPICS_WATCH_TABLE."
183 djmaze 9.5 SET notify_status = 0
184 djmaze 9.5 WHERE topic_id = $topic_id
185 djmaze 9.25 AND user_id = ".$userdata['user_id'];
186 djmaze 9.25 $result = $db->sql_query($sql);
187 djmaze 9.5 }
188 djmaze 9.5 }
189 djmaze 9.5 } else {
190 djmaze 9.5 if ( isset($_GET['watch']) ) {
191 djmaze 9.5 if ( $_GET['watch'] == 'topic' ) {
192 djmaze 9.5 $is_watching_topic = TRUE;
193 djmaze 9.5 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
194 djmaze 9.25 $sql = "INSERT $sql_priority INTO ".TOPICS_WATCH_TABLE." (user_id, topic_id, notify_status)
195 djmaze 9.25 VALUES (".$userdata['user_id'].", $topic_id, 0)";
196 djmaze 9.25 $result = $db->sql_query($sql);
197 djmaze 9.5 }
198 djmaze 9.25 url_refresh(getlink("&file=viewtopic&".POST_TOPIC_URL."=$topic_id&start=$start"));
199 djmaze 9.25 $message = $lang['You_are_watching'].'<br /><br />'.sprintf($lang['Click_return_topic'], '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;start=$start").'">', '</a>');
200 djmaze 9.5 message_die(GENERAL_MESSAGE, $message);
201 djmaze 9.5 }
202 djmaze 9.5 }
203 djmaze 1.1 } else {
204 djmaze 9.5 if ( isset($_GET['unwatch']) ) {
205 djmaze 9.5 if ( $_GET['unwatch'] == 'topic' ) {
206 djmaze 9.5 url_redirect(getlink('Your_Account'), true);
207 djmaze 9.5 }
208 djmaze 9.5 }
209 djmaze 1.1 }
210 djmaze 1.1  
211 djmaze 1.1 //
212 djmaze 1.1 // Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
213 djmaze 1.1 // then get it's value, find the number of topics with dates newer than it (to properly
214 djmaze 1.1 // handle pagination) and alter the main query
215 djmaze 1.1 //
216 djmaze 1.1 $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
217 djmaze 1.1 $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']);
218 djmaze 1.1  
219 djmaze 1.1 if( !empty($_POST['postdays']) || !empty($_GET['postdays']) ) {
220 djmaze 9.5 $post_days = ( !empty($_POST['postdays']) ) ? intval($_POST['postdays']) : intval($_GET['postdays']);
221 djmaze 9.37.2.1 $min_post_time = time() - (intval($post_days) * 86400);
222 djmaze 9.5 $sql = "SELECT COUNT(p.post_id) AS num_posts
223 phoenix 9.32 FROM ".TOPICS_TABLE." t, ".POSTS_TABLE." p
224 djmaze 9.5 WHERE t.topic_id = $topic_id
225 djmaze 9.5 AND p.topic_id = t.topic_id
226 djmaze 9.5 AND p.post_time >= $min_post_time";
227 djmaze 9.25 $result = $db->sql_query($sql);
228 djmaze 9.37.2.2 $total_replies = ( $row = $db->sql_fetchrow($result, SQL_NUM) ) ? intval($row[0]) : 0;
229 djmaze 9.37.2.2 $db->sql_freeresult($result);
230 djmaze 9.5 $limit_posts_time = "AND p.post_time >= $min_post_time ";
231 djmaze 9.5 if ( !empty($_POST['postdays'])) {
232 djmaze 9.5 $start = 0;
233 djmaze 9.5 }
234 djmaze 1.1 } else {
235 djmaze 9.5 $total_replies = intval($forum_topic_data['topic_replies']) + 1;
236 djmaze 9.5 $limit_posts_time = '';
237 djmaze 9.5 $post_days = 0;
238 djmaze 1.1 }
239 djmaze 1.1  
240 djmaze 1.1 $select_post_days = '<select name="postdays">';
241 djmaze 1.1 for($i = 0; $i < count($previous_days); $i++) {
242 djmaze 9.5 $selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
243 djmaze 9.25 $select_post_days .= '<option value="'.$previous_days[$i].'"'.$selected.'>'.$previous_days_text[$i].'</option>';
244 djmaze 1.1 }
245 djmaze 1.1 $select_post_days .= '</select>';
246 djmaze 1.1  
247 djmaze 1.1 //
248 djmaze 1.1 // Decide how to order the post display
249 djmaze 1.1 //
250 djmaze 1.1 if ( !empty($_POST['postorder']) || !empty($_GET['postorder']) ) {
251 djmaze 9.5 $post_order = (!empty($_POST['postorder'])) ? htmlprepare($_POST['postorder']) : htmlprepare($_GET['postorder']);
252 djmaze 9.5 $post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
253 djmaze 1.1 } else {
254 djmaze 9.5 $post_order = 'asc';
255 djmaze 9.5 $post_time_order = 'ASC';
256 djmaze 1.1 }
257 djmaze 1.1  
258 djmaze 1.1 $select_post_order = '<select name="postorder">';
259 djmaze 1.1 if ( $post_time_order == 'ASC' ) {
260 djmaze 9.25 $select_post_order .= '<option value="asc" selected="selected">'.$lang['Oldest_First'].'</option><option value="desc">'.$lang['Newest_First'].'</option>';
261 djmaze 1.1 } else {
262 djmaze 9.25 $select_post_order .= '<option value="asc">'.$lang['Oldest_First'].'</option><option value="desc" selected="selected">'.$lang['Newest_First'].'</option>';
263 djmaze 1.1 }
264 djmaze 1.1 $select_post_order .= '</select>';
265 djmaze 1.1  
266 djmaze 1.1 //
267 djmaze 1.1 // Go ahead and pull all data for this topic
268 djmaze 1.1 //
269 djmaze 1.1 /* lanzer speedup for large forums
270 djmaze 1.1 $total_pages = ceil($total_replies/$board_config['posts_per_page']);
271 djmaze 1.1 $on_page = floor($start / $board_config['posts_per_page']) + 1;
272 djmaze 1.1 if ($start > 100 && ($total_replies / 2) < $start) {
273 djmaze 9.5 $reverse = TRUE;
274 djmaze 9.5 $last_page_posts = $total_replies - ($board_config['posts_per_page'] * ($total_pages - 1));
275 djmaze 1.1 }
276 djmaze 1.1 if (isset($reverse)) {
277 djmaze 9.5 $limit_string = ($total_pages == $on_page) ? $last_page_posts : ($last_page_posts + ($total_pages - $on_page - 1) * $board_config['posts_per_page'] ).','. $board_config['posts_per_page'];
278 djmaze 9.25 $sql = "SELECT p.post_id FROM ".POSTS_TABLE." p USE INDEX(topic_n_id) WHERE p.topic_id = $topic_id $limit_posts_time ORDER BY p.post_id DESC LIMIT $limit_string" ;
279 djmaze 1.1 } else {
280 djmaze 9.25 $sql = "SELECT p.post_id FROM ".POSTS_TABLE." p WHERE p.topic_id = $topic_id $limit_posts_time LIMIT $start, ".$board_config['posts_per_page'];
281 djmaze 1.1 }
282 djmaze 9.25 $result = $db->sql_query($sql);
283 djmaze 1.1 while (list($p_id) = $db->sql_fetchrow($result)) {
284 djmaze 9.5 $p_array[] = $p_id;
285 djmaze 1.1 }
286 djmaze 1.1 $post_index = implode(",",$p_array);
287 djmaze 9.26 $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, u.user_allow_viewonline, u.user_allowsmile, p.*, pt.post_text, pt.post_subject
288 djmaze 9.25 FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt
289 djmaze 1.1 WHERE p.post_id in ($post_index)
290 djmaze 9.5 AND pt.post_id = p.post_id
291 djmaze 9.5 AND u.user_id = p.poster_id
292 djmaze 1.1 ORDER BY p.post_time $post_time_order";
293 djmaze 1.1 */
294 djmaze 9.29 $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.bio, u.user_timezone, u.user_occ, u.user_interests, p.*, pt.post_text, pt.post_subject";
295 djmaze 9.29 if (isset($userinfo['server_specs'])){ $sql .= ", u.server_specs"; }
296 phoenix 9.32 $sql .=" FROM ".POSTS_TABLE." p, ".USERS_TABLE." u, ".POSTS_TEXT_TABLE." pt
297 djmaze 9.5 WHERE p.topic_id = $topic_id
298 djmaze 9.5 $limit_posts_time
299 djmaze 9.5 AND pt.post_id = p.post_id
300 djmaze 9.5 AND u.user_id = p.poster_id
301 djmaze 9.5 ORDER BY p.post_time $post_time_order
302 djmaze 9.5 LIMIT $start, ".(isset($finish)? ((($finish - $start) > 0)? ($finish - $start): -$finish): $board_config['posts_per_page']);
303 djmaze 9.25 $result = $db->sql_query($sql);
304 djmaze 1.1  
305 djmaze 1.1 $postrow = array();
306 djmaze 1.1 if ($row = $db->sql_fetchrow($result)) {
307 djmaze 9.5 do {
308 djmaze 9.5 $postrow[] = $row;
309 djmaze 9.5 }
310 djmaze 9.37.2.2 while ($row = $db->sql_fetchrow($result, SQL_ASSOC));
311 djmaze 9.5 $db->sql_freeresult($result);
312 djmaze 9.5 $total_posts = count($postrow);
313 djmaze 1.1 } else {
314 djmaze 9.5 require_once('includes/phpBB/functions_admin.php');
315 djmaze 9.5 sync('topic', $topic_id);
316 djmaze 9.5 message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
317 djmaze 1.1 }
318 djmaze 1.1  
319 djmaze 1.1 $resync = FALSE;
320 djmaze 1.1 if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow)) {
321 djmaze 9.5 $resync = TRUE;
322 djmaze 1.1 } elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies']) {
323 djmaze 9.5 $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']);
324 djmaze 9.5 $resync = ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies']);
325 djmaze 1.1 } elseif (count($postrow) < $board_config['posts_per_page']) {
326 djmaze 9.5 $resync = TRUE;
327 djmaze 1.1 }
328 djmaze 1.1  
329 djmaze 1.1 if ($resync) {
330 djmaze 9.5 require_once('includes/phpBB/functions_admin.php');
331 djmaze 9.5 sync('topic', $topic_id);
332 djmaze 9.25 $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM '.POSTS_TABLE.' WHERE topic_id = '.$topic_id);
333 djmaze 9.5 $row = $db->sql_fetchrow($result);
334 djmaze 9.5 $total_replies = $row['total'];
335 djmaze 9.37.2.2 $db->sql_freeresult($result);
336 djmaze 1.1 }
337 djmaze 1.1  
338 djmaze 9.25 $ranksrow = $db->sql_ufetchrowset("SELECT * FROM ".RANKS_TABLE." ORDER BY rank_special, rank_min",SQL_ASSOC);
339 djmaze 1.1  
340 djmaze 1.1 //
341 djmaze 1.1 // Define censored word matches
342 djmaze 1.1 //
343 djmaze 1.1 $orig_word = array();
344 djmaze 1.1 $replacement_word = array();
345 djmaze 1.1 obtain_word_list($orig_word, $replacement_word);
346 djmaze 1.1  
347 djmaze 1.1 //
348 djmaze 1.1 // Censor topic title
349 djmaze 1.1 //
350 djmaze 8.18 if (count($orig_word)) { $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); }
351 djmaze 1.1  
352 djmaze 1.1 //
353 djmaze 1.1 // Was a highlight request part of the URI?
354 djmaze 1.1 //
355 djmaze 1.1 $highlight_match = $highlight = '';
356 djmaze 1.1 if (isset($_GET['highlight'])) {
357 djmaze 9.5 // Split words and phrases
358 djmaze 9.5 $words = explode(' ', htmlprepare($_GET['highlight']));
359 djmaze 9.5 for($i = 0; $i < sizeof($words); $i++) {
360 djmaze 9.5 $words[$i] = trim($words[$i]);
361 djmaze 9.5 if (trim($words[$i]) != '') {
362 djmaze 9.25 $highlight_match .= (($highlight_match != '') ? '|' : '').str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
363 djmaze 9.5 }
364 djmaze 9.5 }
365 djmaze 9.5 unset($words);
366 djmaze 9.5 $highlight = urlencode($_GET['highlight']);
367 djmaze 1.1 }
368 djmaze 1.1  
369 djmaze 1.1 //
370 djmaze 1.1 // Post, reply and other URL generation for
371 djmaze 1.1 // templating vars
372 djmaze 1.1 //
373 djmaze 9.25 $printer_topic_url = getlink("&amp;file=viewtopic&amp;printertopic=1&amp;".POST_TOPIC_URL."=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult");
374 djmaze 9.25 $new_topic_url = getlink("&amp;file=posting&amp;mode=newtopic&amp;".POST_FORUM_URL."=$forum_id");
375 djmaze 9.25 $reply_topic_url = getlink("&amp;file=posting&amp;mode=reply&amp;".POST_TOPIC_URL."=$topic_id");
376 djmaze 9.25 $view_forum_url = getlink("&amp;file=viewforum&amp;".POST_FORUM_URL."=$forum_id");
377 djmaze 9.25 $view_prev_topic_url = getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;view=previous");
378 djmaze 9.25 $view_next_topic_url = getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;view=next");
379 djmaze 1.1  
380 djmaze 1.1 //
381 djmaze 1.1 // Mozilla navigation bar
382 djmaze 1.1 //
383 djmaze 1.1 $nav_links['prev'] = array(
384 djmaze 9.5 'url' => $view_prev_topic_url,
385 djmaze 9.5 'title' => $lang['View_previous_topic']
386 djmaze 1.1 );
387 djmaze 1.1 $nav_links['next'] = array(
388 djmaze 9.5 'url' => $view_next_topic_url,
389 djmaze 9.5 'title' => $lang['View_next_topic']
390 djmaze 1.1 );
391 djmaze 1.1 $nav_links['up'] = array(
392 djmaze 9.5 'url' => $view_forum_url,
393 djmaze 9.5 'title' => $forum_name
394 djmaze 1.1 );
395 djmaze 1.1  
396 djmaze 1.1 $reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
397 djmaze 1.1 $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
398 djmaze 1.1 $post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
399 djmaze 1.1 $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
400 djmaze 1.1 $printer_img = $images['printer'];
401 akamu 9.22 $printer_alt = _PRINTER;
402 djmaze 1.1 //
403 djmaze 1.1 // Set a cookie for this topic
404 djmaze 1.1 //
405 djmaze 9.10 if (is_user()) {
406 djmaze 9.5 $tracking_topics = isset($CPG_SESS[$module_name]['track_topics']) ? $CPG_SESS[$module_name]['track_topics'] : array();
407 djmaze 9.5 $tracking_forums = isset($CPG_SESS[$module_name]['track_forums']) ? $CPG_SESS[$module_name]['track_forums'] : array();
408 djmaze 9.5 if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) ) {
409 djmaze 9.5 $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
410 djmaze 9.5 } else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) ) {
411 djmaze 9.5 $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
412 djmaze 9.5 } else {
413 djmaze 9.5 $topic_last_read = $userdata['user_lastvisit'];
414 djmaze 9.5 }
415 djmaze 9.37.2.1 $CPG_SESS[$module_name]['track_topics'][$topic_id] = time();
416 djmaze 1.1 }
417 djmaze 1.1  
418 djmaze 1.1 //
419 djmaze 1.1 // Output page header
420 djmaze 1.1 //
421 akamu 8.13 $page_title = $forum_topic_data['cat_title'].' '._BC_DELIM.' '.$forum_name.' '._BC_DELIM.' '. $topic_title;
422 djmaze 1.1 if(isset($_GET['printertopic'])) {
423 djmaze 9.5 $gen_print_header = true;
424 djmaze 1.1 }
425 akamu 1.18 require_once('includes/phpBB/page_header.php');
426 djmaze 1.1  
427 djmaze 1.1 make_jumpbox('viewforum', $forum_id);
428 djmaze 1.1  
429 djmaze 1.1 //
430 djmaze 1.1 // User authorisation levels output
431 djmaze 1.1 //
432 djmaze 9.25 $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ).'<br />';
433 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ).'<br />';
434 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ).'<br />';
435 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ).'<br />';
436 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ).'<br />';
437 djmaze 1.1 //if (defined('BBAttach_mod')) {
438 djmaze 9.5 if (!intval($attach_config['disable_mod'])) {
439 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_attachments'] && $is_auth['auth_post'] ) ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot'] ).'<br />';
440 djmaze 9.25 $s_auth_can .= ( ( $is_auth['auth_download']) ? $lang['Rules_download_can'] : $lang['Rules_download_cannot'] ).'<br />';
441 djmaze 9.5 }
442 djmaze 1.1 $topic_mod = '';
443 djmaze 1.1  
444 djmaze 1.1 if ( $is_auth['auth_mod'] ) {
445 djmaze 9.25 $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="'.getlink("&amp;file=modcp&amp;".POST_FORUM_URL."=$forum_id").'">', '</a>');
446 phoenix 9.35 $topic_mod .= '<a href="'.getlink("&amp;file=modcp&amp;".POST_TOPIC_URL."=$topic_id&amp;mode=delete").'"><img src="'.$images['topic_mod_delete'].'" alt="'.$lang['Delete_topic'].'" title="'.$lang['Delete_topic'].'" style="border:0;" /></a>&nbsp;';
447 phoenix 9.35 $topic_mod .= '<a href="'.getlink("&amp;file=modcp&amp;".POST_TOPIC_URL."=$topic_id&amp;mode=move"). '"><img src="'.$images['topic_mod_move'].'" alt="'.$lang['Move_topic'].'" title="'.$lang['Move_topic'].'" style="border:0;" /></a>&nbsp;';
448 phoenix 9.35 $topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? '<a href="'.getlink("&amp;file=modcp&amp;".POST_TOPIC_URL."=$topic_id&amp;mode=lock").'"><img src="'.$images['topic_mod_lock'].'" alt="'.$lang['Lock_topic'].'" title="'.$lang['Lock_topic'].'" style="border:0;" /></a>&nbsp;' : '<a href="'.getlink("&amp;file=modcp&amp;".POST_TOPIC_URL."=$topic_id&amp;mode=unlock").'"><img src="'.$images['topic_mod_unlock'].'" alt="'.$lang['Unlock_topic'].'" title="'.$lang['Unlock_topic'].'" style="border:0;" /></a>&nbsp;';
449 phoenix 9.35 $topic_mod .= '<a href="'.getlink("&amp;file=modcp&amp;".POST_TOPIC_URL."=$topic_id&amp;mode=split").'"><img src="'.$images['topic_mod_split'].'" alt="'.$lang['Split_topic'].'" title="'.$lang['Split_topic'].'" style="border:0;" /></a>&nbsp;';
450 djmaze 1.1 //-- mod : merge -----------------------------------------------------------------------------------
451 phoenix 9.35 $topic_mod .= '<a href="'.getlink("&amp;file=merge&amp;".POST_TOPIC_URL.'='.$topic_id).'"><img src="'.$images['topic_mod_merge'].'" alt="'.$lang['Merge_topics'].'" title="'.$lang['Merge_topics'].'" style="border:0;" /></a>&nbsp;';
452 djmaze 1.1 //-- fin mod : merge -------------------------------------------------------------------------------
453 djmaze 1.1 }
454 djmaze 1.1  
455 djmaze 1.1 //
456 djmaze 1.1 // Topic watch information
457 djmaze 1.1 //
458 akamu 9.24 $s_watching_topic = $s_watching_topic_img ='';
459 djmaze 1.1 if ( $can_watch_topic ) {
460 djmaze 9.5 if ( $is_watching_topic ) {
461 djmaze 9.25 $s_watching_topic = '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;unwatch=topic&amp;start=$start").'">'.$lang['Stop_watching_topic'].'</a>';
462 phoenix 9.35 $s_watching_topic_img = ( isset($images['Topic_un_watch']) ) ? '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;unwatch=topic&amp;start=$start").'"><img src="'.$images['Topic_un_watch'].'" alt="'.$lang['Stop_watching_topic'].'" title="'.$lang['Stop_watching_topic'].'" style="border:0;" /></a>' : '';
463 djmaze 9.5 } else {
464 djmaze 9.25 $s_watching_topic = '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;watch=topic&amp;start=$start").'">'.$lang['Start_watching_topic'].'</a>';
465 phoenix 9.35 $s_watching_topic_img = ( isset($images['Topic_watch']) ) ? '<a href="'.getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;watch=topic&amp;start=$start").'"><img src="'.$images['Topic_watch'].'" alt="'.$lang['Stop_watching_topic'].'" title="'.$lang['Start_watching_topic'].'" style="border:0;" /></a>' : '';
466 djmaze 9.5 }
467 djmaze 1.1 }
468 djmaze 1.1  
469 djmaze 1.1 //
470 djmaze 1.1 // If we've got a hightlight set pass it on to pagination,
471 djmaze 1.1 // I get annoyed when I lose my highlight after the first page.
472 djmaze 1.1 //
473 akamu 8.7 $pagination_printertopic = $pagination_highlight = $pagination_finish_rel ='';
474 djmaze 1.1 if(isset($_GET['printertopic'])) {
475 djmaze 9.5 $pagination_printertopic = "printertopic=1&amp;";
476 djmaze 1.1 }
477 djmaze 8.18 if ($highlight != '') {
478 djmaze 9.5 $pagination_highlight = "&amp;highlight=$highlight";
479 djmaze 1.1 }
480 djmaze 1.1 $pagination_ppp = $board_config['posts_per_page'];
481 djmaze 1.1 if(isset($finish)) {
482 djmaze 9.5 $pagination_ppp = ($finish < 0)? -$finish: ($finish - $start);
483 djmaze 9.5 $pagination_finish_rel = "&amp;finish_rel=". -$pagination_ppp;
484 djmaze 1.1 }
485 djmaze 1.1  
486 djmaze 9.25 $pagination = generate_pagination("&amp;file=viewtopic&amp;". $pagination_printertopic.POST_TOPIC_URL."=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order".$pagination_highlight.$pagination_finish_rel, $total_replies, $pagination_ppp, $start);
487 djmaze 8.18 if ($pagination != '' && !empty($pagination_printertopic)) {
488 djmaze 9.25 $pagination .= ' &nbsp;<a href="'.getlink('&amp;file=viewtopic&amp;?'. $pagination_printertopic. POST_TOPIC_URL."=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order".$pagination_highlight.'&amp;start=0&amp;finish_rel=-10000').'" title=" :| |: ">:|&nbsp;|:</a>';
489 djmaze 1.1 }
490 djmaze 1.1  
491 djmaze 1.1 //
492 djmaze 1.1 // Send vars to template
493 djmaze 1.1 //
494 djmaze 1.1 $template->assign_vars(array(
495 djmaze 9.5 'START_REL' => ($start + 1),
496 djmaze 9.5 'FINISH_REL' => (isset($_GET['finish_rel'])? intval($_GET['finish_rel']) : ($board_config['posts_per_page'] - $start)),
497 djmaze 9.5 'FORUM_ID' => $forum_id,
498 djmaze 9.5 'FORUM_NAME' => $forum_name,
499 djmaze 9.5 'FORUM_DESC' => $forum_desc,
500 djmaze 9.5 'TOPIC_ID' => $topic_id,
501 djmaze 9.5 'TOPIC_TITLE' => $topic_title,
502 djmaze 9.5 'PAGINATION' => $pagination,
503 djmaze 9.5 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $pagination_ppp ) + 1 ), ceil( $total_replies / $pagination_ppp )),
504 djmaze 9.5  
505 djmaze 9.5 'POST_IMG' => $post_img,
506 djmaze 9.5 'REPLY_IMG' => $reply_img,
507 djmaze 9.5 'PRINTER_IMG' => $printer_img,
508 djmaze 9.5 'BC_DELIM' => _BC_DELIM,
509 djmaze 9.5 'L_AUTHOR' => $lang['Author'],
510 djmaze 9.5 'L_MESSAGE' => $lang['Message'],
511 djmaze 9.5 'L_POSTED' => $lang['Posted'],
512 djmaze 9.5 'L_POST_SUBJECT' => $lang['Post_subject'],
513 djmaze 9.5 'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
514 djmaze 9.5 'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
515 djmaze 9.5 'L_POST_NEW_TOPIC' => $post_alt,
516 djmaze 9.5 'L_POST_REPLY_TOPIC' => $reply_alt,
517 djmaze 9.5 'L_PRINTER_TOPIC' => $printer_alt,
518 djmaze 9.5 'L_BACK_TO_TOP_LINK' =>get_uri(),
519 djmaze 9.5 'L_BACK_TO_TOP' => $lang['Back_to_top'],
520 djmaze 9.5 'L_DISPLAY_POSTS' => $lang['Display_posts'],
521 djmaze 9.5 'L_LOCK_TOPIC' => $lang['Lock_topic'],
522 djmaze 9.5 'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
523 djmaze 9.5 'L_MOVE_TOPIC' => $lang['Move_topic'],
524 djmaze 9.5 'L_SPLIT_TOPIC' => $lang['Split_topic'],
525 djmaze 9.5 'L_DELETE_TOPIC' => $lang['Delete_topic'],
526 djmaze 9.5 'L_GOTO_PAGE' => $lang['Goto_page'],
527 djmaze 9.5 'L_GO' => $lang['Go'],
528 djmaze 9.5  
529 djmaze 9.5 'S_TOPIC_LINK' => POST_TOPIC_URL,
530 djmaze 9.5 'S_SELECT_POST_DAYS' => $select_post_days,
531 djmaze 9.5 'S_SELECT_POST_ORDER' => $select_post_order,
532 djmaze 9.25 'S_POST_DAYS_ACTION' => getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;start=$start"),
533 djmaze 9.5 'S_AUTH_LIST' => $s_auth_can,
534 djmaze 9.5 'S_TOPIC_ADMIN' => $topic_mod,
535 djmaze 9.5 'S_WATCH_TOPIC' => $s_watching_topic,
536 djmaze 9.5 'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
537 djmaze 9.5  
538 djmaze 9.25 'U_VIEW_TOPIC' => getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight"),
539 djmaze 9.5 'U_VIEW_FORUM' => $view_forum_url,
540 djmaze 9.5 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
541 djmaze 9.5 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
542 djmaze 9.5 'U_POST_NEW_TOPIC' => $new_topic_url,
543 djmaze 9.5 'U_PRINTER_TOPIC' => $printer_topic_url,
544 djmaze 9.5 'U_POST_REPLY_TOPIC' => $reply_topic_url)
545 djmaze 1.1 );
546 djmaze 1.1 //
547 djmaze 1.1 // Does this topic contain a poll?
548 djmaze 1.1 //
549 djmaze 1.1 if ( !empty($forum_topic_data['topic_vote']) )
550 djmaze 1.1 {
551 djmaze 9.5 $s_hidden_fields = '';
552 djmaze 1.1  
553 djmaze 9.5 $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
554 phoenix 9.32 FROM ".VOTE_DESC_TABLE." vd, ".VOTE_RESULTS_TABLE." vr
555 djmaze 9.5 WHERE vd.topic_id = $topic_id AND vr.vote_id = vd.vote_id
556 djmaze 9.5 ORDER BY vr.vote_option_id ASC";
557 djmaze 9.25 $vote_info = $db->sql_ufetchrowset($sql, SQL_ASSOC);
558 djmaze 9.5 if ( $vote_info ) {
559 djmaze 9.5 $vote_options = count($vote_info);
560 djmaze 9.5 $vote_id = $vote_info[0]['vote_id'];
561 djmaze 9.5 $vote_title = $vote_info[0]['vote_text'];
562 djmaze 9.5  
563 djmaze 9.25 $result = $db->sql_query("SELECT vote_id FROM ".VOTE_USERS_TABLE." WHERE vote_id = $vote_id AND vote_user_id = ".intval($userdata['user_id']));
564 djmaze 9.5 $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
565 djmaze 9.5 $db->sql_freeresult($result);
566 djmaze 9.5 if ( isset($_GET['vote']) || isset($_POST['vote']) ) {
567 djmaze 9.5 $view_result = ( ( ( isset($_GET['vote']) ) ? $_GET['vote'] : $_POST['vote'] ) == 'viewresult' ) ? TRUE : 0;
568 djmaze 9.5 } else {
569 djmaze 9.5 $view_result = 0;
570 djmaze 9.5 }
571 djmaze 9.5  
572 djmaze 9.37.2.1 $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
573 djmaze 9.5  
574 djmaze 9.5 if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
575 djmaze 9.5 {
576 djmaze 9.5 $vote_results_sum = 0;
577 djmaze 9.5  
578 djmaze 9.5 for($i = 0; $i < $vote_options; $i++) {
579 djmaze 9.5 $vote_results_sum += $vote_info[$i]['vote_result'];
580 djmaze 9.5 }
581 djmaze 9.5  
582 djmaze 9.5 $vote_graphic = 0;
583 djmaze 9.5 $vote_graphic_max = count($images['voting_graphic']);
584 djmaze 9.5  
585 djmaze 9.5 for($i = 0; $i < $vote_options; $i++) {
586 djmaze 9.5 $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
587 djmaze 9.5 $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
588 djmaze 9.5  
589 djmaze 9.5 $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
590 djmaze 9.5 $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
591 djmaze 9.5  
592 djmaze 9.5 if ( count($orig_word) ) {
593 djmaze 9.5 $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
594 djmaze 9.5 }
595 djmaze 9.5  
596 djmaze 9.5 $template->assign_block_vars('poll_option', array(
597 djmaze 9.5 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
598 djmaze 9.5 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
599 djmaze 9.5 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
600 djmaze 9.5  
601 djmaze 9.5 'POLL_OPTION_IMG' => $vote_graphic_img,
602 djmaze 9.5 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
603 djmaze 9.5 );
604 djmaze 9.5 }
605 djmaze 9.5  
606 djmaze 9.5 $template->assign_vars(array(
607 djmaze 9.5 'S_POLL_RESULTS' => true,
608 djmaze 9.5 'L_TOTAL_VOTES' => $lang['Total_votes'],
609 djmaze 9.5 'TOTAL_VOTES' => $vote_results_sum)
610 djmaze 9.5 );
611 djmaze 9.5 }
612 djmaze 9.5 else
613 djmaze 9.5 {
614 djmaze 9.5 for($i = 0; $i < $vote_options; $i++)
615 djmaze 9.5 {
616 djmaze 9.5 if ( count($orig_word) ) {
617 djmaze 9.5 $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
618 djmaze 9.5 }
619 djmaze 9.5  
620 djmaze 9.5 $template->assign_block_vars('poll_option', array(
621 djmaze 9.5 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
622 djmaze 9.5 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
623 djmaze 9.5 );
624 djmaze 9.5 }
625 djmaze 9.5  
626 djmaze 9.5 $template->assign_vars(array(
627 djmaze 9.5 'S_POLL_RESULTS' => false,
628 djmaze 9.5 'L_SUBMIT_VOTE' => $lang['Submit_vote'],
629 djmaze 9.5 'L_VIEW_RESULTS' => $lang['View_results'],
630 djmaze 9.5  
631 djmaze 9.25 'U_VIEW_RESULTS' => getlink("&amp;file=viewtopic&amp;".POST_TOPIC_URL."=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
632 djmaze 9.5 );
633 djmaze 9.5  
634 djmaze 9.25 $s_hidden_fields = '<input type="hidden" name="topic_id" value="'.$topic_id.'" /><input type="hidden" name="mode" value="vote" />';
635 djmaze 9.5 }
636 djmaze 9.5  
637 djmaze 9.5 if ( count($orig_word) ) {
638 djmaze 9.5 $vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
639 djmaze 9.5 }
640 djmaze 9.5  
641 djmaze 9.5 $template->assign_vars(array(
642 djmaze 9.5 'POLL_QUESTION' => $vote_title,
643 djmaze 9.5  
644 djmaze 9.5 'S_HIDDEN_FIELDS' => $s_hidden_fields,
645 djmaze 9.25 'S_POLL_ACTION' => getlink("&amp;file=posting&amp;mode=vote&amp;".POST_TOPIC_URL."=$topic_id"))
646 djmaze 9.5 );
647 djmaze 9.5 }
648 djmaze 9.5 $template->assign_var('S_HAS_POLL', is_array($vote_info));
649 akamu 8.15 }else{
650 djmaze 9.5 $template->assign_var('S_HAS_POLL', 0);
651 djmaze 1.1 }
652 djmaze 1.1 //
653 djmaze 1.1 // Initializes some templating variables for displaying Attachments in Posts
654 djmaze 1.1 //
655 djmaze 1.1 //if (defined('BBAttach_mod')) {
656 djmaze 9.5 $switch_attachment = (empty($forum_topic_data) && !empty($forum_row)) ? $forum_row['topic_attachment'] : $forum_topic_data['topic_attachment'];
657 djmaze 9.5 if ( intval($switch_attachment) != 0 && !intval($attach_config['disable_mod']) && $is_auth['auth_download'] && $is_auth['auth_view'] ) {
658 djmaze 9.5 $post_id_array = array();
659 djmaze 9.5 for ($i = 0; $i < $total_posts; $i++) {
660 djmaze 9.5 if ($postrow[$i]['post_attachment'] == 1) {
661 djmaze 9.5 $post_id_array[] = $postrow[$i]['post_id'];
662 djmaze 9.5 }
663 djmaze 9.5 }
664 djmaze 9.5 if (count($post_id_array) > 0) {
665 djmaze 9.5 $rows = get_attachments_from_post($post_id_array);
666 djmaze 9.5 $num_rows = count($rows);
667 djmaze 9.5 if ($num_rows > 0) {
668 djmaze 9.5 reset($attachments);
669 djmaze 9.5 for ($i = 0; $i < $num_rows; $i++) {
670 djmaze 9.25 $attachments['_'.$rows[$i]['post_id']][] = $rows[$i];
671 djmaze 9.5 }
672 djmaze 9.5 init_complete_extensions_data();
673 djmaze 9.5 $template->assign_vars(array(
674 djmaze 9.5 'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
675 djmaze 9.5 'L_KILOBYTE' => $lang['KB'])
676 djmaze 9.5 );
677 djmaze 9.5 }
678 djmaze 9.5 }
679 djmaze 9.5 }
680 djmaze 1.1  
681 djmaze 1.1 //
682 djmaze 1.1 // Update the topic view counter
683 djmaze 1.1 //
684 djmaze 9.25 $db->sql_query("UPDATE ".TOPICS_TABLE." SET topic_views = topic_views + 1 WHERE topic_id = $topic_id");
685 djmaze 1.1  
686 djmaze 8.9 if (is_active('coppermine')) {
687 djmaze 9.5 list($ugall, $ugalldir) = $db->sql_ufetchrow("SELECT prefix, dirname FROM ".$prefix."_cpg_installs LIMIT 1");
688 djmaze 8.9 } else {
689 djmaze 9.5 $ugall = false;
690 djmaze 8.9 }
691 djmaze 8.9 $ugalleries = array();
692 djmaze 1.1 //
693 djmaze 1.1 // Okay, let's do the loop, yeah come on baby let's do the loop
694 djmaze 1.1 // and it goes like this ...
695 djmaze 1.1 //
696 djmaze 9.11 for ($i = 0; $i < $total_posts; $i++) {
697 djmaze 9.5 $poster_id = $postrow[$i]['user_id'];
698 djmaze 9.11 $poster = ($poster_id == ANONYMOUS) ? $lang['Guest'] : $postrow[$i]['username'];
699 djmaze 1.1  
700 djmaze 9.5 $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time']);
701 djmaze 1.1  
702 djmaze 9.25 $poster_posts = ($poster_id != ANONYMOUS) ? $lang['Posts'].': '.$postrow[$i]['user_posts'] : '';
703 djmaze 1.1  
704 djmaze 9.25 $poster_from = ($postrow[$i]['user_from'] && $poster_id != ANONYMOUS) ? $lang['Location'].': '.$postrow[$i]['user_from'] : '';
705 djmaze 9.37.2.3 $poster_from = str_replace('.gif', '', $poster_from);
706 phoenix 9.33 $poster_joined = ($poster_id != ANONYMOUS) ? $lang['Joined'].': '.formatDateTime($postrow[$i]['user_regdate'], '%b %d, %Y') : '';
707 djmaze 9.11 $poster_bio = ($poster_id != ANONYMOUS && $postrow[$i]['bio'] != '') ? sprintf($lang['About_user'],$postrow[$i]['username']).': '.$postrow[$i]['bio'].'<br/ >' : '';
708 djmaze 9.25 $poster_timezone = ($poster_id != ANONYMOUS && $postrow[$i]['user_timezone'] != '') ? $lang['Timezone']. ': '.$lang['tz'][$postrow[$i]['user_timezone']].'<br/ >' : '';
709 djmaze 9.11 $poster_occ = ($poster_id != ANONYMOUS && $postrow[$i]['user_occ'] != '') ? $lang['Occupation'].': '.$postrow[$i]['user_occ'].'<br/ >' : '';
710 djmaze 9.11 $poster_interests = ($poster_id != ANONYMOUS && (!empty($postrow[$i]['user_interests'])) ) ? $lang['Interests'].': '.$postrow[$i]['user_interests'] : '';
711 djmaze 9.5 $poster_avatar = '';
712 djmaze 9.5 if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] ) {
713 djmaze 9.5 switch( $postrow[$i]['user_avatar_type'] )
714 djmaze 9.5 {
715 djmaze 9.5 case USER_AVATAR_UPLOAD:
716 phoenix 9.35 $poster_avatar = ( $MAIN_CFG['avatar']['allow_upload'] ) ? '<img src="'.$MAIN_CFG['avatar']['path'].'/'.$postrow[$i]['user_avatar'].'" alt="" style="border:0;" />' : '';
717 djmaze 9.5 break;
718 djmaze 9.5 case USER_AVATAR_REMOTE:
719 phoenix 9.35 $poster_avatar = ( $MAIN_CFG['avatar']['allow_remote'] ) ? '<img src="'.$postrow[$i]['user_avatar'].'" alt="" style="border:0;" />' : '';
720 djmaze 9.5 break;
721 djmaze 9.5 case USER_AVATAR_GALLERY:
722 phoenix 9.35 $poster_avatar = ( $MAIN_CFG['avatar']['allow_local'] ) ? '<img src="'.$MAIN_CFG['avatar']['gallery_path'].'/'.$postrow[$i]['user_avatar'].'" alt="" style="border:0;" />' : '';
723 djmaze 9.5 break;
724 djmaze 9.5 }
725 djmaze 9.5 }
726 djmaze 9.5  
727 djmaze 9.5 //
728 djmaze 9.5 // Default Avatar MOD - Begin
729 djmaze 9.5 //
730 djmaze 9.5 if (empty($poster_avatar) && $poster_id != ANONYMOUS && isset($images['default_avatar'])) {
731 phoenix 9.35 $poster_avatar = '<img src="'. $images['default_avatar'] .'" alt="" style="border:0;" />';
732 djmaze 9.5 }
733 djmaze 9.5 if ($poster_id == ANONYMOUS && isset($images['guest_avatar'])) {
734 phoenix 9.35 $poster_avatar = '<img src="'. $images['guest_avatar'] .'" alt="" style="border:0;" />';
735 djmaze 9.5 }
736 djmaze 9.5  
737 djmaze 9.5 //
738 djmaze 9.5 // Define the little post icon
739 djmaze 9.5 //
740 djmaze 9.10 if (is_user() && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read) {
741 djmaze 9.5 $mini_post_img = $images['icon_minipost_new'];
742 djmaze 9.5 $mini_post_alt = $lang['New_post'];
743 djmaze 9.5 } else {
744 djmaze 9.5 $mini_post_img = $images['icon_minipost'];
745 djmaze 9.5 $mini_post_alt = $lang['Post'];
746 djmaze 9.5 }
747 djmaze 9.5  
748 djmaze 9.25 $mini_post_url = getlink("&amp;file=viewtopic&amp;".POST_POST_URL.'='.$postrow[$i]['post_id']).'#'.$postrow[$i]['post_id'];
749 djmaze 9.5  
750 djmaze 9.5 //
751 djmaze 9.5 // Generate ranks, set them to empty string initially.
752 djmaze 9.5 //
753 djmaze 9.5 $poster_rank = '';
754 djmaze 9.5 $rank_image = '';
755 djmaze 9.11 if ($poster_id != ANONYMOUS) {
756 djmaze 9.11 if ($postrow[$i]['user_rank']) {
757 djmaze 9.5 for($j = 0; $j < count($ranksrow); $j++) {
758 djmaze 9.5 if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] ) {
759 djmaze 9.5 $poster_rank = $ranksrow[$j]['rank_title'];
760 phoenix 9.35 $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="'.$ranksrow[$j]['rank_image'].'" alt="'.$poster_rank.'" title="'.$poster_rank.'" style="border:0;" /><br />' : '';
761 djmaze 9.5 }
762 djmaze 9.5 }
763 djmaze 9.5 } else {
764 djmaze 9.5 for($j = 0; $j < count($ranksrow); $j++) {
765 djmaze 9.5 if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] ) {
766 djmaze 9.5 $poster_rank = $ranksrow[$j]['rank_title'];
767 phoenix 9.35 $rank_image = ($ranksrow[$j]['rank_image']) ? '<img src="'.$ranksrow[$j]['rank_image'].'" alt="'.$poster_rank.'" title="'.$poster_rank.'" style="border:0;" /><br />' : '';
768 djmaze 9.5 }
769 djmaze 9.5 }
770 djmaze 9.5 }
771 djmaze 9.5 }
772 djmaze 9.5  
773 djmaze 9.5 //
774 djmaze 9.5 // Handle anon users posting with usernames
775 djmaze 9.5 //
776 djmaze 9.11 if ($poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '') {
777 djmaze 9.5 $poster = $postrow[$i]['post_username'];
778 djmaze 9.5 $poster_rank = $lang['Guest'];
779 djmaze 9.5 }
780 djmaze 9.5  
781 djmaze 9.27 $old_theme = version_compare(THEME_VERSION, '9.1', '<');
782 djmaze 9.27 $profile_img = $profile = $pm_img = $pm = $email_img = $email = $www_img = $www = $icq_status_img = $icq_img = $icq = $aim_img = $aim = $msn_img = $msn = $yim_img = $yim = $skype_img = $skype = $gal_img = $gal = '';
783 djmaze 9.11 if ($poster_id != ANONYMOUS) {
784 djmaze 9.27 $profile = array(
785 djmaze 9.27 'IMG' => $images['icon_profile'],
786 djmaze 9.27 'TITLE' => $lang['Read_profile'],
787 djmaze 9.27 'URL' => getlink("Your_Account&amp;profile=$poster_id"),
788 djmaze 9.27 'TARGET' => false
789 djmaze 9.27 );
790 djmaze 9.27 if ($old_theme) {
791 phoenix 9.35 $profile_img = '<a href="'.$profile['URL'].'"><img src="'.$profile['IMG'].'" alt="'.$profile['TITLE'].'" title="'.$profile['TITLE'].'" style="border:0;" /></a>';
792 djmaze 9.27 $profile = '<a href="'.$profile['URL'].'">'.$profile['TITLE'].'</a>';
793 djmaze 9.27 }
794 djmaze 9.28 if (is_user() && is_active("Private_Messages")) {
795 djmaze 9.27 $pm = array(
796 djmaze 9.27 'IMG' => $images['icon_pm'],
797 djmaze 9.27 'TITLE' => $lang['Send_private_message'],
798 djmaze 9.27 'URL' => getlink("Private_Messages&amp;mode=post&amp;".POST_USERS_URL."=$poster_id"),
799 djmaze 9.27 'TARGET' => false
800 djmaze 9.27 );
801 djmaze 9.27 if ($old_theme) {
802 phoenix 9.35 $pm_img = '<a href="'.$pm['URL'].'"><img src="'.$pm['IMG'].'" alt="'.$pm['TITLE'].'" title="'.$pm['TITLE'].'" style="border:0;" /></a>';
803 djmaze 9.27 $pm = '<a href="'.$pm['URL'].'">'.$pm['TITLE'].'</a>';
804 djmaze 9.27 }
805 djmaze 9.27 }
806 djmaze 9.27 if (!empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod']) {
807 djmaze 9.27 $email = array(
808 djmaze 9.27 'IMG' => $images['icon_email'],
809 djmaze 9.27 'TITLE' => $lang['Send_email'],
810 djmaze 9.27 'URL' => ($board_config['board_email_form']) ? getlink("&amp;file=profile&amp;mode=email&amp;".POST_USERS_URL.'='.$poster_id) : 'mailto:'.$postrow[$i]['user_email'],
811 djmaze 9.27 'TARGET' => false
812 djmaze 9.27 );
813 djmaze 9.27 if ($old_theme) {
814 phoenix 9.35 $email_img = '<a href="'.$email['URL'].'"><img src="'.$email['IMG'].'" alt="'.$email['TITLE'].'" title="'.$email['TITLE'].'" style="border:0;" /></a>';
815 djmaze 9.27 $email = '<a href="'.$email['URL'].'">'.$email['TITLE'].'</a>';
816 djmaze 9.27 }
817 djmaze 9.27 }
818 djmaze 9.27 if ($postrow[$i]['user_website'] == 'http:///' || $postrow[$i]['user_website'] == 'http://'){
819 djmaze 9.27 $postrow[$i]['user_website'] = '';
820 djmaze 9.5 }
821 djmaze 9.27 if (!empty($postrow[$i]['user_website'])) {
822 djmaze 9.27 if (substr($postrow[$i]['user_website'],0, 7) != 'http://') {
823 djmaze 9.27 $postrow[$i]['user_website'] = 'http://'.$postrow[$i]['user_website'];
824 djmaze 9.27 }
825 djmaze 9.27 $www = array(
826 djmaze 9.27 'IMG' => $images['icon_www'],
827 djmaze 9.27 'TITLE' => $lang['Visit_website'],
828 djmaze 9.27 'URL' => $postrow[$i]['user_website'],
829 djmaze 9.27 'TARGET' => '_blank'
830 djmaze 9.27 );
831 djmaze 9.27 if ($old_theme) {
832 phoenix 9.35 $www_img = '<a href="'.$www['URL'].'" target="_blank"><img src="'.$www['IMG'].'" alt="'.$www['TITLE'].'" title="'.$www['TITLE'].'" style="border:0;" /></a>';
833 djmaze 9.27 $www = '<a href="'.$www['URL'].'" target="_blank">'.$www['TITLE'].'</a>';
834 djmaze 9.27 }
835 djmaze 9.27 }
836 djmaze 9.27 if (!empty($postrow[$i]['user_icq'])) {
837 djmaze 9.27 $icq = array(
838 djmaze 9.27 'IMG' => $images['icon_icq'],
839 djmaze 9.27 'TITLE' => $lang['ICQ'],
840 nanocaio 9.31 'URL' => 'http://www.icq.com/people/about_me.php?uin='.$postrow[$i]['user_icq'],
841 djmaze 9.27 'TARGET' => '_blank'
842 djmaze 9.27 );
843 djmaze 9.27 if ($old_theme) {
844 phoenix 9.35 $icq_status_img = '<a href="http://wwp.icq.com/'.$postrow[$i]['user_icq'].'#pager"><img src="http://web.icq.com/whitepages/online?icq='.$postrow[$i]['user_icq'].'&img=5" style="border:0; width:18px; height:18px;" /></a>';
845 phoenix 9.35 $icq_img = '<a href="'.$icq['URL'].'" target="_blank"><img src="'.$icq['IMG'].'" alt="'.$icq['TITLE'].'" title="'.$icq['TITLE'].'" style="border:0;" /></a>';
846 djmaze 9.27 $icq = '<a href="'.$icq['URL'].'" target="_blank">'.$icq['TITLE'].'</a>';
847 djmaze 9.27 }
848 djmaze 9.27 }
849 djmaze 9.27 if (!empty($postrow[$i]['user_aim'])) {
850 djmaze 9.27 $aim = array(
851 djmaze 9.27 'IMG' => $images['icon_aim'],
852 djmaze 9.27 'TITLE' => $lang['AIM'],
853 djmaze 9.27 'URL' => 'aim:goim?screenname='.$postrow[$i]['user_aim'].'&amp;message=Hey+are+you+there?',
854 djmaze 9.27 'TARGET' => false
855 djmaze 9.27 );
856 djmaze 9.27 if ($old_theme) {
857 phoenix 9.35 $aim_img = '<a href="'.$aim['URL'].'"><img src="'.$aim['IMG'].'" alt="'.$aim['TITLE'].'" title="'.$aim['TITLE'].'" style="border:0;" /></a>';
858 djmaze 9.27 $aim = '<a href="'.$aim['URL'].'">'.$aim['TITLE'].'</a>';
859 djmaze 9.27 }
860 djmaze 9.5 }
861 djmaze 9.27 if (!empty($postrow[$i]['user_msnm'])) {
862 djmaze 9.27 $msn = array(
863 djmaze 9.27 'IMG' => $images['icon_msnm'],
864 djmaze 9.27 'TITLE' => $lang['MSNM'],
865 djmaze 9.27 'URL' => 'http://members.msn.com/'.$postrow[$i]['user_msnm'],
866 djmaze 9.27 'TARGET' => '_blank'
867 djmaze 9.27 );
868 djmaze 9.27 if ($old_theme) {
869 phoenix 9.35 $msn_img = '<a href="'.$msn['URL'].'" target="_blank"><img src="'.$msn['IMG'].'" alt="'.$msn['TITLE'].'" title="'.$msn['TITLE'].'" style="border:0;" /></a>';
870 djmaze 9.27 $msn = '<a href="'.$msn['URL'].'" target="_blank">'.$msn['TITLE'].'</a>';
871 djmaze 9.27 }
872 djmaze 9.5 }
873 djmaze 9.27 if (!empty($postrow[$i]['user_yim'])) {
874 djmaze 9.27 $yim = array(
875 djmaze 9.27 'IMG' => $images['icon_yim'],
876 djmaze 9.27 'TITLE' => $lang['YIM'],
877 djmaze 9.27 'URL' => 'http://edit.yahoo.com/config/send_webmesg?.target='.$postrow[$i]['user_yim'].'&amp;.src=pg',
878 djmaze 9.27 'TARGET' => '_blank'
879 djmaze 9.27 );
880 djmaze 9.27 if ($old_theme) {
881 phoenix 9.35 $yim_img = '<a href="'.$yim['URL'].'" target="_blank"><img src="'.$yim['IMG'].'" alt="'.$yim['TITLE'].'" title="'.$yim['TITLE'].'" style="border:0;" /></a>';
882 djmaze 9.27 $yim = '<a href="'.$yim['URL'].'" target="_blank">'.$yim['TITLE'].'</a>';
883 djmaze 9.27 }
884 djmaze 9.5 }
885 djmaze 9.27 if (!empty($postrow[$i]['user_skype'])) {
886 djmaze 9.27 $skype = array(
887 djmaze 9.27 'IMG' => $images['icon_skype'],
888 djmaze 9.27 'TITLE' => 'Skype',
889 djmaze 9.27 'URL' => 'callto://'.$postrow[$i]['user_skype'],
890 djmaze 9.27 'TARGET' => false
891 djmaze 9.27 );
892 djmaze 9.27 if ($old_theme) {
893 phoenix 9.35 $skype_img = '<a href="'.$skype['URL'].'"><img src="'.$skype['IMG'].'" alt="'.$skype['TITLE'].'" title="'.$skype['TITLE'].'" style="border:0;" /></a>';
894 djmaze 9.27 $skype = '<a href="'.$skype['URL'].'">'.$skype['TITLE'].'</a>';
895 djmaze 9.27 }
896 djmaze 9.5 }
897 djmaze 9.5 if ($ugall) {
898 djmaze 9.5 $user_gallery = 10000+$poster_id;
899 djmaze 9.5 if (!isset($ugalleries[$user_gallery])) {
900 phoenix 9.32 $ugall_result = $db->sql_ufetchrow("SELECT COUNT(*) FROM ".$ugall."pictures AS p, ".$ugall."albums AS a WHERE a.aid=p.aid AND a.category=$user_gallery LIMIT 0,1");
901 djmaze 9.5 $ugalleries[$user_gallery] = $ugall_result[0];
902 djmaze 9.5 }
903 djmaze 9.5 if ($ugalleries[$user_gallery]){
904 djmaze 9.27 $gal = array(
905 djmaze 9.27 'IMG' => $images['icon_cpg'],
906 djmaze 9.27 'TITLE' => _coppermineLANG,
907 djmaze 9.27 'URL' => getlink($ugalldir."&amp;cat=".$user_gallery),
908 djmaze 9.27 'TARGET' => false
909 djmaze 9.27 );
910 djmaze 9.27 if ($old_theme) {
911 phoenix 9.35 $gal_img = '<a href="'.$gal['URL'].'"><img src="'.$gal['IMG'].'" alt="'.$gal['TITLE'].'" title="'.$gal['TITLE'].'" style="border:0;" /></a>';
912 djmaze 9.27 $gal = '<a href="'.$gal['URL'].'">'.$gal['TITLE'].'</a>';
913 djmaze 9.27 }
914 djmaze 9.5 }
915 djmaze 9.5 }
916 djmaze 9.5 }
917 djmaze 9.5  
918 djmaze 9.25 $temp_url = getlink("&amp;file=posting&amp;mode=quote&amp;".POST_POST_URL."=".$postrow[$i]['post_id']);
919 phoenix 9.35 $quote_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_quote'].'" alt="'.$lang['Reply_with_quote'].'" title="'.$lang['Reply_with_quote'].'" style="border:0;" /></a>';
920 djmaze 9.25 $quote = '<a href="'.$temp_url.'">'.$lang['Reply_with_quote'].'</a>';
921 djmaze 9.25  
922 djmaze 9.25 $temp_url = getlink("&amp;file=search&amp;search_author=".urlencode($postrow[$i]['username'])."&amp;showresults=posts");
923 phoenix 9.35 $search_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_search'].'" alt="'.$lang['Search_user_posts'].'" title="'.$lang['Search_user_posts'].'" style="border:0;" /></a>';
924 djmaze 9.25 $search = '<a href="'.$temp_url.'">'.$lang['Search_user_posts'].'</a>';
925 djmaze 9.5  
926 djmaze 9.5 if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] ) {
927 djmaze 9.25 $temp_url = getlink("&amp;file=posting&amp;mode=editpost&amp;".POST_POST_URL."=".$postrow[$i]['post_id']);
928 phoenix 9.35 $edit_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_edit'].'" alt="'.$lang['Edit_delete_post'].'" title="'.$lang['Edit_delete_post'].'" style="border:0;" /></a>';
929 djmaze 9.25 $edit = '<a href="'.$temp_url.'">'.$lang['Edit_delete_post'].'</a>';
930 djmaze 9.5 } else {
931 trevor 9.7 $edit_img = $edit = '';
932 djmaze 9.5 }
933 djmaze 9.5  
934 djmaze 9.5 if ( $is_auth['auth_mod'] ) {
935 djmaze 9.25 $temp_url = getlink("&amp;file=modcp&amp;mode=ip&amp;".POST_POST_URL."=".$postrow[$i]['post_id']."&amp;".POST_TOPIC_URL."=".$topic_id);
936 phoenix 9.35 $ip_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_ip'].'" alt="'.$lang['View_IP'].'" title="'.$lang['View_IP'].'" style="border:0;" /></a>';
937 djmaze 9.25 $ip = '<a href="'.$temp_url.'">'.$lang['View_IP'].'</a>';
938 djmaze 9.25 $temp_url = getlink("&amp;file=posting&amp;mode=delete&amp;".POST_POST_URL."=".$postrow[$i]['post_id']);
939 phoenix 9.35 $delpost_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_delpost'].'" alt="'.$lang['Delete_post'].'" title="'.$lang['Delete_post'].'" style="border:0;" /></a>';
940 djmaze 9.25 $delpost = '<a href="'.$temp_url.'">'.$lang['Delete_post'].'</a>';
941 djmaze 9.5 } else {
942 djmaze 9.5 $ip_img = '';
943 djmaze 9.5 $ip = '';
944 djmaze 9.5 if ($userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id']) {
945 djmaze 9.25 $temp_url = getlink("&amp;file=posting&amp;mode=delete&amp;".POST_POST_URL."=".$postrow[$i]['post_id']);
946 phoenix 9.35 $delpost_img = '<a href="'.$temp_url.'"><img src="'.$images['icon_delpost'].'" alt="'.$lang['Delete_post'].'" title="'.$lang['Delete_post'].'" style="border:0;" /></a>';
947 djmaze 9.25 $delpost = '<a href="'.$temp_url.'">'.$lang['Delete_post'].'</a>';
948 djmaze 9.5 } else {
949 trevor 9.7 $delpost_img = $delpost = '';
950 djmaze 9.5 }
951 djmaze 9.5 }
952 djmaze 9.5  
953 djmaze 9.5 $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
954 djmaze 9.5  
955 djmaze 9.5 $message = $postrow[$i]['post_text'];
956 djmaze 9.5 $user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
957 djmaze 9.5 //
958 djmaze 9.5 // Note! The order used for parsing the message _is_ important, moving things around could break any output
959 djmaze 9.5 //
960 djmaze 9.5  
961 djmaze 9.5 //
962 djmaze 9.5 // If the board has HTML off but the post has HTML
963 djmaze 9.5 // on then we process it, else leave it alone
964 djmaze 9.5 //
965 trevor 9.14 if (!$board_config['allow_html'] || !$userdata['user_allowhtml']) {
966 trevor 9.14 if ($user_sig != '') {
967 djmaze 9.5 $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
968 djmaze 9.5 }
969 djmaze 9.5 if ($postrow[$i]['enable_html']) {
970 djmaze 9.5 $message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
971 djmaze 9.5 }
972 djmaze 9.5 }
973 djmaze 9.5  
974 djmaze 9.5 //
975 djmaze 9.5 // Parse message and/or sig for BBCode if reqd
976 djmaze 9.5 //
977 djmaze 9.5 if ($user_sig != '') {
978 djmaze 9.26 $user_sig = ($board_config['allow_bbcode']) ? decode_bbcode($user_sig, 1, false) : nl2br($user_sig);
979 djmaze 9.5 }
980 djmaze 9.5 if ($postrow[$i]['enable_bbcode']) {
981 djmaze 9.26 $message = ($board_config['allow_bbcode']) ? decode_bbcode($message, 1, false) : nl2br($message);
982 djmaze 9.17 } else {
983 djmaze 9.17 $message = nl2br($message);
984 djmaze 9.5 }
985 djmaze 9.5  
986 djmaze 9.16 if ($user_sig != '') { $user_sig = make_clickable($user_sig); }
987 djmaze 9.5 $message = make_clickable($message);
988 djmaze 9.5  
989 djmaze 9.5 //
990 djmaze 9.5 // Parse smilies
991 djmaze 9.5 //
992 djmaze 9.5 if ($board_config['allow_smilies']) {
993 djmaze 9.5 if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' ) {
994 djmaze 9.5 $user_sig = set_smilies($user_sig);
995 djmaze 9.5 }
996 djmaze 9.5 if ($postrow[$i]['enable_smilies']) {
997 djmaze 9.5 $message = set_smilies($message);
998 djmaze 9.5 }
999 djmaze 9.5 }
1000 djmaze 9.5  
1001 djmaze 9.5 //
1002 djmaze 9.5 // Highlight active words (primarily for search)
1003 djmaze 9.5 //
1004 djmaze 9.5 if ($highlight_match) {
1005 djmaze 9.5 // This was shamelessly 'borrowed' from volker at multiartstudio dot de
1006 djmaze 9.5 // via php.net's annotated manual
1007 phoenix 9.37 $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#(".$highlight_match.")#i', '<span style=\"color:#FFA34F;\"><b>\\\\1</b></span>', '\\0')", '>'.$message.'<'), 1, -1));
1008 djmaze 9.5 }
1009 djmaze 9.5  
1010 djmaze 9.5 //
1011 djmaze 9.5 // Replace naughty words
1012 djmaze 9.5 //
1013 djmaze 9.5 if (count($orig_word)) {
1014 djmaze 9.5 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
1015 djmaze 9.5 if ($user_sig != '') {
1016 djmaze 9.25 $user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>'.$user_sig.'<'), 1, -1));
1017 djmaze 9.5 }
1018 djmaze 9.25 $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>'.$message.'<'), 1, -1));
1019 djmaze 9.5 }
1020 djmaze 9.5  
1021 djmaze 9.5 //
1022 djmaze 9.5 // Replace newlines (we use this rather than nl2br because
1023 djmaze 9.5 // till recently it wasn't XHTML compliant)
1024 djmaze 9.5 //
1025 djmaze 9.11 if ($user_sig != '') {
1026 djmaze 9.25 $user_sig = '<br />_________________<br />'.$user_sig;
1027 djmaze 9.5 }
1028 phoenix 9.35 /* added for dragonflycms.org 9/3/ 2004 10:41PM akamu*/
1029 djmaze 9.12 if ($poster_id != ANONYMOUS && isset($postrow[$i]['server_specs'])) {
1030 djmaze 9.11 if ($postrow[$i]['server_specs'] != '' ) {
1031 djmaze 9.37.2.2 $user_sig .= '<br /><br /><span class="postdetails" style="color: #333399">'.$postrow[$i]['username'].'\'s server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)<br />'.preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $postrow[$i]['server_specs']).'</span>';
1032 djmaze 9.5 } else {
1033 djmaze 9.5 $user_sig .= '<br /><br /><span class="postdetails" style="color: #333399">'.$postrow[$i]['username'].' please enter your server specs in your user profile!</span> '.set_smilies(' :cry: ');
1034 djmaze 9.5 }
1035 djmaze 9.5 }
1036 djmaze 9.5  
1037 djmaze 9.5 // $message = str_replace("\n", "\n<br />\n", $message);
1038 djmaze 9.5  
1039 djmaze 9.5 //
1040 djmaze 9.5 // Editing information
1041 djmaze 9.5 //
1042 djmaze 9.11 if ($postrow[$i]['post_edit_count']) {
1043 djmaze 9.5 $l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
1044 djmaze 9.25 $l_edited_by = '<br /><br />'.sprintf($l_edit_time_total, $poster, create_date($board_config['default_dateformat'], $postrow[$i]['post_edit_time']), $postrow[$i]['post_edit_count']);
1045 djmaze 9.5 } else {
1046 djmaze 9.5 $l_edited_by = '';
1047 djmaze 9.5 }
1048 djmaze 9.5  
1049 djmaze 9.5 //
1050 djmaze 9.5 // Again this will be handled by the templating
1051 djmaze 9.5 // code at some point
1052 djmaze 9.5 //
1053 phoenix 9.36 $row_color = ( !($i % 2) ) ? $bgcolor1 : $bgcolor2;
1054 phoenix 9.36 $row_class = ( !($i % 2) ) ? 'row1' : 'row2';
1055 djmaze 9.5  
1056 djmaze 9.5 $template->assign_block_vars('postrow', array(
1057 djmaze 9.25 'S_HAS_ATTACHMENTS' => isset($attachments['_'.$postrow[$i]['post_id']]),
1058 phoenix 9.36 'ROW_COLOR' => $row_color,
1059 djmaze 9.5 'ROW_CLASS' => $row_class,
1060 djmaze 9.5 'POSTER_NAME' => $poster,
1061 djmaze 9.5 'POSTER_RANK' => $poster_rank,
1062 djmaze 9.5 'RANK_IMAGE' => $rank_image,
1063 djmaze 9.5 'POSTER_JOINED' => $poster_joined,
1064 djmaze 9.5 'POSTER_POSTS' => $poster_posts,
1065 djmaze 9.5 'POSTER_FROM' => $poster_from,
1066 djmaze 9.5 'POSTER_AVATAR' => $poster_avatar,
1067 djmaze 9.5 'POSTER_BIO' => $poster_bio,
1068 djmaze 9.5 'POSTER_TZ' => $poster_timezone,
1069 djmaze 9.5 'POSTER_OCC' => $poster_occ,
1070 djmaze 9.5 'POSTER_INTERESTS' => $poster_interests,
1071 djmaze 9.5 'POST_NUMBER' => ($i + $start + 1),
1072 djmaze 9.5 'POST_DATE' => $post_date,
1073 djmaze 9.5 'POST_SUBJECT' => $post_subject,
1074 djmaze 9.5 'MESSAGE' => $message,
1075 djmaze 9.5 'SIGNATURE' => $user_sig,
1076 djmaze 9.5 'EDITED_MESSAGE' => $l_edited_by,
1077 djmaze 9.5  
1078 djmaze 9.5 'MINI_POST_IMG' => $mini_post_img,
1079 djmaze 9.5 'PROFILE_IMG' => $profile_img,
1080 djmaze 9.5 'PROFILE' => $profile,
1081 djmaze 9.5 'SEARCH_IMG' => $search_img,
1082 djmaze 9.5 'SEARCH' => $search,
1083 djmaze 9.5 'PM_IMG' => $pm_img,
1084 djmaze 9.5 'PM' => $pm,
1085 djmaze 9.5 'EMAIL_IMG' => $email_img,
1086 djmaze 9.5 'EMAIL' => $email,
1087 djmaze 9.5 'WWW_IMG' => $www_img,
1088 djmaze 9.5 'WWW' => $www,
1089 djmaze 9.5 'ICQ_STATUS_IMG' => $icq_status_img,
1090 djmaze 9.5 'ICQ_IMG' => $icq_img,
1091 djmaze 9.5 'ICQ' => $icq,
1092 djmaze 9.5 'AIM_IMG' => $aim_img,
1093 djmaze 9.5 'AIM' => $aim,
1094 djmaze 9.5 'MSN_IMG' => $msn_img,
1095 djmaze 9.5 'MSN' => $msn,
1096 djmaze 9.5 'YIM_IMG' => $yim_img,
1097 djmaze 9.5 'YIM' => $yim,
1098 akamu 9.8 //'SKYPE_IMG' => $skype_img,
1099 akamu 9.8 //'SKYPE' => $skype,
1100 djmaze 9.5 'GAL_IMG' => $gal_img,
1101 djmaze 9.5 'GAL' => $gal,
1102 djmaze 9.5 'EDIT_IMG' => $edit_img,
1103 djmaze 9.5 'EDIT' => $edit,
1104 djmaze 9.5 'QUOTE_IMG' => $quote_img,
1105 djmaze 9.5 'QUOTE' => $quote,
1106 djmaze 9.5 'IP_IMG' => $ip_img,
1107 djmaze 9.5 'IP' => $ip,
1108 djmaze 9.5 'DELETE_IMG' => $delpost_img,
1109 djmaze 9.5 'DELETE' => $delpost,
1110 djmaze 9.5  
1111 djmaze 9.5 'L_MINI_POST_ALT' => $mini_post_alt,
1112 djmaze 9.5  
1113 djmaze 9.5 'U_MINI_POST' => $mini_post_url,
1114 djmaze 9.5 'U_POST_ID' => $postrow[$i]['post_id'])
1115 djmaze 9.5 );
1116 djmaze 9.27 if ($poster_id != ANONYMOUS && !$old_theme) {
1117 djmaze 9.27 $template->assign_block_vars('postrow.user_details', $profile);
1118 djmaze 9.27 if (!empty($pm)) { $template->assign_block_vars('postrow.user_details', $pm); }
1119 djmaze 9.27 if (!empty($email)) { $template->assign_block_vars('postrow.user_details', $email); }
1120 djmaze 9.27 if (!empty($www)) { $template->assign_block_vars('postrow.user_details', $www); }
1121 djmaze 9.27 if (!empty($icq)) { $template->assign_block_vars('postrow.user_details', $icq); }
1122 djmaze 9.27 if (!empty($aim)) { $template->assign_block_vars('postrow.user_details', $aim); }
1123 djmaze 9.27 if (!empty($msn)) { $template->assign_block_vars('postrow.user_details', $msn); }
1124 djmaze 9.27 if (!empty($yim)) { $template->assign_block_vars('postrow.user_details', $yim); }
1125 djmaze 9.27 if (!empty($skype)) { $template->assign_block_vars('postrow.user_details', $skype); }
1126 djmaze 9.27 if (!empty($gal)) { $template->assign_block_vars('postrow.user_details', $gal); }
1127 djmaze 9.27 }
1128 djmaze 9.5 //
1129 djmaze 9.5 // Display Attachments in Posts
1130 djmaze 9.5 //
1131 djmaze 9.5 // if (defined('BBAttach_mod') && $postrow[$i]['post_attachment']) {
1132 djmaze 9.5 if (!intval($attach_config['disable_mod']) && $is_auth['auth_download'] && $postrow[$i]['post_attachment']) {
1133 djmaze 9.5 display_attachments($postrow[$i]['post_id']);
1134 djmaze 9.5 }
1135 djmaze 1.1 }
1136 djmaze 1.1  
1137 djmaze 1.1 //
1138 djmaze 1.1 // Quick Reply Mod
1139 djmaze 1.1 //
1140 akamu 9.21 if ((!$is_auth['auth_reply'] || ($board_config['ropm_quick_reply']=='0') || $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED) && $userdata['user_level'] != ADMIN ) {
1141 djmaze 9.5 $template->assign_vars(array('QUICK_REPLY_FORM' => ''));
1142 djmaze 1.4 } else {
1143 djmaze 9.5 if ( $can_watch_topic && $is_watching_topic ) {
1144 djmaze 9.5 $notify = 1;
1145 djmaze 9.5 } else {
1146 djmaze 9.5 $notify = $userdata['user_notify'];
1147 djmaze 9.5 }
1148 djmaze 9.5 $last_poster = $postrow[$total_posts - 1]['username'];
1149 djmaze 9.5 $last_msg = $postrow[$total_posts - 1]['post_text'];
1150 djmaze 9.25 $last_msg = "[quote=\"$last_poster\"]".$last_msg.'[/quote]';
1151 djmaze 9.5 $last_msg = str_replace("'", "&#39;", $last_msg);
1152 djmaze 9.5 $last_msg = str_replace('"', '&quot;', $last_msg);
1153 djmaze 9.5  
1154 djmaze 9.18 $quick_reply_form = '<input type="hidden" name="mode" value="reply" />
1155 djmaze 9.18 <input type="hidden" name="last_msg" value="'.$last_msg.'" />
1156 djmaze 9.18 <input type="hidden" name="subject" value="Re: '.$topic_title.'" />
1157 djmaze 9.18 <input type="hidden" name="t" value="'.$topic_id.'" />
1158 djmaze 9.18 <input type="hidden" name="notify" value="'.$notify.'" />';
1159 djmaze 1.1  
1160 djmaze 9.19 $anon_reply = '';
1161 djmaze 1.6  
1162 djmaze 9.19 $template->set_filenames(array('quickreply' => 'forums/quickreply.html'));
1163 djmaze 9.5 $template->assign_vars(array(
1164 djmaze 9.5 'L_ATTACH_SIGNATURE' => $lang['Attach_signature'],
1165 djmaze 9.5 'L_EMPTY_MESSAGE' => $lang['Empty_message'],
1166 djmaze 9.5 'L_PREVIEW' => $lang['Preview'],
1167 djmaze 9.5 'L_QUICK_REPLY' => $lang['Quick_Reply'],
1168 djmaze 9.5 'L_QUICK_QUOTE' => $lang['Quick_quote'],
1169 djmaze 9.5 'L_SUBMIT' => $lang['Submit'],
1170 djmaze 9.5 'L_USERNAME' => $lang['Username'],
1171 djmaze 9.5  
1172 djmaze 9.5 'S_ANON_QREPLY' => $anon_reply,
1173 djmaze 9.5 'S_HIDDEN_QREPLY_FIELDS' => $quick_reply_form,
1174 djmaze 9.10 'S_IS_ANON' => !is_user(),
1175 djmaze 9.5 'S_QREPLY_MSG' => $last_msg,
1176 djmaze 9.5 'S_QREPLY_SIG' => ( $userdata['user_attachsig'] ) ? ' checked="checked"' : '',
1177 djmaze 9.5  
1178 djmaze 9.5 'U_POST_ACTION' => getlink('&amp;file=posting')
1179 djmaze 9.5 )
1180 djmaze 9.5 );
1181 djmaze 9.5 $template->assign_var_from_handle('QUICK_REPLY_FORM', 'quickreply');
1182 djmaze 1.1 }
1183 djmaze 1.1 //
1184 djmaze 1.1 // END Quick Reply Mod
1185 djmaze 1.1 //
1186 djmaze 1.1  
1187 djmaze 9.19 if(isset($_GET['printertopic'])) {
1188 djmaze 9.19 $template->set_filenames(array('body' => 'forums/printertopic_body.html'));
1189 djmaze 1.1 } else {
1190 djmaze 9.19 $template->set_filenames(array('body' => 'forums/viewtopic_body.html'));
1191 djmaze 1.1 }
1192 djmaze 1.1  
1193 djmaze 1.1 if(isset($_GET['printertopic'])) {
1194 djmaze 9.5 $gen_simple_header = 1;
1195 djmaze 1.1 }
1196 djmaze 8.16 require_once('includes/phpBB/page_tail.php');


Code Credits - Privacy Policy