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 : 8.18 (9 years 3 months 2 weeks 5 hours 14 minutes 28 seconds ago) by djmaze
Changed : +17 -16 lines
Comment: Complete new installer (expect some bugs)
Changed users_fields table prefix to the $user_prefix
Changed history field elanguage to language
Changed coppermine user_active_cp in *_users from YES/NO to INT (for future use on Postgresql and others)

And some small other fixes


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


Code Credits - Privacy Policy