|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package phpBB3
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
define('IN_PHPBB', true);
|
|
indvdum@0
|
15 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
indvdum@0
|
16 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
indvdum@0
|
17 |
include($phpbb_root_path . 'common.' . $phpEx);
|
|
indvdum@0
|
18 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
19 |
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
indvdum@0
|
20 |
|
|
indvdum@0
|
21 |
// Start session management
|
|
indvdum@0
|
22 |
$user->session_begin();
|
|
indvdum@0
|
23 |
$auth->acl($user->data);
|
|
indvdum@0
|
24 |
|
|
indvdum@0
|
25 |
// Initial var setup
|
|
indvdum@0
|
26 |
$forum_id = request_var('f', 0);
|
|
indvdum@0
|
27 |
$topic_id = request_var('t', 0);
|
|
indvdum@0
|
28 |
$post_id = request_var('p', 0);
|
|
indvdum@0
|
29 |
$voted_id = request_var('vote_id', array('' => 0));
|
|
indvdum@0
|
30 |
|
|
indvdum@0
|
31 |
$voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;
|
|
indvdum@0
|
32 |
|
|
indvdum@0
|
33 |
|
|
indvdum@0
|
34 |
$start = request_var('start', 0);
|
|
indvdum@0
|
35 |
$view = request_var('view', '');
|
|
indvdum@0
|
36 |
|
|
indvdum@0
|
37 |
$default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0;
|
|
indvdum@0
|
38 |
$default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't';
|
|
indvdum@0
|
39 |
$default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a';
|
|
indvdum@0
|
40 |
|
|
indvdum@0
|
41 |
$sort_days = request_var('st', $default_sort_days);
|
|
indvdum@0
|
42 |
$sort_key = request_var('sk', $default_sort_key);
|
|
indvdum@0
|
43 |
$sort_dir = request_var('sd', $default_sort_dir);
|
|
indvdum@0
|
44 |
|
|
indvdum@0
|
45 |
$update = request_var('update', false);
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
$s_can_vote = false;
|
|
indvdum@0
|
48 |
/**
|
|
indvdum@0
|
49 |
* @todo normalize?
|
|
indvdum@0
|
50 |
*/
|
|
indvdum@0
|
51 |
$hilit_words = request_var('hilit', '', true);
|
|
indvdum@0
|
52 |
|
|
indvdum@0
|
53 |
// Do we have a topic or post id?
|
|
indvdum@0
|
54 |
if (!$topic_id && !$post_id)
|
|
indvdum@0
|
55 |
{
|
|
indvdum@0
|
56 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
57 |
}
|
|
indvdum@0
|
58 |
|
|
indvdum@0
|
59 |
// Find topic id if user requested a newer or older topic
|
|
indvdum@0
|
60 |
if ($view && !$post_id)
|
|
indvdum@0
|
61 |
{
|
|
indvdum@0
|
62 |
if (!$forum_id)
|
|
indvdum@0
|
63 |
{
|
|
indvdum@0
|
64 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
65 |
FROM ' . TOPICS_TABLE . "
|
|
indvdum@0
|
66 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
67 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
68 |
$forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
indvdum@0
|
69 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
70 |
|
|
indvdum@0
|
71 |
if (!$forum_id)
|
|
indvdum@0
|
72 |
{
|
|
indvdum@0
|
73 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
74 |
}
|
|
indvdum@0
|
75 |
}
|
|
indvdum@0
|
76 |
|
|
indvdum@0
|
77 |
if ($view == 'unread')
|
|
indvdum@0
|
78 |
{
|
|
indvdum@0
|
79 |
// Get topic tracking info
|
|
indvdum@0
|
80 |
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
|
|
indvdum@0
|
81 |
|
|
indvdum@0
|
82 |
$topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;
|
|
indvdum@0
|
83 |
|
|
indvdum@0
|
84 |
$sql = 'SELECT post_id, topic_id, forum_id
|
|
indvdum@0
|
85 |
FROM ' . POSTS_TABLE . "
|
|
indvdum@0
|
86 |
WHERE topic_id = $topic_id
|
|
indvdum@0
|
87 |
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
|
|
indvdum@0
|
88 |
AND post_time > $topic_last_read
|
|
indvdum@0
|
89 |
AND forum_id = $forum_id
|
|
indvdum@0
|
90 |
ORDER BY post_time ASC";
|
|
indvdum@0
|
91 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
92 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
93 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
94 |
|
|
indvdum@0
|
95 |
if (!$row)
|
|
indvdum@0
|
96 |
{
|
|
indvdum@0
|
97 |
$sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id
|
|
indvdum@0
|
98 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
99 |
WHERE topic_id = ' . $topic_id;
|
|
indvdum@0
|
100 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
101 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
102 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
103 |
}
|
|
indvdum@0
|
104 |
|
|
indvdum@0
|
105 |
if (!$row)
|
|
indvdum@0
|
106 |
{
|
|
indvdum@0
|
107 |
// Setup user environment so we can process lang string
|
|
indvdum@0
|
108 |
$user->setup('viewtopic');
|
|
indvdum@0
|
109 |
|
|
indvdum@0
|
110 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
111 |
}
|
|
indvdum@0
|
112 |
|
|
indvdum@0
|
113 |
$post_id = $row['post_id'];
|
|
indvdum@0
|
114 |
$topic_id = $row['topic_id'];
|
|
indvdum@0
|
115 |
}
|
|
indvdum@0
|
116 |
else if ($view == 'next' || $view == 'previous')
|
|
indvdum@0
|
117 |
{
|
|
indvdum@0
|
118 |
$sql_condition = ($view == 'next') ? '>' : '<';
|
|
indvdum@0
|
119 |
$sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
|
|
indvdum@0
|
120 |
|
|
indvdum@0
|
121 |
$sql = 'SELECT forum_id, topic_last_post_time
|
|
indvdum@0
|
122 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
123 |
WHERE topic_id = ' . $topic_id;
|
|
indvdum@0
|
124 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
125 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
126 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
127 |
|
|
indvdum@0
|
128 |
if (!$row)
|
|
indvdum@0
|
129 |
{
|
|
indvdum@0
|
130 |
$user->setup('viewtopic');
|
|
indvdum@0
|
131 |
// OK, the topic doesn't exist. This error message is not helpful, but technically correct.
|
|
indvdum@0
|
132 |
trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
|
|
indvdum@0
|
133 |
}
|
|
indvdum@0
|
134 |
else
|
|
indvdum@0
|
135 |
{
|
|
indvdum@0
|
136 |
$sql = 'SELECT topic_id, forum_id
|
|
indvdum@0
|
137 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
138 |
WHERE forum_id = ' . $row['forum_id'] . "
|
|
indvdum@0
|
139 |
AND topic_moved_id = 0
|
|
indvdum@0
|
140 |
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
|
|
indvdum@0
|
141 |
" . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
|
|
indvdum@0
|
142 |
ORDER BY topic_last_post_time $sql_ordering";
|
|
indvdum@0
|
143 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
144 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
145 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
146 |
|
|
indvdum@0
|
147 |
if (!$row)
|
|
indvdum@0
|
148 |
{
|
|
indvdum@0
|
149 |
$user->setup('viewtopic');
|
|
indvdum@0
|
150 |
trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
|
|
indvdum@0
|
151 |
}
|
|
indvdum@0
|
152 |
else
|
|
indvdum@0
|
153 |
{
|
|
indvdum@0
|
154 |
$topic_id = $row['topic_id'];
|
|
indvdum@0
|
155 |
|
|
indvdum@0
|
156 |
// Check for global announcement correctness?
|
|
indvdum@0
|
157 |
if (!$row['forum_id'] && !$forum_id)
|
|
indvdum@0
|
158 |
{
|
|
indvdum@0
|
159 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
160 |
}
|
|
indvdum@0
|
161 |
else if ($row['forum_id'])
|
|
indvdum@0
|
162 |
{
|
|
indvdum@0
|
163 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
164 |
}
|
|
indvdum@0
|
165 |
}
|
|
indvdum@0
|
166 |
}
|
|
indvdum@0
|
167 |
}
|
|
indvdum@0
|
168 |
|
|
indvdum@0
|
169 |
// Check for global announcement correctness?
|
|
indvdum@0
|
170 |
if ((!isset($row) || !$row['forum_id']) && !$forum_id)
|
|
indvdum@0
|
171 |
{
|
|
indvdum@0
|
172 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
173 |
}
|
|
indvdum@0
|
174 |
else if (isset($row) && $row['forum_id'])
|
|
indvdum@0
|
175 |
{
|
|
indvdum@0
|
176 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
177 |
}
|
|
indvdum@0
|
178 |
}
|
|
indvdum@0
|
179 |
|
|
indvdum@0
|
180 |
// This rather complex gaggle of code handles querying for topics but
|
|
indvdum@0
|
181 |
// also allows for direct linking to a post (and the calculation of which
|
|
indvdum@0
|
182 |
// page the post is on and the correct display of viewtopic)
|
|
indvdum@0
|
183 |
$sql_array = array(
|
|
indvdum@0
|
184 |
'SELECT' => 't.*, f.*',
|
|
indvdum@0
|
185 |
|
|
indvdum@0
|
186 |
'FROM' => array(FORUMS_TABLE => 'f'),
|
|
indvdum@0
|
187 |
);
|
|
indvdum@0
|
188 |
|
|
indvdum@0
|
189 |
// Firebird handles two columns of the same name a little differently, this
|
|
indvdum@0
|
190 |
// addresses that by forcing the forum_id to come from the forums table.
|
|
indvdum@0
|
191 |
if ($db->sql_layer === 'firebird')
|
|
indvdum@0
|
192 |
{
|
|
indvdum@0
|
193 |
$sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT'];
|
|
indvdum@0
|
194 |
}
|
|
indvdum@0
|
195 |
|
|
indvdum@0
|
196 |
// The FROM-Order is quite important here, else t.* columns can not be correctly bound.
|
|
indvdum@0
|
197 |
if ($post_id)
|
|
indvdum@0
|
198 |
{
|
|
indvdum@0
|
199 |
$sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id';
|
|
indvdum@0
|
200 |
$sql_array['FROM'][POSTS_TABLE] = 'p';
|
|
indvdum@0
|
201 |
}
|
|
indvdum@0
|
202 |
|
|
indvdum@0
|
203 |
// Topics table need to be the last in the chain
|
|
indvdum@0
|
204 |
$sql_array['FROM'][TOPICS_TABLE] = 't';
|
|
indvdum@0
|
205 |
|
|
indvdum@0
|
206 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
207 |
{
|
|
indvdum@0
|
208 |
$sql_array['SELECT'] .= ', tw.notify_status';
|
|
indvdum@0
|
209 |
$sql_array['LEFT_JOIN'] = array();
|
|
indvdum@0
|
210 |
|
|
indvdum@0
|
211 |
$sql_array['LEFT_JOIN'][] = array(
|
|
indvdum@0
|
212 |
'FROM' => array(TOPICS_WATCH_TABLE => 'tw'),
|
|
indvdum@0
|
213 |
'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'
|
|
indvdum@0
|
214 |
);
|
|
indvdum@0
|
215 |
|
|
indvdum@0
|
216 |
if ($config['allow_bookmarks'])
|
|
indvdum@0
|
217 |
{
|
|
indvdum@0
|
218 |
$sql_array['SELECT'] .= ', bm.topic_id as bookmarked';
|
|
indvdum@0
|
219 |
$sql_array['LEFT_JOIN'][] = array(
|
|
indvdum@0
|
220 |
'FROM' => array(BOOKMARKS_TABLE => 'bm'),
|
|
indvdum@0
|
221 |
'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'
|
|
indvdum@0
|
222 |
);
|
|
indvdum@0
|
223 |
}
|
|
indvdum@0
|
224 |
|
|
indvdum@0
|
225 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
226 |
{
|
|
indvdum@0
|
227 |
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
|
|
indvdum@0
|
228 |
|
|
indvdum@0
|
229 |
$sql_array['LEFT_JOIN'][] = array(
|
|
indvdum@0
|
230 |
'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
|
|
indvdum@0
|
231 |
'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
|
|
indvdum@0
|
232 |
);
|
|
indvdum@0
|
233 |
|
|
indvdum@0
|
234 |
$sql_array['LEFT_JOIN'][] = array(
|
|
indvdum@0
|
235 |
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
|
indvdum@0
|
236 |
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
|
|
indvdum@0
|
237 |
);
|
|
indvdum@0
|
238 |
}
|
|
indvdum@0
|
239 |
}
|
|
indvdum@0
|
240 |
|
|
indvdum@0
|
241 |
if (!$post_id)
|
|
indvdum@0
|
242 |
{
|
|
indvdum@0
|
243 |
$sql_array['WHERE'] = "t.topic_id = $topic_id";
|
|
indvdum@0
|
244 |
}
|
|
indvdum@0
|
245 |
else
|
|
indvdum@0
|
246 |
{
|
|
indvdum@0
|
247 |
$sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id";
|
|
indvdum@0
|
248 |
}
|
|
indvdum@0
|
249 |
|
|
indvdum@0
|
250 |
$sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
|
|
indvdum@0
|
251 |
|
|
indvdum@0
|
252 |
if (!$forum_id)
|
|
indvdum@0
|
253 |
{
|
|
indvdum@0
|
254 |
// If it is a global announcement make sure to set the forum id to a postable forum
|
|
indvdum@0
|
255 |
$sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '
|
|
indvdum@0
|
256 |
AND f.forum_type = ' . FORUM_POST . ')';
|
|
indvdum@0
|
257 |
}
|
|
indvdum@0
|
258 |
else
|
|
indvdum@0
|
259 |
{
|
|
indvdum@0
|
260 |
$sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "
|
|
indvdum@0
|
261 |
AND f.forum_id = $forum_id)";
|
|
indvdum@0
|
262 |
}
|
|
indvdum@0
|
263 |
|
|
indvdum@0
|
264 |
$sql_array['WHERE'] .= ')';
|
|
indvdum@0
|
265 |
|
|
indvdum@0
|
266 |
// Join to forum table on topic forum_id unless topic forum_id is zero
|
|
indvdum@0
|
267 |
// whereupon we join on the forum_id passed as a parameter ... this
|
|
indvdum@0
|
268 |
// is done so navigation, forum name, etc. remain consistent with where
|
|
indvdum@0
|
269 |
// user clicked to view a global topic
|
|
indvdum@0
|
270 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
indvdum@0
|
271 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
272 |
$topic_data = $db->sql_fetchrow($result);
|
|
indvdum@0
|
273 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
274 |
|
|
indvdum@0
|
275 |
// link to unapproved post or incorrect link
|
|
indvdum@0
|
276 |
if (!$topic_data)
|
|
indvdum@0
|
277 |
{
|
|
indvdum@0
|
278 |
// If post_id was submitted, we try at least to display the topic as a last resort...
|
|
indvdum@0
|
279 |
if ($post_id && $topic_id)
|
|
indvdum@0
|
280 |
{
|
|
indvdum@0
|
281 |
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : '')));
|
|
indvdum@0
|
282 |
}
|
|
indvdum@0
|
283 |
|
|
indvdum@0
|
284 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
285 |
}
|
|
indvdum@0
|
286 |
|
|
indvdum@0
|
287 |
$forum_id = (int) $topic_data['forum_id'];
|
|
indvdum@0
|
288 |
// This is for determining where we are (page)
|
|
indvdum@0
|
289 |
if ($post_id)
|
|
indvdum@0
|
290 |
{
|
|
indvdum@0
|
291 |
// are we where we are supposed to be?
|
|
indvdum@0
|
292 |
if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id']))
|
|
indvdum@0
|
293 |
{
|
|
indvdum@0
|
294 |
// If post_id was submitted, we try at least to display the topic as a last resort...
|
|
indvdum@0
|
295 |
if ($topic_id)
|
|
indvdum@0
|
296 |
{
|
|
indvdum@0
|
297 |
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id" . (($forum_id) ? "&f=$forum_id" : '')));
|
|
indvdum@0
|
298 |
}
|
|
indvdum@0
|
299 |
|
|
indvdum@0
|
300 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
301 |
}
|
|
indvdum@0
|
302 |
if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
|
|
indvdum@0
|
303 |
{
|
|
indvdum@0
|
304 |
$check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
|
|
indvdum@0
|
305 |
|
|
indvdum@0
|
306 |
if ($sort_dir == $check_sort)
|
|
indvdum@0
|
307 |
{
|
|
indvdum@0
|
308 |
$topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
|
|
indvdum@0
|
309 |
}
|
|
indvdum@0
|
310 |
else
|
|
indvdum@0
|
311 |
{
|
|
indvdum@0
|
312 |
$topic_data['prev_posts'] = 0;
|
|
indvdum@0
|
313 |
}
|
|
indvdum@0
|
314 |
}
|
|
indvdum@0
|
315 |
else
|
|
indvdum@0
|
316 |
{
|
|
indvdum@0
|
317 |
$sql = 'SELECT COUNT(p.post_id) AS prev_posts
|
|
indvdum@0
|
318 |
FROM ' . POSTS_TABLE . " p
|
|
indvdum@0
|
319 |
WHERE p.topic_id = {$topic_data['topic_id']}
|
|
indvdum@0
|
320 |
" . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '');
|
|
indvdum@0
|
321 |
|
|
indvdum@0
|
322 |
if ($sort_dir == 'd')
|
|
indvdum@0
|
323 |
{
|
|
indvdum@0
|
324 |
$sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))";
|
|
indvdum@0
|
325 |
}
|
|
indvdum@0
|
326 |
else
|
|
indvdum@0
|
327 |
{
|
|
indvdum@0
|
328 |
$sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))";
|
|
indvdum@0
|
329 |
}
|
|
indvdum@0
|
330 |
|
|
indvdum@0
|
331 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
332 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
333 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
$topic_data['prev_posts'] = $row['prev_posts'] - 1;
|
|
indvdum@0
|
336 |
}
|
|
indvdum@0
|
337 |
}
|
|
indvdum@0
|
338 |
|
|
indvdum@0
|
339 |
$topic_id = (int) $topic_data['topic_id'];
|
|
indvdum@0
|
340 |
//
|
|
indvdum@0
|
341 |
$topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
|
|
indvdum@0
|
342 |
|
|
indvdum@0
|
343 |
// Check sticky/announcement time limit
|
|
indvdum@0
|
344 |
if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())
|
|
indvdum@0
|
345 |
{
|
|
indvdum@0
|
346 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
indvdum@0
|
347 |
SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0
|
|
indvdum@0
|
348 |
WHERE topic_id = ' . $topic_id;
|
|
indvdum@0
|
349 |
$db->sql_query($sql);
|
|
indvdum@0
|
350 |
|
|
indvdum@0
|
351 |
$topic_data['topic_type'] = POST_NORMAL;
|
|
indvdum@0
|
352 |
$topic_data['topic_time_limit'] = 0;
|
|
indvdum@0
|
353 |
}
|
|
indvdum@0
|
354 |
|
|
indvdum@0
|
355 |
// Setup look and feel
|
|
indvdum@0
|
356 |
$user->setup('viewtopic', $topic_data['forum_style']);
|
|
indvdum@0
|
357 |
|
|
indvdum@0
|
358 |
if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))
|
|
indvdum@0
|
359 |
{
|
|
indvdum@0
|
360 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
361 |
}
|
|
indvdum@0
|
362 |
|
|
indvdum@0
|
363 |
// Start auth check
|
|
indvdum@0
|
364 |
if (!$auth->acl_get('f_read', $forum_id))
|
|
indvdum@0
|
365 |
{
|
|
indvdum@0
|
366 |
if ($user->data['user_id'] != ANONYMOUS)
|
|
indvdum@0
|
367 |
{
|
|
indvdum@0
|
368 |
trigger_error('SORRY_AUTH_READ');
|
|
indvdum@0
|
369 |
}
|
|
indvdum@0
|
370 |
|
|
indvdum@0
|
371 |
login_box('', $user->lang['LOGIN_VIEWFORUM']);
|
|
indvdum@0
|
372 |
}
|
|
indvdum@0
|
373 |
|
|
indvdum@0
|
374 |
// Forum is passworded ... check whether access has been granted to this
|
|
indvdum@0
|
375 |
// user this session, if not show login box
|
|
indvdum@0
|
376 |
if ($topic_data['forum_password'])
|
|
indvdum@0
|
377 |
{
|
|
indvdum@0
|
378 |
login_forum_box($topic_data);
|
|
indvdum@0
|
379 |
}
|
|
indvdum@0
|
380 |
|
|
indvdum@0
|
381 |
// Redirect to login or to the correct post upon emailed notification links
|
|
indvdum@0
|
382 |
if (isset($_GET['e']))
|
|
indvdum@0
|
383 |
{
|
|
indvdum@0
|
384 |
$jump_to = request_var('e', 0);
|
|
indvdum@0
|
385 |
|
|
indvdum@0
|
386 |
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
|
|
indvdum@0
|
387 |
|
|
indvdum@0
|
388 |
if ($user->data['user_id'] == ANONYMOUS)
|
|
indvdum@0
|
389 |
{
|
|
indvdum@0
|
390 |
login_box($redirect_url . "&p=$post_id&e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']);
|
|
indvdum@0
|
391 |
}
|
|
indvdum@0
|
392 |
|
|
indvdum@0
|
393 |
if ($jump_to > 0)
|
|
indvdum@0
|
394 |
{
|
|
indvdum@0
|
395 |
// We direct the already logged in user to the correct post...
|
|
indvdum@0
|
396 |
redirect($redirect_url . ((!$post_id) ? "&p=$jump_to" : "&p=$post_id") . "#p$jump_to");
|
|
indvdum@0
|
397 |
}
|
|
indvdum@0
|
398 |
}
|
|
indvdum@0
|
399 |
|
|
indvdum@0
|
400 |
// What is start equal to?
|
|
indvdum@0
|
401 |
if ($post_id)
|
|
indvdum@0
|
402 |
{
|
|
indvdum@0
|
403 |
$start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page'];
|
|
indvdum@0
|
404 |
}
|
|
indvdum@0
|
405 |
|
|
indvdum@0
|
406 |
// Get topic tracking info
|
|
indvdum@0
|
407 |
if (!isset($topic_tracking_info))
|
|
indvdum@0
|
408 |
{
|
|
indvdum@0
|
409 |
$topic_tracking_info = array();
|
|
indvdum@0
|
410 |
|
|
indvdum@0
|
411 |
// Get topic tracking info
|
|
indvdum@0
|
412 |
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
|
indvdum@0
|
413 |
{
|
|
indvdum@0
|
414 |
$tmp_topic_data = array($topic_id => $topic_data);
|
|
indvdum@0
|
415 |
$topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));
|
|
indvdum@0
|
416 |
unset($tmp_topic_data);
|
|
indvdum@0
|
417 |
}
|
|
indvdum@0
|
418 |
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
|
indvdum@0
|
419 |
{
|
|
indvdum@0
|
420 |
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
|
|
indvdum@0
|
421 |
}
|
|
indvdum@0
|
422 |
}
|
|
indvdum@0
|
423 |
|
|
indvdum@0
|
424 |
// Post ordering options
|
|
indvdum@0
|
425 |
$limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
|
indvdum@0
|
426 |
|
|
indvdum@0
|
427 |
$sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
|
|
indvdum@0
|
428 |
$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
|
|
indvdum@0
|
429 |
$join_user_sql = array('a' => true, 't' => false, 's' => false);
|
|
indvdum@0
|
430 |
|
|
indvdum@0
|
431 |
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
|
indvdum@0
|
432 |
|
|
indvdum@0
|
433 |
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
|
|
indvdum@0
|
434 |
|
|
indvdum@0
|
435 |
// Obtain correct post count and ordering SQL if user has
|
|
indvdum@0
|
436 |
// requested anything different
|
|
indvdum@0
|
437 |
if ($sort_days)
|
|
indvdum@0
|
438 |
{
|
|
indvdum@0
|
439 |
$min_post_time = time() - ($sort_days * 86400);
|
|
indvdum@0
|
440 |
|
|
indvdum@0
|
441 |
$sql = 'SELECT COUNT(post_id) AS num_posts
|
|
indvdum@0
|
442 |
FROM ' . POSTS_TABLE . "
|
|
indvdum@0
|
443 |
WHERE topic_id = $topic_id
|
|
indvdum@0
|
444 |
AND post_time >= $min_post_time
|
|
indvdum@0
|
445 |
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');
|
|
indvdum@0
|
446 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
447 |
$total_posts = (int) $db->sql_fetchfield('num_posts');
|
|
indvdum@0
|
448 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
449 |
|
|
indvdum@0
|
450 |
$limit_posts_time = "AND p.post_time >= $min_post_time ";
|
|
indvdum@0
|
451 |
|
|
indvdum@0
|
452 |
if (isset($_POST['sort']))
|
|
indvdum@0
|
453 |
{
|
|
indvdum@0
|
454 |
$start = 0;
|
|
indvdum@0
|
455 |
}
|
|
indvdum@0
|
456 |
}
|
|
indvdum@0
|
457 |
else
|
|
indvdum@0
|
458 |
{
|
|
indvdum@0
|
459 |
$total_posts = $topic_replies + 1;
|
|
indvdum@0
|
460 |
$limit_posts_time = '';
|
|
indvdum@0
|
461 |
}
|
|
indvdum@0
|
462 |
|
|
indvdum@0
|
463 |
// Was a highlight request part of the URI?
|
|
indvdum@0
|
464 |
$highlight_match = $highlight = '';
|
|
indvdum@0
|
465 |
if ($hilit_words)
|
|
indvdum@0
|
466 |
{
|
|
indvdum@0
|
467 |
foreach (explode(' ', trim($hilit_words)) as $word)
|
|
indvdum@0
|
468 |
{
|
|
indvdum@0
|
469 |
if (trim($word))
|
|
indvdum@0
|
470 |
{
|
|
indvdum@0
|
471 |
$word = str_replace('\*', '\w+?', preg_quote($word, '#'));
|
|
indvdum@0
|
472 |
$word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
|
|
indvdum@0
|
473 |
$highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
|
|
indvdum@0
|
474 |
}
|
|
indvdum@0
|
475 |
}
|
|
indvdum@0
|
476 |
|
|
indvdum@0
|
477 |
$highlight = urlencode($hilit_words);
|
|
indvdum@0
|
478 |
}
|
|
indvdum@0
|
479 |
|
|
indvdum@0
|
480 |
// Make sure $start is set to the last page if it exceeds the amount
|
|
indvdum@0
|
481 |
if ($start < 0 || $start >= $total_posts)
|
|
indvdum@0
|
482 |
{
|
|
indvdum@0
|
483 |
$start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
|
|
indvdum@0
|
484 |
}
|
|
indvdum@0
|
485 |
|
|
indvdum@0
|
486 |
// General Viewtopic URL for return links
|
|
indvdum@0
|
487 |
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : ''));
|
|
indvdum@0
|
488 |
|
|
indvdum@0
|
489 |
// Are we watching this topic?
|
|
indvdum@0
|
490 |
$s_watching_topic = array(
|
|
indvdum@0
|
491 |
'link' => '',
|
|
indvdum@0
|
492 |
'title' => '',
|
|
indvdum@0
|
493 |
'is_watching' => false,
|
|
indvdum@0
|
494 |
);
|
|
indvdum@0
|
495 |
|
|
indvdum@0
|
496 |
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'])
|
|
indvdum@0
|
497 |
{
|
|
indvdum@0
|
498 |
$notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null;
|
|
indvdum@0
|
499 |
watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
|
|
indvdum@0
|
500 |
|
|
indvdum@0
|
501 |
// Reset forum notification if forum notify is set
|
|
indvdum@0
|
502 |
if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
|
|
indvdum@0
|
503 |
{
|
|
indvdum@0
|
504 |
$s_watching_forum = $s_watching_topic;
|
|
indvdum@0
|
505 |
watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
|
|
indvdum@0
|
506 |
}
|
|
indvdum@0
|
507 |
}
|
|
indvdum@0
|
508 |
|
|
indvdum@0
|
509 |
// Bookmarks
|
|
indvdum@0
|
510 |
if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
|
|
indvdum@0
|
511 |
{
|
|
indvdum@0
|
512 |
if (check_link_hash(request_var('hash', ''), "topic_$topic_id"))
|
|
indvdum@0
|
513 |
{
|
|
indvdum@0
|
514 |
if (!$topic_data['bookmarked'])
|
|
indvdum@0
|
515 |
{
|
|
indvdum@0
|
516 |
$sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
|
indvdum@0
|
517 |
'user_id' => $user->data['user_id'],
|
|
indvdum@0
|
518 |
'topic_id' => $topic_id,
|
|
indvdum@0
|
519 |
));
|
|
indvdum@0
|
520 |
$db->sql_query($sql);
|
|
indvdum@0
|
521 |
}
|
|
indvdum@0
|
522 |
else
|
|
indvdum@0
|
523 |
{
|
|
indvdum@0
|
524 |
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "
|
|
indvdum@0
|
525 |
WHERE user_id = {$user->data['user_id']}
|
|
indvdum@0
|
526 |
AND topic_id = $topic_id";
|
|
indvdum@0
|
527 |
$db->sql_query($sql);
|
|
indvdum@0
|
528 |
}
|
|
indvdum@0
|
529 |
$message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
|
|
indvdum@0
|
530 |
}
|
|
indvdum@0
|
531 |
else
|
|
indvdum@0
|
532 |
{
|
|
indvdum@0
|
533 |
$message = $user->lang['BOOKMARK_ERR'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
|
|
indvdum@0
|
534 |
}
|
|
indvdum@0
|
535 |
meta_refresh(3, $viewtopic_url);
|
|
indvdum@0
|
536 |
|
|
indvdum@0
|
537 |
trigger_error($message);
|
|
indvdum@0
|
538 |
}
|
|
indvdum@0
|
539 |
|
|
indvdum@0
|
540 |
// Grab ranks
|
|
indvdum@0
|
541 |
$ranks = $cache->obtain_ranks();
|
|
indvdum@0
|
542 |
|
|
indvdum@0
|
543 |
// Grab icons
|
|
indvdum@0
|
544 |
$icons = $cache->obtain_icons();
|
|
indvdum@0
|
545 |
|
|
indvdum@0
|
546 |
// Grab extensions
|
|
indvdum@0
|
547 |
$extensions = array();
|
|
indvdum@0
|
548 |
if ($topic_data['topic_attachment'])
|
|
indvdum@0
|
549 |
{
|
|
indvdum@0
|
550 |
$extensions = $cache->obtain_attach_extensions($forum_id);
|
|
indvdum@0
|
551 |
}
|
|
indvdum@0
|
552 |
|
|
indvdum@0
|
553 |
// Forum rules listing
|
|
indvdum@0
|
554 |
$s_forum_rules = '';
|
|
indvdum@0
|
555 |
gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);
|
|
indvdum@0
|
556 |
|
|
indvdum@0
|
557 |
// Quick mod tools
|
|
indvdum@0
|
558 |
$allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;
|
|
indvdum@0
|
559 |
|
|
indvdum@0
|
560 |
$topic_mod = '';
|
|
indvdum@0
|
561 |
$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';
|
|
indvdum@0
|
562 |
$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
|
|
indvdum@0
|
563 |
$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';
|
|
indvdum@0
|
564 |
$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';
|
|
indvdum@0
|
565 |
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';
|
|
indvdum@0
|
566 |
$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';
|
|
indvdum@0
|
567 |
$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';
|
|
indvdum@0
|
568 |
$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';
|
|
indvdum@0
|
569 |
$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
|
|
indvdum@0
|
570 |
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
|
|
indvdum@0
|
571 |
$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
|
|
indvdum@0
|
572 |
$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
|
|
indvdum@0
|
573 |
|
|
indvdum@0
|
574 |
// If we've got a hightlight set pass it on to pagination.
|
|
indvdum@0
|
575 |
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
|
|
indvdum@0
|
576 |
|
|
indvdum@0
|
577 |
// Navigation links
|
|
indvdum@0
|
578 |
generate_forum_nav($topic_data);
|
|
indvdum@0
|
579 |
|
|
indvdum@0
|
580 |
// Forum Rules
|
|
indvdum@0
|
581 |
generate_forum_rules($topic_data);
|
|
indvdum@0
|
582 |
|
|
indvdum@0
|
583 |
// Moderators
|
|
indvdum@0
|
584 |
$forum_moderators = array();
|
|
indvdum@0
|
585 |
if ($config['load_moderators'])
|
|
indvdum@0
|
586 |
{
|
|
indvdum@0
|
587 |
get_moderators($forum_moderators, $forum_id);
|
|
indvdum@0
|
588 |
}
|
|
indvdum@0
|
589 |
|
|
indvdum@0
|
590 |
// This is only used for print view so ...
|
|
indvdum@0
|
591 |
$server_path = (!$view) ? $phpbb_root_path : generate_board_url() . '/';
|
|
indvdum@0
|
592 |
|
|
indvdum@0
|
593 |
// Replace naughty words in title
|
|
indvdum@0
|
594 |
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);
|
|
indvdum@0
|
595 |
|
|
indvdum@0
|
596 |
$s_search_hidden_fields = array(
|
|
indvdum@0
|
597 |
't' => $topic_id,
|
|
indvdum@0
|
598 |
'sf' => 'msgonly',
|
|
indvdum@0
|
599 |
);
|
|
indvdum@0
|
600 |
if ($_SID)
|
|
indvdum@0
|
601 |
{
|
|
indvdum@0
|
602 |
$s_search_hidden_fields['sid'] = $_SID;
|
|
indvdum@0
|
603 |
}
|
|
indvdum@0
|
604 |
|
|
indvdum@0
|
605 |
if (!empty($_EXTRA_URL))
|
|
indvdum@0
|
606 |
{
|
|
indvdum@0
|
607 |
foreach ($_EXTRA_URL as $url_param)
|
|
indvdum@0
|
608 |
{
|
|
indvdum@0
|
609 |
$url_param = explode('=', $url_param, 2);
|
|
indvdum@0
|
610 |
$s_hidden_fields[$url_param[0]] = $url_param[1];
|
|
indvdum@0
|
611 |
}
|
|
indvdum@0
|
612 |
}
|
|
indvdum@0
|
613 |
|
|
indvdum@0
|
614 |
// Send vars to template
|
|
indvdum@0
|
615 |
$template->assign_vars(array(
|
|
indvdum@0
|
616 |
'FORUM_ID' => $forum_id,
|
|
indvdum@0
|
617 |
'FORUM_NAME' => $topic_data['forum_name'],
|
|
indvdum@0
|
618 |
'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']),
|
|
indvdum@0
|
619 |
'TOPIC_ID' => $topic_id,
|
|
indvdum@0
|
620 |
'TOPIC_TITLE' => $topic_data['topic_title'],
|
|
indvdum@0
|
621 |
'TOPIC_POSTER' => $topic_data['topic_poster'],
|
|
indvdum@0
|
622 |
|
|
indvdum@0
|
623 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
|
|
indvdum@0
|
624 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
|
|
indvdum@0
|
625 |
'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
|
|
indvdum@0
|
626 |
|
|
indvdum@0
|
627 |
'PAGINATION' => $pagination,
|
|
indvdum@0
|
628 |
'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start),
|
|
indvdum@0
|
629 |
'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
|
|
indvdum@0
|
630 |
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '',
|
|
indvdum@0
|
631 |
'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
|
|
indvdum@0
|
632 |
|
|
indvdum@0
|
633 |
'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
|
|
indvdum@0
|
634 |
'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
|
|
indvdum@0
|
635 |
'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'),
|
|
indvdum@0
|
636 |
'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'),
|
|
indvdum@0
|
637 |
'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'),
|
|
indvdum@0
|
638 |
'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'),
|
|
indvdum@0
|
639 |
'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'),
|
|
indvdum@0
|
640 |
'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),
|
|
indvdum@0
|
641 |
'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
|
|
indvdum@0
|
642 |
'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'),
|
|
indvdum@0
|
643 |
'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
|
|
indvdum@0
|
644 |
'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'),
|
|
indvdum@0
|
645 |
'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'),
|
|
indvdum@0
|
646 |
'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'),
|
|
indvdum@0
|
647 |
'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'),
|
|
indvdum@0
|
648 |
'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') ,
|
|
indvdum@0
|
649 |
'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'),
|
|
indvdum@0
|
650 |
'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
|
|
indvdum@0
|
651 |
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
|
|
indvdum@0
|
652 |
'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'),
|
|
indvdum@0
|
653 |
|
|
indvdum@0
|
654 |
'S_IS_LOCKED' => ($topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED) ? false : true,
|
|
indvdum@0
|
655 |
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
|
indvdum@0
|
656 |
'S_SELECT_SORT_KEY' => $s_sort_key,
|
|
indvdum@0
|
657 |
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
|
indvdum@0
|
658 |
'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
|
|
indvdum@0
|
659 |
'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")),
|
|
indvdum@0
|
660 |
'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
|
|
indvdum@0
|
661 |
'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id),
|
|
indvdum@0
|
662 |
|
|
indvdum@0
|
663 |
'S_VIEWTOPIC' => true,
|
|
indvdum@0
|
664 |
'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
|
|
indvdum@0
|
665 |
'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx"),
|
|
indvdum@0
|
666 |
'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields),
|
|
indvdum@0
|
667 |
|
|
indvdum@0
|
668 |
'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
|
|
indvdum@0
|
669 |
'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
|
|
indvdum@0
|
670 |
'S_ENABLE_FEEDS_TOPIC' => ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,
|
|
indvdum@0
|
671 |
|
|
indvdum@0
|
672 |
'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id",
|
|
indvdum@0
|
673 |
'U_FORUM' => $server_path,
|
|
indvdum@0
|
674 |
'U_VIEW_TOPIC' => $viewtopic_url,
|
|
indvdum@0
|
675 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
|
indvdum@0
|
676 |
'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=previous"),
|
|
indvdum@0
|
677 |
'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=next"),
|
|
indvdum@0
|
678 |
'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&view=print' : '',
|
|
indvdum@0
|
679 |
'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") : '',
|
|
indvdum@0
|
680 |
|
|
indvdum@0
|
681 |
'U_WATCH_TOPIC' => $s_watching_topic['link'],
|
|
indvdum@0
|
682 |
'L_WATCH_TOPIC' => $s_watching_topic['title'],
|
|
indvdum@0
|
683 |
'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'],
|
|
indvdum@0
|
684 |
|
|
indvdum@0
|
685 |
'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") : '',
|
|
indvdum@0
|
686 |
'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],
|
|
indvdum@0
|
687 |
|
|
indvdum@0
|
688 |
'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=post&f=$forum_id") : '',
|
|
indvdum@0
|
689 |
'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id") : '',
|
|
indvdum@0
|
690 |
'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) : '')
|
|
indvdum@0
|
691 |
);
|
|
indvdum@0
|
692 |
|
|
indvdum@0
|
693 |
// Does this topic contain a poll?
|
|
indvdum@0
|
694 |
if (!empty($topic_data['poll_start']))
|
|
indvdum@0
|
695 |
{
|
|
indvdum@0
|
696 |
$sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
|
|
indvdum@0
|
697 |
FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p
|
|
indvdum@0
|
698 |
WHERE o.topic_id = $topic_id
|
|
indvdum@0
|
699 |
AND p.post_id = {$topic_data['topic_first_post_id']}
|
|
indvdum@0
|
700 |
AND p.topic_id = o.topic_id
|
|
indvdum@0
|
701 |
ORDER BY o.poll_option_id";
|
|
indvdum@0
|
702 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
703 |
|
|
indvdum@0
|
704 |
$poll_info = array();
|
|
indvdum@0
|
705 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
706 |
{
|
|
indvdum@0
|
707 |
$poll_info[] = $row;
|
|
indvdum@0
|
708 |
}
|
|
indvdum@0
|
709 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
710 |
|
|
indvdum@0
|
711 |
$cur_voted_id = array();
|
|
indvdum@0
|
712 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
713 |
{
|
|
indvdum@0
|
714 |
$sql = 'SELECT poll_option_id
|
|
indvdum@0
|
715 |
FROM ' . POLL_VOTES_TABLE . '
|
|
indvdum@0
|
716 |
WHERE topic_id = ' . $topic_id . '
|
|
indvdum@0
|
717 |
AND vote_user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
718 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
719 |
|
|
indvdum@0
|
720 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
721 |
{
|
|
indvdum@0
|
722 |
$cur_voted_id[] = $row['poll_option_id'];
|
|
indvdum@0
|
723 |
}
|
|
indvdum@0
|
724 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
725 |
}
|
|
indvdum@0
|
726 |
else
|
|
indvdum@0
|
727 |
{
|
|
indvdum@0
|
728 |
// Cookie based guest tracking ... I don't like this but hum ho
|
|
indvdum@0
|
729 |
// it's oft requested. This relies on "nice" users who don't feel
|
|
indvdum@0
|
730 |
// the need to delete cookies to mess with results.
|
|
indvdum@0
|
731 |
if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
|
|
indvdum@0
|
732 |
{
|
|
indvdum@0
|
733 |
$cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);
|
|
indvdum@0
|
734 |
$cur_voted_id = array_map('intval', $cur_voted_id);
|
|
indvdum@0
|
735 |
}
|
|
indvdum@0
|
736 |
}
|
|
indvdum@0
|
737 |
|
|
indvdum@0
|
738 |
// Can not vote at all if no vote permission
|
|
indvdum@0
|
739 |
$s_can_vote = ($auth->acl_get('f_vote', $forum_id) &&
|
|
indvdum@0
|
740 |
(($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
|
|
indvdum@0
|
741 |
$topic_data['topic_status'] != ITEM_LOCKED &&
|
|
indvdum@0
|
742 |
$topic_data['forum_status'] != ITEM_LOCKED &&
|
|
indvdum@0
|
743 |
(!sizeof($cur_voted_id) ||
|
|
indvdum@0
|
744 |
($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change']))) ? true : false;
|
|
indvdum@0
|
745 |
$s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
|
|
indvdum@0
|
746 |
|
|
indvdum@0
|
747 |
if ($update && $s_can_vote)
|
|
indvdum@0
|
748 |
{
|
|
indvdum@0
|
749 |
|
|
indvdum@0
|
750 |
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting'))
|
|
indvdum@0
|
751 |
{
|
|
indvdum@0
|
752 |
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start"));
|
|
indvdum@0
|
753 |
|
|
indvdum@0
|
754 |
meta_refresh(5, $redirect_url);
|
|
indvdum@0
|
755 |
if (!sizeof($voted_id))
|
|
indvdum@0
|
756 |
{
|
|
indvdum@0
|
757 |
$message = 'NO_VOTE_OPTION';
|
|
indvdum@0
|
758 |
}
|
|
indvdum@0
|
759 |
else if (sizeof($voted_id) > $topic_data['poll_max_options'])
|
|
indvdum@0
|
760 |
{
|
|
indvdum@0
|
761 |
$message = 'TOO_MANY_VOTE_OPTIONS';
|
|
indvdum@0
|
762 |
}
|
|
indvdum@0
|
763 |
else if (in_array(VOTE_CONVERTED, $cur_voted_id))
|
|
indvdum@0
|
764 |
{
|
|
indvdum@0
|
765 |
$message = 'VOTE_CONVERTED';
|
|
indvdum@0
|
766 |
}
|
|
indvdum@0
|
767 |
else
|
|
indvdum@0
|
768 |
{
|
|
indvdum@0
|
769 |
$message = 'FORM_INVALID';
|
|
indvdum@0
|
770 |
}
|
|
indvdum@0
|
771 |
|
|
indvdum@0
|
772 |
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
773 |
trigger_error($message);
|
|
indvdum@0
|
774 |
}
|
|
indvdum@0
|
775 |
|
|
indvdum@0
|
776 |
foreach ($voted_id as $option)
|
|
indvdum@0
|
777 |
{
|
|
indvdum@0
|
778 |
if (in_array($option, $cur_voted_id))
|
|
indvdum@0
|
779 |
{
|
|
indvdum@0
|
780 |
continue;
|
|
indvdum@0
|
781 |
}
|
|
indvdum@0
|
782 |
|
|
indvdum@0
|
783 |
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
|
|
indvdum@0
|
784 |
SET poll_option_total = poll_option_total + 1
|
|
indvdum@0
|
785 |
WHERE poll_option_id = ' . (int) $option . '
|
|
indvdum@0
|
786 |
AND topic_id = ' . (int) $topic_id;
|
|
indvdum@0
|
787 |
$db->sql_query($sql);
|
|
indvdum@0
|
788 |
|
|
indvdum@0
|
789 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
790 |
{
|
|
indvdum@0
|
791 |
$sql_ary = array(
|
|
indvdum@0
|
792 |
'topic_id' => (int) $topic_id,
|
|
indvdum@0
|
793 |
'poll_option_id' => (int) $option,
|
|
indvdum@0
|
794 |
'vote_user_id' => (int) $user->data['user_id'],
|
|
indvdum@0
|
795 |
'vote_user_ip' => (string) $user->ip,
|
|
indvdum@0
|
796 |
);
|
|
indvdum@0
|
797 |
|
|
indvdum@0
|
798 |
$sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
|
indvdum@0
|
799 |
$db->sql_query($sql);
|
|
indvdum@0
|
800 |
}
|
|
indvdum@0
|
801 |
}
|
|
indvdum@0
|
802 |
|
|
indvdum@0
|
803 |
foreach ($cur_voted_id as $option)
|
|
indvdum@0
|
804 |
{
|
|
indvdum@0
|
805 |
if (!in_array($option, $voted_id))
|
|
indvdum@0
|
806 |
{
|
|
indvdum@0
|
807 |
$sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
|
|
indvdum@0
|
808 |
SET poll_option_total = poll_option_total - 1
|
|
indvdum@0
|
809 |
WHERE poll_option_id = ' . (int) $option . '
|
|
indvdum@0
|
810 |
AND topic_id = ' . (int) $topic_id;
|
|
indvdum@0
|
811 |
$db->sql_query($sql);
|
|
indvdum@0
|
812 |
|
|
indvdum@0
|
813 |
if ($user->data['is_registered'])
|
|
indvdum@0
|
814 |
{
|
|
indvdum@0
|
815 |
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
|
|
indvdum@0
|
816 |
WHERE topic_id = ' . (int) $topic_id . '
|
|
indvdum@0
|
817 |
AND poll_option_id = ' . (int) $option . '
|
|
indvdum@0
|
818 |
AND vote_user_id = ' . (int) $user->data['user_id'];
|
|
indvdum@0
|
819 |
$db->sql_query($sql);
|
|
indvdum@0
|
820 |
}
|
|
indvdum@0
|
821 |
}
|
|
indvdum@0
|
822 |
}
|
|
indvdum@0
|
823 |
|
|
indvdum@0
|
824 |
if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
|
|
indvdum@0
|
825 |
{
|
|
indvdum@0
|
826 |
$user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);
|
|
indvdum@0
|
827 |
}
|
|
indvdum@0
|
828 |
|
|
indvdum@0
|
829 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
indvdum@0
|
830 |
SET poll_last_vote = ' . time() . "
|
|
indvdum@0
|
831 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
832 |
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
|
|
indvdum@0
|
833 |
$db->sql_query($sql);
|
|
indvdum@0
|
834 |
|
|
indvdum@0
|
835 |
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start"));
|
|
indvdum@0
|
836 |
|
|
indvdum@0
|
837 |
meta_refresh(5, $redirect_url);
|
|
indvdum@0
|
838 |
trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
|
|
indvdum@0
|
839 |
}
|
|
indvdum@0
|
840 |
|
|
indvdum@0
|
841 |
$poll_total = 0;
|
|
indvdum@0
|
842 |
foreach ($poll_info as $poll_option)
|
|
indvdum@0
|
843 |
{
|
|
indvdum@0
|
844 |
$poll_total += $poll_option['poll_option_total'];
|
|
indvdum@0
|
845 |
}
|
|
indvdum@0
|
846 |
|
|
indvdum@0
|
847 |
if ($poll_info[0]['bbcode_bitfield'])
|
|
indvdum@0
|
848 |
{
|
|
indvdum@0
|
849 |
$poll_bbcode = new bbcode();
|
|
indvdum@0
|
850 |
}
|
|
indvdum@0
|
851 |
else
|
|
indvdum@0
|
852 |
{
|
|
indvdum@0
|
853 |
$poll_bbcode = false;
|
|
indvdum@0
|
854 |
}
|
|
indvdum@0
|
855 |
|
|
indvdum@0
|
856 |
for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
|
|
indvdum@0
|
857 |
{
|
|
indvdum@0
|
858 |
$poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);
|
|
indvdum@0
|
859 |
|
|
indvdum@0
|
860 |
if ($poll_bbcode !== false)
|
|
indvdum@0
|
861 |
{
|
|
indvdum@0
|
862 |
$poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);
|
|
indvdum@0
|
863 |
}
|
|
indvdum@0
|
864 |
|
|
indvdum@0
|
865 |
$poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']);
|
|
indvdum@0
|
866 |
$poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);
|
|
indvdum@0
|
867 |
}
|
|
indvdum@0
|
868 |
|
|
indvdum@0
|
869 |
$topic_data['poll_title'] = censor_text($topic_data['poll_title']);
|
|
indvdum@0
|
870 |
|
|
indvdum@0
|
871 |
if ($poll_bbcode !== false)
|
|
indvdum@0
|
872 |
{
|
|
indvdum@0
|
873 |
$poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);
|
|
indvdum@0
|
874 |
}
|
|
indvdum@0
|
875 |
|
|
indvdum@0
|
876 |
$topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']);
|
|
indvdum@0
|
877 |
$topic_data['poll_title'] = smiley_text($topic_data['poll_title']);
|
|
indvdum@0
|
878 |
|
|
indvdum@0
|
879 |
unset($poll_bbcode);
|
|
indvdum@0
|
880 |
|
|
indvdum@0
|
881 |
foreach ($poll_info as $poll_option)
|
|
indvdum@0
|
882 |
{
|
|
indvdum@0
|
883 |
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
|
|
indvdum@0
|
884 |
$option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
|
|
indvdum@0
|
885 |
|
|
indvdum@0
|
886 |
$template->assign_block_vars('poll_option', array(
|
|
indvdum@0
|
887 |
'POLL_OPTION_ID' => $poll_option['poll_option_id'],
|
|
indvdum@0
|
888 |
'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
|
|
indvdum@0
|
889 |
'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
|
|
indvdum@0
|
890 |
'POLL_OPTION_PERCENT' => $option_pct_txt,
|
|
indvdum@0
|
891 |
'POLL_OPTION_PCT' => round($option_pct * 100),
|
|
indvdum@0
|
892 |
'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)),
|
|
indvdum@0
|
893 |
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
|
|
indvdum@0
|
894 |
);
|
|
indvdum@0
|
895 |
}
|
|
indvdum@0
|
896 |
|
|
indvdum@0
|
897 |
$poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
|
|
indvdum@0
|
898 |
|
|
indvdum@0
|
899 |
$template->assign_vars(array(
|
|
indvdum@0
|
900 |
'POLL_QUESTION' => $topic_data['poll_title'],
|
|
indvdum@0
|
901 |
'TOTAL_VOTES' => $poll_total,
|
|
indvdum@0
|
902 |
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
|
|
indvdum@0
|
903 |
'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),
|
|
indvdum@0
|
904 |
|
|
indvdum@0
|
905 |
'L_MAX_VOTES' => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']),
|
|
indvdum@0
|
906 |
'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',
|
|
indvdum@0
|
907 |
|
|
indvdum@0
|
908 |
'S_HAS_POLL' => true,
|
|
indvdum@0
|
909 |
'S_CAN_VOTE' => $s_can_vote,
|
|
indvdum@0
|
910 |
'S_DISPLAY_RESULTS' => $s_display_results,
|
|
indvdum@0
|
911 |
'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false,
|
|
indvdum@0
|
912 |
'S_POLL_ACTION' => $viewtopic_url,
|
|
indvdum@0
|
913 |
|
|
indvdum@0
|
914 |
'U_VIEW_RESULTS' => $viewtopic_url . '&view=viewpoll')
|
|
indvdum@0
|
915 |
);
|
|
indvdum@0
|
916 |
|
|
indvdum@0
|
917 |
unset($poll_end, $poll_info, $voted_id);
|
|
indvdum@0
|
918 |
}
|
|
indvdum@0
|
919 |
|
|
indvdum@0
|
920 |
// If the user is trying to reach the second half of the topic, fetch it starting from the end
|
|
indvdum@0
|
921 |
$store_reverse = false;
|
|
indvdum@0
|
922 |
$sql_limit = $config['posts_per_page'];
|
|
indvdum@0
|
923 |
$sql_sort_order = $direction = '';
|
|
indvdum@0
|
924 |
|
|
indvdum@0
|
925 |
if ($start > $total_posts / 2)
|
|
indvdum@0
|
926 |
{
|
|
indvdum@0
|
927 |
$store_reverse = true;
|
|
indvdum@0
|
928 |
|
|
indvdum@0
|
929 |
if ($start + $config['posts_per_page'] > $total_posts)
|
|
indvdum@0
|
930 |
{
|
|
indvdum@0
|
931 |
$sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start));
|
|
indvdum@0
|
932 |
}
|
|
indvdum@0
|
933 |
|
|
indvdum@0
|
934 |
// Select the sort order
|
|
indvdum@0
|
935 |
$direction = (($sort_dir == 'd') ? 'ASC' : 'DESC');
|
|
indvdum@0
|
936 |
$sql_start = max(0, $total_posts - $sql_limit - $start);
|
|
indvdum@0
|
937 |
}
|
|
indvdum@0
|
938 |
else
|
|
indvdum@0
|
939 |
{
|
|
indvdum@0
|
940 |
// Select the sort order
|
|
indvdum@0
|
941 |
$direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
|
indvdum@0
|
942 |
$sql_start = $start;
|
|
indvdum@0
|
943 |
}
|
|
indvdum@0
|
944 |
|
|
indvdum@0
|
945 |
if (is_array($sort_by_sql[$sort_key]))
|
|
indvdum@0
|
946 |
{
|
|
indvdum@0
|
947 |
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
|
|
indvdum@0
|
948 |
}
|
|
indvdum@0
|
949 |
else
|
|
indvdum@0
|
950 |
{
|
|
indvdum@0
|
951 |
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
|
|
indvdum@0
|
952 |
}
|
|
indvdum@0
|
953 |
|
|
indvdum@0
|
954 |
// Container for user details, only process once
|
|
indvdum@0
|
955 |
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();
|
|
indvdum@0
|
956 |
$has_attachments = $display_notice = false;
|
|
indvdum@0
|
957 |
$bbcode_bitfield = '';
|
|
indvdum@0
|
958 |
$i = $i_total = 0;
|
|
indvdum@0
|
959 |
|
|
indvdum@0
|
960 |
// Go ahead and pull all data for this topic
|
|
indvdum@0
|
961 |
$sql = 'SELECT p.post_id
|
|
indvdum@0
|
962 |
FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
|
indvdum@0
|
963 |
WHERE p.topic_id = $topic_id
|
|
indvdum@0
|
964 |
" . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
|
|
indvdum@0
|
965 |
" . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
|
indvdum@0
|
966 |
$limit_posts_time
|
|
indvdum@0
|
967 |
ORDER BY $sql_sort_order";
|
|
indvdum@0
|
968 |
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
|
|
indvdum@0
|
969 |
|
|
indvdum@0
|
970 |
$i = ($store_reverse) ? $sql_limit - 1 : 0;
|
|
indvdum@0
|
971 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
972 |
{
|
|
indvdum@0
|
973 |
$post_list[$i] = (int) $row['post_id'];
|
|
indvdum@0
|
974 |
($store_reverse) ? $i-- : $i++;
|
|
indvdum@0
|
975 |
}
|
|
indvdum@0
|
976 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
977 |
|
|
indvdum@0
|
978 |
if (!sizeof($post_list))
|
|
indvdum@0
|
979 |
{
|
|
indvdum@0
|
980 |
if ($sort_days)
|
|
indvdum@0
|
981 |
{
|
|
indvdum@0
|
982 |
trigger_error('NO_POSTS_TIME_FRAME');
|
|
indvdum@0
|
983 |
}
|
|
indvdum@0
|
984 |
else
|
|
indvdum@0
|
985 |
{
|
|
indvdum@0
|
986 |
trigger_error('NO_TOPIC');
|
|
indvdum@0
|
987 |
}
|
|
indvdum@0
|
988 |
}
|
|
indvdum@0
|
989 |
|
|
indvdum@0
|
990 |
// Holding maximum post time for marking topic read
|
|
indvdum@0
|
991 |
// We need to grab it because we do reverse ordering sometimes
|
|
indvdum@0
|
992 |
$max_post_time = 0;
|
|
indvdum@0
|
993 |
|
|
indvdum@0
|
994 |
$sql = $db->sql_build_query('SELECT', array(
|
|
indvdum@0
|
995 |
'SELECT' => 'u.*, z.friend, z.foe, p.*',
|
|
indvdum@0
|
996 |
|
|
indvdum@0
|
997 |
'FROM' => array(
|
|
indvdum@0
|
998 |
USERS_TABLE => 'u',
|
|
indvdum@0
|
999 |
POSTS_TABLE => 'p',
|
|
indvdum@0
|
1000 |
),
|
|
indvdum@0
|
1001 |
|
|
indvdum@0
|
1002 |
'LEFT_JOIN' => array(
|
|
indvdum@0
|
1003 |
array(
|
|
indvdum@0
|
1004 |
'FROM' => array(ZEBRA_TABLE => 'z'),
|
|
indvdum@0
|
1005 |
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
|
|
indvdum@0
|
1006 |
)
|
|
indvdum@0
|
1007 |
),
|
|
indvdum@0
|
1008 |
|
|
indvdum@0
|
1009 |
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
|
|
indvdum@0
|
1010 |
AND u.user_id = p.poster_id'
|
|
indvdum@0
|
1011 |
));
|
|
indvdum@0
|
1012 |
|
|
indvdum@0
|
1013 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1014 |
|
|
indvdum@0
|
1015 |
$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
|
|
indvdum@0
|
1016 |
|
|
indvdum@0
|
1017 |
// Posts are stored in the $rowset array while $attach_list, $user_cache
|
|
indvdum@0
|
1018 |
// and the global bbcode_bitfield are built
|
|
indvdum@0
|
1019 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1020 |
{
|
|
indvdum@0
|
1021 |
// Set max_post_time
|
|
indvdum@0
|
1022 |
if ($row['post_time'] > $max_post_time)
|
|
indvdum@0
|
1023 |
{
|
|
indvdum@0
|
1024 |
$max_post_time = $row['post_time'];
|
|
indvdum@0
|
1025 |
}
|
|
indvdum@0
|
1026 |
|
|
indvdum@0
|
1027 |
$poster_id = (int) $row['poster_id'];
|
|
indvdum@0
|
1028 |
|
|
indvdum@0
|
1029 |
// Does post have an attachment? If so, add it to the list
|
|
indvdum@0
|
1030 |
if ($row['post_attachment'] && $config['allow_attachments'])
|
|
indvdum@0
|
1031 |
{
|
|
indvdum@0
|
1032 |
$attach_list[] = (int) $row['post_id'];
|
|
indvdum@0
|
1033 |
|
|
indvdum@0
|
1034 |
if ($row['post_approved'])
|
|
indvdum@0
|
1035 |
{
|
|
indvdum@0
|
1036 |
$has_attachments = true;
|
|
indvdum@0
|
1037 |
}
|
|
indvdum@0
|
1038 |
}
|
|
indvdum@0
|
1039 |
|
|
indvdum@0
|
1040 |
$rowset[$row['post_id']] = array(
|
|
indvdum@0
|
1041 |
'hide_post' => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false,
|
|
indvdum@0
|
1042 |
|
|
indvdum@0
|
1043 |
'post_id' => $row['post_id'],
|
|
indvdum@0
|
1044 |
'post_time' => $row['post_time'],
|
|
indvdum@0
|
1045 |
'user_id' => $row['user_id'],
|
|
indvdum@0
|
1046 |
'username' => $row['username'],
|
|
indvdum@0
|
1047 |
'user_colour' => $row['user_colour'],
|
|
indvdum@0
|
1048 |
'topic_id' => $row['topic_id'],
|
|
indvdum@0
|
1049 |
'forum_id' => $row['forum_id'],
|
|
indvdum@0
|
1050 |
'post_subject' => $row['post_subject'],
|
|
indvdum@0
|
1051 |
'post_edit_count' => $row['post_edit_count'],
|
|
indvdum@0
|
1052 |
'post_edit_time' => $row['post_edit_time'],
|
|
indvdum@0
|
1053 |
'post_edit_reason' => $row['post_edit_reason'],
|
|
indvdum@0
|
1054 |
'post_edit_user' => $row['post_edit_user'],
|
|
indvdum@0
|
1055 |
'post_edit_locked' => $row['post_edit_locked'],
|
|
indvdum@0
|
1056 |
|
|
indvdum@0
|
1057 |
// Make sure the icon actually exists
|
|
indvdum@0
|
1058 |
'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
|
|
indvdum@0
|
1059 |
'post_attachment' => $row['post_attachment'],
|
|
indvdum@0
|
1060 |
'post_approved' => $row['post_approved'],
|
|
indvdum@0
|
1061 |
'post_reported' => $row['post_reported'],
|
|
indvdum@0
|
1062 |
'post_username' => $row['post_username'],
|
|
indvdum@0
|
1063 |
'post_text' => $row['post_text'],
|
|
indvdum@0
|
1064 |
'bbcode_uid' => $row['bbcode_uid'],
|
|
indvdum@0
|
1065 |
'bbcode_bitfield' => $row['bbcode_bitfield'],
|
|
indvdum@0
|
1066 |
'enable_smilies' => $row['enable_smilies'],
|
|
indvdum@0
|
1067 |
'enable_sig' => $row['enable_sig'],
|
|
indvdum@0
|
1068 |
'friend' => $row['friend'],
|
|
indvdum@0
|
1069 |
'foe' => $row['foe'],
|
|
indvdum@0
|
1070 |
);
|
|
indvdum@0
|
1071 |
|
|
indvdum@0
|
1072 |
// Define the global bbcode bitfield, will be used to load bbcodes
|
|
indvdum@0
|
1073 |
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
|
|
indvdum@0
|
1074 |
|
|
indvdum@0
|
1075 |
// Is a signature attached? Are we going to display it?
|
|
indvdum@0
|
1076 |
if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
|
|
indvdum@0
|
1077 |
{
|
|
indvdum@0
|
1078 |
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
|
|
indvdum@0
|
1079 |
}
|
|
indvdum@0
|
1080 |
|
|
indvdum@0
|
1081 |
// Cache various user specific data ... so we don't have to recompute
|
|
indvdum@0
|
1082 |
// this each time the same user appears on this page
|
|
indvdum@0
|
1083 |
if (!isset($user_cache[$poster_id]))
|
|
indvdum@0
|
1084 |
{
|
|
indvdum@0
|
1085 |
if ($poster_id == ANONYMOUS)
|
|
indvdum@0
|
1086 |
{
|
|
indvdum@0
|
1087 |
$user_cache[$poster_id] = array(
|
|
indvdum@0
|
1088 |
'joined' => '',
|
|
indvdum@0
|
1089 |
'posts' => '',
|
|
indvdum@0
|
1090 |
'from' => '',
|
|
indvdum@0
|
1091 |
|
|
indvdum@0
|
1092 |
'sig' => '',
|
|
indvdum@0
|
1093 |
'sig_bbcode_uid' => '',
|
|
indvdum@0
|
1094 |
'sig_bbcode_bitfield' => '',
|
|
indvdum@0
|
1095 |
|
|
indvdum@0
|
1096 |
'online' => false,
|
|
indvdum@0
|
1097 |
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
|
|
indvdum@0
|
1098 |
'rank_title' => '',
|
|
indvdum@0
|
1099 |
'rank_image' => '',
|
|
indvdum@0
|
1100 |
'rank_image_src' => '',
|
|
indvdum@0
|
1101 |
'sig' => '',
|
|
indvdum@0
|
1102 |
'profile' => '',
|
|
indvdum@0
|
1103 |
'pm' => '',
|
|
indvdum@0
|
1104 |
'email' => '',
|
|
indvdum@0
|
1105 |
'www' => '',
|
|
indvdum@0
|
1106 |
'icq_status_img' => '',
|
|
indvdum@0
|
1107 |
'icq' => '',
|
|
indvdum@0
|
1108 |
'aim' => '',
|
|
indvdum@0
|
1109 |
'msn' => '',
|
|
indvdum@0
|
1110 |
'yim' => '',
|
|
indvdum@0
|
1111 |
'jabber' => '',
|
|
indvdum@0
|
1112 |
'search' => '',
|
|
indvdum@0
|
1113 |
'age' => '',
|
|
indvdum@0
|
1114 |
|
|
indvdum@0
|
1115 |
'username' => $row['username'],
|
|
indvdum@0
|
1116 |
'user_colour' => $row['user_colour'],
|
|
indvdum@0
|
1117 |
|
|
indvdum@0
|
1118 |
'warnings' => 0,
|
|
indvdum@0
|
1119 |
'allow_pm' => 0,
|
|
indvdum@0
|
1120 |
);
|
|
indvdum@0
|
1121 |
|
|
indvdum@0
|
1122 |
get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
|
indvdum@0
|
1123 |
}
|
|
indvdum@0
|
1124 |
else
|
|
indvdum@0
|
1125 |
{
|
|
indvdum@0
|
1126 |
$user_sig = '';
|
|
indvdum@0
|
1127 |
|
|
indvdum@0
|
1128 |
// We add the signature to every posters entry because enable_sig is post dependant
|
|
indvdum@0
|
1129 |
if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
|
|
indvdum@0
|
1130 |
{
|
|
indvdum@0
|
1131 |
$user_sig = $row['user_sig'];
|
|
indvdum@0
|
1132 |
}
|
|
indvdum@0
|
1133 |
|
|
indvdum@0
|
1134 |
$id_cache[] = $poster_id;
|
|
indvdum@0
|
1135 |
|
|
indvdum@0
|
1136 |
$user_cache[$poster_id] = array(
|
|
indvdum@0
|
1137 |
'joined' => $user->format_date($row['user_regdate']),
|
|
indvdum@0
|
1138 |
'posts' => $row['user_posts'],
|
|
indvdum@0
|
1139 |
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
|
|
indvdum@0
|
1140 |
'from' => (!empty($row['user_from'])) ? $row['user_from'] : '',
|
|
indvdum@0
|
1141 |
|
|
indvdum@0
|
1142 |
'sig' => $user_sig,
|
|
indvdum@0
|
1143 |
'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
|
|
indvdum@0
|
1144 |
'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
|
|
indvdum@0
|
1145 |
|
|
indvdum@0
|
1146 |
'viewonline' => $row['user_allow_viewonline'],
|
|
indvdum@0
|
1147 |
'allow_pm' => $row['user_allow_pm'],
|
|
indvdum@0
|
1148 |
|
|
indvdum@0
|
1149 |
'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
|
|
indvdum@0
|
1150 |
'age' => '',
|
|
indvdum@0
|
1151 |
|
|
indvdum@0
|
1152 |
'rank_title' => '',
|
|
indvdum@0
|
1153 |
'rank_image' => '',
|
|
indvdum@0
|
1154 |
'rank_image_src' => '',
|
|
indvdum@0
|
1155 |
|
|
indvdum@0
|
1156 |
'username' => $row['username'],
|
|
indvdum@0
|
1157 |
'user_colour' => $row['user_colour'],
|
|
indvdum@0
|
1158 |
|
|
indvdum@0
|
1159 |
'online' => false,
|
|
indvdum@0
|
1160 |
'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"),
|
|
indvdum@0
|
1161 |
'www' => $row['user_website'],
|
|
indvdum@0
|
1162 |
'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '',
|
|
indvdum@0
|
1163 |
'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '',
|
|
indvdum@0
|
1164 |
'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '',
|
|
indvdum@0
|
1165 |
'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '',
|
|
indvdum@0
|
1166 |
'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&sr=posts") : '',
|
|
indvdum@0
|
1167 |
|
|
indvdum@0
|
1168 |
'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']),
|
|
indvdum@0
|
1169 |
'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']),
|
|
indvdum@0
|
1170 |
'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']),
|
|
indvdum@0
|
1171 |
'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
|
|
indvdum@0
|
1172 |
);
|
|
indvdum@0
|
1173 |
|
|
indvdum@0
|
1174 |
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
|
|
indvdum@0
|
1175 |
|
|
indvdum@0
|
1176 |
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
|
|
indvdum@0
|
1177 |
{
|
|
indvdum@0
|
1178 |
$user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);
|
|
indvdum@0
|
1179 |
}
|
|
indvdum@0
|
1180 |
else
|
|
indvdum@0
|
1181 |
{
|
|
indvdum@0
|
1182 |
$user_cache[$poster_id]['email'] = '';
|
|
indvdum@0
|
1183 |
}
|
|
indvdum@0
|
1184 |
|
|
indvdum@0
|
1185 |
if (!empty($row['user_icq']))
|
|
indvdum@0
|
1186 |
{
|
|
indvdum@0
|
1187 |
$user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . urlencode($row['user_icq']) . '/';
|
|
indvdum@0
|
1188 |
$user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />';
|
|
indvdum@0
|
1189 |
}
|
|
indvdum@0
|
1190 |
else
|
|
indvdum@0
|
1191 |
{
|
|
indvdum@0
|
1192 |
$user_cache[$poster_id]['icq_status_img'] = '';
|
|
indvdum@0
|
1193 |
$user_cache[$poster_id]['icq'] = '';
|
|
indvdum@0
|
1194 |
}
|
|
indvdum@0
|
1195 |
|
|
indvdum@0
|
1196 |
if ($config['allow_birthdays'] && !empty($row['user_birthday']))
|
|
indvdum@0
|
1197 |
{
|
|
indvdum@0
|
1198 |
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
|
|
indvdum@0
|
1199 |
|
|
indvdum@0
|
1200 |
if ($bday_year)
|
|
indvdum@0
|
1201 |
{
|
|
indvdum@0
|
1202 |
$diff = $now['mon'] - $bday_month;
|
|
indvdum@0
|
1203 |
if ($diff == 0)
|
|
indvdum@0
|
1204 |
{
|
|
indvdum@0
|
1205 |
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
|
|
indvdum@0
|
1206 |
}
|
|
indvdum@0
|
1207 |
else
|
|
indvdum@0
|
1208 |
{
|
|
indvdum@0
|
1209 |
$diff = ($diff < 0) ? 1 : 0;
|
|
indvdum@0
|
1210 |
}
|
|
indvdum@0
|
1211 |
|
|
indvdum@0
|
1212 |
$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
|
|
indvdum@0
|
1213 |
}
|
|
indvdum@0
|
1214 |
}
|
|
indvdum@0
|
1215 |
}
|
|
indvdum@0
|
1216 |
}
|
|
indvdum@0
|
1217 |
}
|
|
indvdum@0
|
1218 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1219 |
|
|
indvdum@0
|
1220 |
// Load custom profile fields
|
|
indvdum@0
|
1221 |
if ($config['load_cpf_viewtopic'])
|
|
indvdum@0
|
1222 |
{
|
|
indvdum@0
|
1223 |
if (!class_exists('custom_profile'))
|
|
indvdum@0
|
1224 |
{
|
|
indvdum@0
|
1225 |
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
|
|
indvdum@0
|
1226 |
}
|
|
indvdum@0
|
1227 |
$cp = new custom_profile();
|
|
indvdum@0
|
1228 |
|
|
indvdum@0
|
1229 |
// Grab all profile fields from users in id cache for later use - similar to the poster cache
|
|
indvdum@0
|
1230 |
$profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
|
|
indvdum@0
|
1231 |
|
|
indvdum@0
|
1232 |
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
|
|
indvdum@0
|
1233 |
$profile_fields_cache = array();
|
|
indvdum@0
|
1234 |
foreach ($profile_fields_tmp as $profile_user_id => $profile_fields)
|
|
indvdum@0
|
1235 |
{
|
|
indvdum@0
|
1236 |
$profile_fields_cache[$profile_user_id] = array();
|
|
indvdum@0
|
1237 |
foreach ($profile_fields as $used_ident => $profile_field)
|
|
indvdum@0
|
1238 |
{
|
|
indvdum@0
|
1239 |
if ($profile_field['data']['field_show_on_vt'])
|
|
indvdum@0
|
1240 |
{
|
|
indvdum@0
|
1241 |
$profile_fields_cache[$profile_user_id][$used_ident] = $profile_field;
|
|
indvdum@0
|
1242 |
}
|
|
indvdum@0
|
1243 |
}
|
|
indvdum@0
|
1244 |
}
|
|
indvdum@0
|
1245 |
unset($profile_fields_tmp);
|
|
indvdum@0
|
1246 |
}
|
|
indvdum@0
|
1247 |
|
|
indvdum@0
|
1248 |
// Generate online information for user
|
|
indvdum@0
|
1249 |
if ($config['load_onlinetrack'] && sizeof($id_cache))
|
|
indvdum@0
|
1250 |
{
|
|
indvdum@0
|
1251 |
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
|
|
indvdum@0
|
1252 |
FROM ' . SESSIONS_TABLE . '
|
|
indvdum@0
|
1253 |
WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '
|
|
indvdum@0
|
1254 |
GROUP BY session_user_id';
|
|
indvdum@0
|
1255 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1256 |
|
|
indvdum@0
|
1257 |
$update_time = $config['load_online_time'] * 60;
|
|
indvdum@0
|
1258 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1259 |
{
|
|
indvdum@0
|
1260 |
$user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
|
|
indvdum@0
|
1261 |
}
|
|
indvdum@0
|
1262 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1263 |
}
|
|
indvdum@0
|
1264 |
unset($id_cache);
|
|
indvdum@0
|
1265 |
|
|
indvdum@0
|
1266 |
// Pull attachment data
|
|
indvdum@0
|
1267 |
if (sizeof($attach_list))
|
|
indvdum@0
|
1268 |
{
|
|
indvdum@0
|
1269 |
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))
|
|
indvdum@0
|
1270 |
{
|
|
indvdum@0
|
1271 |
$sql = 'SELECT *
|
|
indvdum@0
|
1272 |
FROM ' . ATTACHMENTS_TABLE . '
|
|
indvdum@0
|
1273 |
WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
|
|
indvdum@0
|
1274 |
AND in_message = 0
|
|
indvdum@0
|
1275 |
ORDER BY filetime DESC, post_msg_id ASC';
|
|
indvdum@0
|
1276 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1277 |
|
|
indvdum@0
|
1278 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
1279 |
{
|
|
indvdum@0
|
1280 |
$attachments[$row['post_msg_id']][] = $row;
|
|
indvdum@0
|
1281 |
}
|
|
indvdum@0
|
1282 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1283 |
|
|
indvdum@0
|
1284 |
// No attachments exist, but post table thinks they do so go ahead and reset post_attach flags
|
|
indvdum@0
|
1285 |
if (!sizeof($attachments))
|
|
indvdum@0
|
1286 |
{
|
|
indvdum@0
|
1287 |
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
indvdum@0
|
1288 |
SET post_attachment = 0
|
|
indvdum@0
|
1289 |
WHERE ' . $db->sql_in_set('post_id', $attach_list);
|
|
indvdum@0
|
1290 |
$db->sql_query($sql);
|
|
indvdum@0
|
1291 |
|
|
indvdum@0
|
1292 |
// We need to update the topic indicator too if the complete topic is now without an attachment
|
|
indvdum@0
|
1293 |
if (sizeof($rowset) != $total_posts)
|
|
indvdum@0
|
1294 |
{
|
|
indvdum@0
|
1295 |
// Not all posts are displayed so we query the db to find if there's any attachment for this topic
|
|
indvdum@0
|
1296 |
$sql = 'SELECT a.post_msg_id as post_id
|
|
indvdum@0
|
1297 |
FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p
|
|
indvdum@0
|
1298 |
WHERE p.topic_id = $topic_id
|
|
indvdum@0
|
1299 |
AND p.post_approved = 1
|
|
indvdum@0
|
1300 |
AND p.topic_id = a.topic_id";
|
|
indvdum@0
|
1301 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
1302 |
$row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1303 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1304 |
|
|
indvdum@0
|
1305 |
if (!$row)
|
|
indvdum@0
|
1306 |
{
|
|
indvdum@0
|
1307 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
1308 |
SET topic_attachment = 0
|
|
indvdum@0
|
1309 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1310 |
$db->sql_query($sql);
|
|
indvdum@0
|
1311 |
}
|
|
indvdum@0
|
1312 |
}
|
|
indvdum@0
|
1313 |
else
|
|
indvdum@0
|
1314 |
{
|
|
indvdum@0
|
1315 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
1316 |
SET topic_attachment = 0
|
|
indvdum@0
|
1317 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1318 |
$db->sql_query($sql);
|
|
indvdum@0
|
1319 |
}
|
|
indvdum@0
|
1320 |
}
|
|
indvdum@0
|
1321 |
else if ($has_attachments && !$topic_data['topic_attachment'])
|
|
indvdum@0
|
1322 |
{
|
|
indvdum@0
|
1323 |
// Topic has approved attachments but its flag is wrong
|
|
indvdum@0
|
1324 |
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
|
indvdum@0
|
1325 |
SET topic_attachment = 1
|
|
indvdum@0
|
1326 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1327 |
$db->sql_query($sql);
|
|
indvdum@0
|
1328 |
|
|
indvdum@0
|
1329 |
$topic_data['topic_attachment'] = 1;
|
|
indvdum@0
|
1330 |
}
|
|
indvdum@0
|
1331 |
}
|
|
indvdum@0
|
1332 |
else
|
|
indvdum@0
|
1333 |
{
|
|
indvdum@0
|
1334 |
$display_notice = true;
|
|
indvdum@0
|
1335 |
}
|
|
indvdum@0
|
1336 |
}
|
|
indvdum@0
|
1337 |
|
|
indvdum@0
|
1338 |
// Instantiate BBCode if need be
|
|
indvdum@0
|
1339 |
if ($bbcode_bitfield !== '')
|
|
indvdum@0
|
1340 |
{
|
|
indvdum@0
|
1341 |
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
|
indvdum@0
|
1342 |
}
|
|
indvdum@0
|
1343 |
|
|
indvdum@0
|
1344 |
$i_total = sizeof($rowset) - 1;
|
|
indvdum@0
|
1345 |
$prev_post_id = '';
|
|
indvdum@0
|
1346 |
|
|
indvdum@0
|
1347 |
$template->assign_vars(array(
|
|
indvdum@0
|
1348 |
'S_NUM_POSTS' => sizeof($post_list))
|
|
indvdum@0
|
1349 |
);
|
|
indvdum@0
|
1350 |
|
|
indvdum@0
|
1351 |
// Output the posts
|
|
indvdum@0
|
1352 |
$first_unread = $post_unread = false;
|
|
indvdum@0
|
1353 |
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
|
|
indvdum@0
|
1354 |
{
|
|
indvdum@0
|
1355 |
// A non-existing rowset only happens if there was no user present for the entered poster_id
|
|
indvdum@0
|
1356 |
// This could be a broken posts table.
|
|
indvdum@0
|
1357 |
if (!isset($rowset[$post_list[$i]]))
|
|
indvdum@0
|
1358 |
{
|
|
indvdum@0
|
1359 |
continue;
|
|
indvdum@0
|
1360 |
}
|
|
indvdum@0
|
1361 |
|
|
indvdum@0
|
1362 |
$row =& $rowset[$post_list[$i]];
|
|
indvdum@0
|
1363 |
$poster_id = $row['user_id'];
|
|
indvdum@0
|
1364 |
|
|
indvdum@0
|
1365 |
// End signature parsing, only if needed
|
|
indvdum@0
|
1366 |
if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
|
|
indvdum@0
|
1367 |
{
|
|
indvdum@0
|
1368 |
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
|
|
indvdum@0
|
1369 |
|
|
indvdum@0
|
1370 |
if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
|
|
indvdum@0
|
1371 |
{
|
|
indvdum@0
|
1372 |
$bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
|
|
indvdum@0
|
1373 |
}
|
|
indvdum@0
|
1374 |
|
|
indvdum@0
|
1375 |
$user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
|
|
indvdum@0
|
1376 |
$user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
|
|
indvdum@0
|
1377 |
$user_cache[$poster_id]['sig_parsed'] = true;
|
|
indvdum@0
|
1378 |
}
|
|
indvdum@0
|
1379 |
|
|
indvdum@0
|
1380 |
// Parse the message and subject
|
|
indvdum@0
|
1381 |
$message = censor_text($row['post_text']);
|
|
indvdum@0
|
1382 |
|
|
indvdum@0
|
1383 |
// Second parse bbcode here
|
|
indvdum@0
|
1384 |
if ($row['bbcode_bitfield'])
|
|
indvdum@0
|
1385 |
{
|
|
indvdum@0
|
1386 |
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
|
indvdum@0
|
1387 |
}
|
|
indvdum@0
|
1388 |
|
|
indvdum@0
|
1389 |
$message = bbcode_nl2br($message);
|
|
indvdum@0
|
1390 |
$message = smiley_text($message);
|
|
indvdum@0
|
1391 |
|
|
indvdum@0
|
1392 |
if (!empty($attachments[$row['post_id']]))
|
|
indvdum@0
|
1393 |
{
|
|
indvdum@0
|
1394 |
parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count);
|
|
indvdum@0
|
1395 |
}
|
|
indvdum@0
|
1396 |
|
|
indvdum@0
|
1397 |
// Replace naughty words such as farty pants
|
|
indvdum@0
|
1398 |
$row['post_subject'] = censor_text($row['post_subject']);
|
|
indvdum@0
|
1399 |
|
|
indvdum@0
|
1400 |
// Highlight active words (primarily for search)
|
|
indvdum@0
|
1401 |
if ($highlight_match)
|
|
indvdum@0
|
1402 |
{
|
|
indvdum@0
|
1403 |
$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message);
|
|
indvdum@0
|
1404 |
$row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $row['post_subject']);
|
|
indvdum@0
|
1405 |
}
|
|
indvdum@0
|
1406 |
|
|
indvdum@0
|
1407 |
// Editing information
|
|
indvdum@0
|
1408 |
if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])
|
|
indvdum@0
|
1409 |
{
|
|
indvdum@0
|
1410 |
// Get usernames for all following posts if not already stored
|
|
indvdum@0
|
1411 |
if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))))
|
|
indvdum@0
|
1412 |
{
|
|
indvdum@0
|
1413 |
// Remove all post_ids already parsed (we do not have to check them)
|
|
indvdum@0
|
1414 |
$post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i);
|
|
indvdum@0
|
1415 |
|
|
indvdum@0
|
1416 |
$sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour
|
|
indvdum@0
|
1417 |
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
|
|
indvdum@0
|
1418 |
WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . '
|
|
indvdum@0
|
1419 |
AND p.post_edit_count <> 0
|
|
indvdum@0
|
1420 |
AND p.post_edit_user <> 0
|
|
indvdum@0
|
1421 |
AND p.post_edit_user = u.user_id';
|
|
indvdum@0
|
1422 |
$result2 = $db->sql_query($sql);
|
|
indvdum@0
|
1423 |
while ($user_edit_row = $db->sql_fetchrow($result2))
|
|
indvdum@0
|
1424 |
{
|
|
indvdum@0
|
1425 |
$post_edit_list[$user_edit_row['user_id']] = $user_edit_row;
|
|
indvdum@0
|
1426 |
}
|
|
indvdum@0
|
1427 |
$db->sql_freeresult($result2);
|
|
indvdum@0
|
1428 |
|
|
indvdum@0
|
1429 |
unset($post_storage_list);
|
|
indvdum@0
|
1430 |
}
|
|
indvdum@0
|
1431 |
|
|
indvdum@0
|
1432 |
$l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
|
|
indvdum@0
|
1433 |
|
|
indvdum@0
|
1434 |
if ($row['post_edit_reason'])
|
|
indvdum@0
|
1435 |
{
|
|
indvdum@0
|
1436 |
// User having edited the post also being the post author?
|
|
indvdum@0
|
1437 |
if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
|
|
indvdum@0
|
1438 |
{
|
|
indvdum@0
|
1439 |
$display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
|
|
indvdum@0
|
1440 |
}
|
|
indvdum@0
|
1441 |
else
|
|
indvdum@0
|
1442 |
{
|
|
indvdum@0
|
1443 |
$display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']);
|
|
indvdum@0
|
1444 |
}
|
|
indvdum@0
|
1445 |
|
|
indvdum@0
|
1446 |
$l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
|
|
indvdum@0
|
1447 |
}
|
|
indvdum@0
|
1448 |
else
|
|
indvdum@0
|
1449 |
{
|
|
indvdum@0
|
1450 |
if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))
|
|
indvdum@0
|
1451 |
{
|
|
indvdum@0
|
1452 |
$user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']];
|
|
indvdum@0
|
1453 |
}
|
|
indvdum@0
|
1454 |
|
|
indvdum@0
|
1455 |
// User having edited the post also being the post author?
|
|
indvdum@0
|
1456 |
if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
|
|
indvdum@0
|
1457 |
{
|
|
indvdum@0
|
1458 |
$display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
|
|
indvdum@0
|
1459 |
}
|
|
indvdum@0
|
1460 |
else
|
|
indvdum@0
|
1461 |
{
|
|
indvdum@0
|
1462 |
$display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']);
|
|
indvdum@0
|
1463 |
}
|
|
indvdum@0
|
1464 |
|
|
indvdum@0
|
1465 |
$l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']);
|
|
indvdum@0
|
1466 |
}
|
|
indvdum@0
|
1467 |
}
|
|
indvdum@0
|
1468 |
else
|
|
indvdum@0
|
1469 |
{
|
|
indvdum@0
|
1470 |
$l_edited_by = '';
|
|
indvdum@0
|
1471 |
}
|
|
indvdum@0
|
1472 |
|
|
indvdum@0
|
1473 |
// Bump information
|
|
indvdum@0
|
1474 |
if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) )
|
|
indvdum@0
|
1475 |
{
|
|
indvdum@0
|
1476 |
// It is safe to grab the username from the user cache array, we are at the last
|
|
indvdum@0
|
1477 |
// post and only the topic poster and last poster are allowed to bump.
|
|
indvdum@0
|
1478 |
// Admins and mods are bound to the above rules too...
|
|
indvdum@0
|
1479 |
$l_bumped_by = sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'], false, true));
|
|
indvdum@0
|
1480 |
}
|
|
indvdum@0
|
1481 |
else
|
|
indvdum@0
|
1482 |
{
|
|
indvdum@0
|
1483 |
$l_bumped_by = '';
|
|
indvdum@0
|
1484 |
}
|
|
indvdum@0
|
1485 |
|
|
indvdum@0
|
1486 |
$cp_row = array();
|
|
indvdum@0
|
1487 |
|
|
indvdum@0
|
1488 |
//
|
|
indvdum@0
|
1489 |
if ($config['load_cpf_viewtopic'])
|
|
indvdum@0
|
1490 |
{
|
|
indvdum@0
|
1491 |
$cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
|
|
indvdum@0
|
1492 |
}
|
|
indvdum@0
|
1493 |
|
|
indvdum@0
|
1494 |
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
indvdum@0
|
1495 |
|
|
indvdum@0
|
1496 |
$s_first_unread = false;
|
|
indvdum@0
|
1497 |
if (!$first_unread && $post_unread)
|
|
indvdum@0
|
1498 |
{
|
|
indvdum@0
|
1499 |
$s_first_unread = $first_unread = true;
|
|
indvdum@0
|
1500 |
}
|
|
indvdum@0
|
1501 |
|
|
indvdum@0
|
1502 |
$edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
|
|
indvdum@0
|
1503 |
$user->data['user_id'] == $poster_id &&
|
|
indvdum@0
|
1504 |
$auth->acl_get('f_edit', $forum_id) &&
|
|
indvdum@0
|
1505 |
!$row['post_edit_locked'] &&
|
|
indvdum@0
|
1506 |
($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])
|
|
indvdum@0
|
1507 |
)));
|
|
indvdum@0
|
1508 |
|
|
indvdum@0
|
1509 |
$delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || (
|
|
indvdum@0
|
1510 |
$user->data['user_id'] == $poster_id &&
|
|
indvdum@0
|
1511 |
$auth->acl_get('f_delete', $forum_id) &&
|
|
indvdum@0
|
1512 |
$topic_data['topic_last_post_id'] == $row['post_id'] &&
|
|
indvdum@0
|
1513 |
($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&
|
|
indvdum@0
|
1514 |
// we do not want to allow removal of the last post if a moderator locked it!
|
|
indvdum@0
|
1515 |
!$row['post_edit_locked']
|
|
indvdum@0
|
1516 |
)));
|
|
indvdum@0
|
1517 |
|
|
indvdum@0
|
1518 |
//
|
|
indvdum@0
|
1519 |
$postrow = array(
|
|
indvdum@0
|
1520 |
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
1521 |
'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
1522 |
'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
1523 |
'U_POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_profile'] : get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
|
|
indvdum@0
|
1524 |
|
|
indvdum@0
|
1525 |
'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
|
|
indvdum@0
|
1526 |
'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
|
|
indvdum@0
|
1527 |
'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
|
|
indvdum@0
|
1528 |
'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
|
|
indvdum@0
|
1529 |
'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
|
|
indvdum@0
|
1530 |
'POSTER_FROM' => $user_cache[$poster_id]['from'],
|
|
indvdum@0
|
1531 |
'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
|
|
indvdum@0
|
1532 |
'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'],
|
|
indvdum@0
|
1533 |
'POSTER_AGE' => $user_cache[$poster_id]['age'],
|
|
indvdum@0
|
1534 |
|
|
indvdum@0
|
1535 |
'POST_DATE' => $user->format_date($row['post_time'], false, ($view == 'print') ? true : false),
|
|
indvdum@0
|
1536 |
'POST_SUBJECT' => $row['post_subject'],
|
|
indvdum@0
|
1537 |
'MESSAGE' => $message,
|
|
indvdum@0
|
1538 |
'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
|
|
indvdum@0
|
1539 |
'EDITED_MESSAGE' => $l_edited_by,
|
|
indvdum@0
|
1540 |
'EDIT_REASON' => $row['post_edit_reason'],
|
|
indvdum@0
|
1541 |
'BUMPED_MESSAGE' => $l_bumped_by,
|
|
indvdum@0
|
1542 |
|
|
indvdum@0
|
1543 |
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
|
|
indvdum@0
|
1544 |
'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',
|
|
indvdum@0
|
1545 |
'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',
|
|
indvdum@0
|
1546 |
'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
|
|
indvdum@0
|
1547 |
'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'],
|
|
indvdum@0
|
1548 |
'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
|
|
indvdum@0
|
1549 |
'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
|
|
indvdum@0
|
1550 |
|
|
indvdum@0
|
1551 |
'U_EDIT' => ($edit_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f=$forum_id&p={$row['post_id']}") : '',
|
|
indvdum@0
|
1552 |
'U_QUOTE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=quote&f=$forum_id&p={$row['post_id']}") : '',
|
|
indvdum@0
|
1553 |
'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&f=$forum_id&p=" . $row['post_id'], true, $user->session_id) : '',
|
|
indvdum@0
|
1554 |
'U_DELETE' => ($delete_allowed) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=delete&f=$forum_id&p={$row['post_id']}") : '',
|
|
indvdum@0
|
1555 |
|
|
indvdum@0
|
1556 |
'U_PROFILE' => $user_cache[$poster_id]['profile'],
|
|
indvdum@0
|
1557 |
'U_SEARCH' => $user_cache[$poster_id]['search'],
|
|
indvdum@0
|
1558 |
'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '',
|
|
indvdum@0
|
1559 |
'U_EMAIL' => $user_cache[$poster_id]['email'],
|
|
indvdum@0
|
1560 |
'U_WWW' => $user_cache[$poster_id]['www'],
|
|
indvdum@0
|
1561 |
'U_ICQ' => $user_cache[$poster_id]['icq'],
|
|
indvdum@0
|
1562 |
'U_AIM' => $user_cache[$poster_id]['aim'],
|
|
indvdum@0
|
1563 |
'U_MSN' => $user_cache[$poster_id]['msn'],
|
|
indvdum@0
|
1564 |
'U_YIM' => $user_cache[$poster_id]['yim'],
|
|
indvdum@0
|
1565 |
'U_JABBER' => $user_cache[$poster_id]['jabber'],
|
|
indvdum@0
|
1566 |
|
|
indvdum@0
|
1567 |
'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '',
|
|
indvdum@0
|
1568 |
'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
|
indvdum@0
|
1569 |
'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
|
indvdum@0
|
1570 |
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '#p' . $row['post_id'],
|
|
indvdum@0
|
1571 |
'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',
|
|
indvdum@0
|
1572 |
'U_PREV_POST_ID' => $prev_post_id,
|
|
indvdum@0
|
1573 |
'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '',
|
|
indvdum@0
|
1574 |
'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
|
indvdum@0
|
1575 |
|
|
indvdum@0
|
1576 |
'POST_ID' => $row['post_id'],
|
|
indvdum@0
|
1577 |
'POST_NUMBER' => $i + $start + 1,
|
|
indvdum@0
|
1578 |
'POSTER_ID' => $poster_id,
|
|
indvdum@0
|
1579 |
|
|
indvdum@0
|
1580 |
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
|
|
indvdum@0
|
1581 |
'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
|
|
indvdum@0
|
1582 |
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,
|
|
indvdum@0
|
1583 |
'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
|
|
indvdum@0
|
1584 |
'S_FRIEND' => ($row['friend']) ? true : false,
|
|
indvdum@0
|
1585 |
'S_UNREAD_POST' => $post_unread,
|
|
indvdum@0
|
1586 |
'S_FIRST_UNREAD' => $s_first_unread,
|
|
indvdum@0
|
1587 |
'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
|
|
indvdum@0
|
1588 |
'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false,
|
|
indvdum@0
|
1589 |
|
|
indvdum@0
|
1590 |
'S_IGNORE_POST' => ($row['hide_post']) ? true : false,
|
|
indvdum@0
|
1591 |
'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '',
|
|
indvdum@0
|
1592 |
);
|
|
indvdum@0
|
1593 |
|
|
indvdum@0
|
1594 |
if (isset($cp_row['row']) && sizeof($cp_row['row']))
|
|
indvdum@0
|
1595 |
{
|
|
indvdum@0
|
1596 |
$postrow = array_merge($postrow, $cp_row['row']);
|
|
indvdum@0
|
1597 |
}
|
|
indvdum@0
|
1598 |
|
|
indvdum@0
|
1599 |
// Dump vars into template
|
|
indvdum@0
|
1600 |
$template->assign_block_vars('postrow', $postrow);
|
|
indvdum@0
|
1601 |
|
|
indvdum@0
|
1602 |
if (!empty($cp_row['blockrow']))
|
|
indvdum@0
|
1603 |
{
|
|
indvdum@0
|
1604 |
foreach ($cp_row['blockrow'] as $field_data)
|
|
indvdum@0
|
1605 |
{
|
|
indvdum@0
|
1606 |
$template->assign_block_vars('postrow.custom_fields', $field_data);
|
|
indvdum@0
|
1607 |
}
|
|
indvdum@0
|
1608 |
}
|
|
indvdum@0
|
1609 |
|
|
indvdum@0
|
1610 |
// Display not already displayed Attachments for this post, we already parsed them. ;)
|
|
indvdum@0
|
1611 |
if (!empty($attachments[$row['post_id']]))
|
|
indvdum@0
|
1612 |
{
|
|
indvdum@0
|
1613 |
foreach ($attachments[$row['post_id']] as $attachment)
|
|
indvdum@0
|
1614 |
{
|
|
indvdum@0
|
1615 |
$template->assign_block_vars('postrow.attachment', array(
|
|
indvdum@0
|
1616 |
'DISPLAY_ATTACHMENT' => $attachment)
|
|
indvdum@0
|
1617 |
);
|
|
indvdum@0
|
1618 |
}
|
|
indvdum@0
|
1619 |
}
|
|
indvdum@0
|
1620 |
|
|
indvdum@0
|
1621 |
$prev_post_id = $row['post_id'];
|
|
indvdum@0
|
1622 |
|
|
indvdum@0
|
1623 |
unset($rowset[$post_list[$i]]);
|
|
indvdum@0
|
1624 |
unset($attachments[$row['post_id']]);
|
|
indvdum@0
|
1625 |
}
|
|
indvdum@0
|
1626 |
unset($rowset, $user_cache);
|
|
indvdum@0
|
1627 |
|
|
indvdum@0
|
1628 |
// Update topic view and if necessary attachment view counters ... but only for humans and if this is the first 'page view'
|
|
indvdum@0
|
1629 |
if (isset($user->data['session_page']) && !$user->data['is_bot'] && (strpos($user->data['session_page'], '&t=' . $topic_id) === false || isset($user->data['session_created'])))
|
|
indvdum@0
|
1630 |
{
|
|
indvdum@0
|
1631 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
indvdum@0
|
1632 |
SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
|
|
indvdum@0
|
1633 |
WHERE topic_id = $topic_id";
|
|
indvdum@0
|
1634 |
$db->sql_query($sql);
|
|
indvdum@0
|
1635 |
|
|
indvdum@0
|
1636 |
// Update the attachment download counts
|
|
indvdum@0
|
1637 |
if (sizeof($update_count))
|
|
indvdum@0
|
1638 |
{
|
|
indvdum@0
|
1639 |
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
|
|
indvdum@0
|
1640 |
SET download_count = download_count + 1
|
|
indvdum@0
|
1641 |
WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
|
|
indvdum@0
|
1642 |
$db->sql_query($sql);
|
|
indvdum@0
|
1643 |
}
|
|
indvdum@0
|
1644 |
}
|
|
indvdum@0
|
1645 |
|
|
indvdum@0
|
1646 |
// Get last post time for all global announcements
|
|
indvdum@0
|
1647 |
// to keep proper forums tracking
|
|
indvdum@0
|
1648 |
if ($topic_data['topic_type'] == POST_GLOBAL)
|
|
indvdum@0
|
1649 |
{
|
|
indvdum@0
|
1650 |
$sql = 'SELECT topic_last_post_time as forum_last_post_time
|
|
indvdum@0
|
1651 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
1652 |
WHERE forum_id = 0
|
|
indvdum@0
|
1653 |
ORDER BY topic_last_post_time DESC';
|
|
indvdum@0
|
1654 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
1655 |
$topic_data['forum_last_post_time'] = (int) $db->sql_fetchfield('forum_last_post_time');
|
|
indvdum@0
|
1656 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1657 |
|
|
indvdum@0
|
1658 |
$sql = 'SELECT mark_time as forum_mark_time
|
|
indvdum@0
|
1659 |
FROM ' . FORUMS_TRACK_TABLE . '
|
|
indvdum@0
|
1660 |
WHERE forum_id = 0
|
|
indvdum@0
|
1661 |
AND user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
1662 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1663 |
$topic_data['forum_mark_time'] = (int) $db->sql_fetchfield('forum_mark_time');
|
|
indvdum@0
|
1664 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1665 |
}
|
|
indvdum@0
|
1666 |
|
|
indvdum@0
|
1667 |
// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
|
|
indvdum@0
|
1668 |
if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
|
|
indvdum@0
|
1669 |
{
|
|
indvdum@0
|
1670 |
markread('topic', (($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_id, $max_post_time);
|
|
indvdum@0
|
1671 |
|
|
indvdum@0
|
1672 |
// Update forum info
|
|
indvdum@0
|
1673 |
$all_marked_read = update_forum_tracking_info((($topic_data['topic_type'] == POST_GLOBAL) ? 0 : $forum_id), $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
|
|
indvdum@0
|
1674 |
}
|
|
indvdum@0
|
1675 |
else
|
|
indvdum@0
|
1676 |
{
|
|
indvdum@0
|
1677 |
$all_marked_read = true;
|
|
indvdum@0
|
1678 |
}
|
|
indvdum@0
|
1679 |
|
|
indvdum@0
|
1680 |
// If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link
|
|
indvdum@0
|
1681 |
if ($all_marked_read)
|
|
indvdum@0
|
1682 |
{
|
|
indvdum@0
|
1683 |
if ($post_unread)
|
|
indvdum@0
|
1684 |
{
|
|
indvdum@0
|
1685 |
$template->assign_vars(array(
|
|
indvdum@0
|
1686 |
'U_VIEW_UNREAD_POST' => '#unread',
|
|
indvdum@0
|
1687 |
));
|
|
indvdum@0
|
1688 |
}
|
|
indvdum@0
|
1689 |
else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id])
|
|
indvdum@0
|
1690 |
{
|
|
indvdum@0
|
1691 |
$template->assign_vars(array(
|
|
indvdum@0
|
1692 |
'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread',
|
|
indvdum@0
|
1693 |
));
|
|
indvdum@0
|
1694 |
}
|
|
indvdum@0
|
1695 |
}
|
|
indvdum@0
|
1696 |
else if (!$all_marked_read)
|
|
indvdum@0
|
1697 |
{
|
|
indvdum@0
|
1698 |
$last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false;
|
|
indvdum@0
|
1699 |
|
|
indvdum@0
|
1700 |
// What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread
|
|
indvdum@0
|
1701 |
if ($last_page && $post_unread)
|
|
indvdum@0
|
1702 |
{
|
|
indvdum@0
|
1703 |
$template->assign_vars(array(
|
|
indvdum@0
|
1704 |
'U_VIEW_UNREAD_POST' => '#unread',
|
|
indvdum@0
|
1705 |
));
|
|
indvdum@0
|
1706 |
}
|
|
indvdum@0
|
1707 |
else if (!$last_page)
|
|
indvdum@0
|
1708 |
{
|
|
indvdum@0
|
1709 |
$template->assign_vars(array(
|
|
indvdum@0
|
1710 |
'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread',
|
|
indvdum@0
|
1711 |
));
|
|
indvdum@0
|
1712 |
}
|
|
indvdum@0
|
1713 |
}
|
|
indvdum@0
|
1714 |
|
|
indvdum@0
|
1715 |
// let's set up quick_reply
|
|
indvdum@0
|
1716 |
$s_quick_reply = false;
|
|
indvdum@0
|
1717 |
if ($user->data['is_registered'] && $config['allow_quick_reply'] && ($topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) && $auth->acl_get('f_reply', $forum_id))
|
|
indvdum@0
|
1718 |
{
|
|
indvdum@0
|
1719 |
// Quick reply enabled forum
|
|
indvdum@0
|
1720 |
$s_quick_reply = (($topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED) || $auth->acl_get('m_edit', $forum_id)) ? true : false;
|
|
indvdum@0
|
1721 |
}
|
|
indvdum@0
|
1722 |
|
|
indvdum@0
|
1723 |
if ($s_can_vote || $s_quick_reply)
|
|
indvdum@0
|
1724 |
{
|
|
indvdum@0
|
1725 |
add_form_key('posting');
|
|
indvdum@0
|
1726 |
|
|
indvdum@0
|
1727 |
if ($s_quick_reply)
|
|
indvdum@0
|
1728 |
{
|
|
indvdum@0
|
1729 |
$s_attach_sig = $config['allow_sig'] && $user->optionget('attachsig') && $auth->acl_get('f_sigs', $forum_id) && $auth->acl_get('u_sig');
|
|
indvdum@0
|
1730 |
$s_smilies = $config['allow_smilies'] && $user->optionget('smilies') && $auth->acl_get('f_smilies', $forum_id);
|
|
indvdum@0
|
1731 |
$s_bbcode = $config['allow_bbcode'] && $user->optionget('bbcode') && $auth->acl_get('f_bbcode', $forum_id);
|
|
indvdum@0
|
1732 |
$s_notify = $config['allow_topic_notify'] && ($user->data['user_notify'] || $s_watching_topic['is_watching']);
|
|
indvdum@0
|
1733 |
|
|
indvdum@0
|
1734 |
$qr_hidden_fields = array(
|
|
indvdum@0
|
1735 |
'topic_cur_post_id' => (int) $topic_data['topic_last_post_id'],
|
|
indvdum@0
|
1736 |
'lastclick' => (int) time(),
|
|
indvdum@0
|
1737 |
'topic_id' => (int) $topic_data['topic_id'],
|
|
indvdum@0
|
1738 |
'forum_id' => (int) $forum_id,
|
|
indvdum@0
|
1739 |
);
|
|
indvdum@0
|
1740 |
|
|
indvdum@0
|
1741 |
// Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
|
|
indvdum@0
|
1742 |
(!$s_bbcode) ? $qr_hidden_fields['disable_bbcode'] = 1 : true;
|
|
indvdum@0
|
1743 |
(!$s_smilies) ? $qr_hidden_fields['disable_smilies'] = 1 : true;
|
|
indvdum@0
|
1744 |
(!$config['allow_post_links']) ? $qr_hidden_fields['disable_magic_url'] = 1 : true;
|
|
indvdum@0
|
1745 |
($s_attach_sig) ? $qr_hidden_fields['attach_sig'] = 1 : true;
|
|
indvdum@0
|
1746 |
($s_notify) ? $qr_hidden_fields['notify'] = 1 : true;
|
|
indvdum@0
|
1747 |
($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true;
|
|
indvdum@0
|
1748 |
|
|
indvdum@0
|
1749 |
$template->assign_vars(array(
|
|
indvdum@0
|
1750 |
'S_QUICK_REPLY' => true,
|
|
indvdum@0
|
1751 |
'U_QR_ACTION' => append_sid("{$phpbb_root_path}posting.$phpEx", "mode=reply&f=$forum_id&t=$topic_id"),
|
|
indvdum@0
|
1752 |
'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields),
|
|
indvdum@0
|
1753 |
'SUBJECT' => 'Re: ' . censor_text($topic_data['topic_title']),
|
|
indvdum@0
|
1754 |
));
|
|
indvdum@0
|
1755 |
}
|
|
indvdum@0
|
1756 |
}
|
|
indvdum@0
|
1757 |
// now I have the urge to wash my hands :(
|
|
indvdum@0
|
1758 |
|
|
indvdum@0
|
1759 |
|
|
indvdum@0
|
1760 |
// We overwrite $_REQUEST['f'] if there is no forum specified
|
|
indvdum@0
|
1761 |
// to be able to display the correct online list.
|
|
indvdum@0
|
1762 |
// One downside is that the user currently viewing this topic/post is not taken into account.
|
|
indvdum@0
|
1763 |
if (empty($_REQUEST['f']))
|
|
indvdum@0
|
1764 |
{
|
|
indvdum@0
|
1765 |
$_REQUEST['f'] = $forum_id;
|
|
indvdum@0
|
1766 |
}
|
|
indvdum@0
|
1767 |
|
|
indvdum@0
|
1768 |
// We need to do the same with the topic_id. See #53025.
|
|
indvdum@0
|
1769 |
if (empty($_REQUEST['t']) && !empty($topic_id))
|
|
indvdum@0
|
1770 |
{
|
|
indvdum@0
|
1771 |
$_REQUEST['t'] = $topic_id;
|
|
indvdum@0
|
1772 |
}
|
|
indvdum@0
|
1773 |
|
|
indvdum@0
|
1774 |
// Output the page
|
|
indvdum@0
|
1775 |
page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title'], true, $forum_id);
|
|
indvdum@0
|
1776 |
|
|
indvdum@0
|
1777 |
$template->set_filenames(array(
|
|
indvdum@0
|
1778 |
'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
|
|
indvdum@0
|
1779 |
);
|
|
indvdum@0
|
1780 |
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id);
|
|
indvdum@0
|
1781 |
|
|
indvdum@0
|
1782 |
page_footer();
|
|
indvdum@0
|
1783 |
|
|
indvdum@0
|
1784 |
?> |