Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 494 lines (353 sloc) 20.922 kb
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
1 <?php
2
3 /*
f362a03 Dietrich Moerman copyright update
dietrichm authored
4 Copyright (C) 2003-2005 UseBB Team
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
5 http://www.usebb.net
6
7 $Header$
8
9 This file is part of UseBB.
10
11 UseBB is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 UseBB is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with UseBB; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26 define('INCLUDED', true);
27 define('ROOT_PATH', './');
28
29 //
30 // Include usebb engine
31 //
32 require(ROOT_PATH.'sources/common.php');
33
34 //
35 // If an ID has been passed
36 //
2fd9938 Dietrich Moerman better integer detection
dietrichm authored
37 if ( ( !empty($_GET['id']) && valid_int($_GET['id']) ) || ( !empty($_GET['post']) && valid_int($_GET['post']) ) ) {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
38
39 //
40 // Look up the topic ID for post ID's
41 //
2fd9938 Dietrich Moerman better integer detection
dietrichm authored
42 if ( !empty($_GET['post']) && valid_int($_GET['post']) ) {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
43
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
44 $result = $db->query("SELECT p1.topic_id, COUNT(p2.id) AS post_in_topic FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p1, ".TABLE_PREFIX."posts p2 WHERE p1.id = ".$_GET['post']." AND t.id = p1.topic_id AND p2.topic_id = p1.topic_id AND p2.id <= ".$_GET['post']." GROUP BY p1.topic_id");
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
45 $out = $db->fetch_result($result);
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
46
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
47 if ( $out['topic_id'] ) {
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
48
02e1a0b Dietrich Moerman paging
dietrichm authored
49 $requested_topic = $out['topic_id'];
5b0fa3c Dietrich Moerman finished paging for topics
dietrichm authored
50 $post_in_topic = $out['post_in_topic'];
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
51
52 } else {
53
54 //
55 // Update and get the session information
56 //
57 $session->update();
58
59 //
60 // Include the page header
61 //
62 require(ROOT_PATH.'sources/page_head.php');
63
64 //
65 // This post does not exist, show an error
66 //
2d145ee Dietrich Moerman 404 error codes returned when needed.
dietrichm authored
67 header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
68 $template->set_page_title($lang['Error']);
c9b5378 Dietrich Moerman OMG HUGE update. Check Changelog.txt. ;)
dietrichm authored
69 $template->parse('msgbox', 'global', array(
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
70 'box_title' => $lang['Error'],
71 'content' => sprintf($lang['NoSuchPost'], 'ID '.$_GET['post'])
72 ));
73
74 //
75 // Include the page header
76 //
77 require(ROOT_PATH.'sources/page_foot.php');
78
79 exit();
80
81 }
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
82
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
83 } elseif ( !empty($_GET['act']) && $_GET['act'] == 'getnewpost' ) {
84
2f16b78 Dietrich Moerman better detect new post in topic
dietrichm authored
85 $previous_view = ( array_key_exists($_GET['id'], $_SESSION['viewed_topics']) ) ? $_SESSION['viewed_topics'][$_GET['id']] : $_SESSION['previous_visit'];
86
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
87 $result = $db->query("SELECT COUNT(p.id) AS post_in_topic FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p WHERE t.id = ".$_GET['id']." AND t.id = p.topic_id AND p.post_time <= ".$previous_view." GROUP BY p.topic_id");
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
88 $out = $db->fetch_result($result);
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
89
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
90 if ( $out['post_in_topic'] )
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
91 $post_in_topic = $out['post_in_topic'];
92
93 $requested_topic = $_GET['id'];
94
02e1a0b Dietrich Moerman paging
dietrichm authored
95 } else {
96
97 $requested_topic = $_GET['id'];
98
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
99 }
100
101 //
102 // Update and get the session information
103 //
02e1a0b Dietrich Moerman paging
dietrichm authored
104 $session->update('topic:'.$requested_topic);
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
105
106 //
107 // Include the page header
108 //
109 require(ROOT_PATH.'sources/page_head.php');
110
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
111 $result = $db->query("SELECT t.id, t.topic_title, t.status_locked, t.status_sticky, t.count_replies, t.forum_id, t.last_post_id, f.id AS forum_id, f.name AS forum_name, f.status AS forum_status, f.auth, f.hide_mods_list FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.id = ".$requested_topic." AND f.id = t.forum_id");
112 $topicdata = $db->fetch_result($result);
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
113
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
114 if ( !$topicdata['id'] ) {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
115
116 //
117 // This topic does not exist, show an error
118 //
2d145ee Dietrich Moerman 404 error codes returned when needed.
dietrichm authored
119 header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
120 $template->set_page_title($lang['Error']);
c9b5378 Dietrich Moerman OMG HUGE update. Check Changelog.txt. ;)
dietrichm authored
121 $template->parse('msgbox', 'global', array(
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
122 'box_title' => $lang['Error'],
02e1a0b Dietrich Moerman paging
dietrichm authored
123 'content' => sprintf($lang['NoSuchTopic'], 'ID '.$requested_topic)
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
124 ));
125
126 } else {
127
781faf6 Dietrich Moerman Many, many updates, fixes and additions. Topics are replyable, however y...
dietrichm authored
128 if ( $functions->auth($topicdata['auth'], 'read', $topicdata['forum_id']) ) {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
129
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
130 //
131 // The user may view this topic
132 //
133
4f4e6d4 Dietrich Moerman Added bad words filter.
dietrichm authored
134 $topic_title = unhtml($functions->replace_badwords(stripslashes($topicdata['topic_title'])));
135
136 $template->set_page_title('<a href="'.$functions->make_url('forum.php', array('id' => $topicdata['forum_id'])).'">'.unhtml(stripslashes($topicdata['forum_name'])).'</a>'.$template->get_config('locationbar_item_delimiter').$topic_title);
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
137
138 //
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
139 // Update views count
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
140 //
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
141 $result = $db->query("UPDATE ".TABLE_PREFIX."topics SET count_views = count_views+1 WHERE id = ".$requested_topic);
781faf6 Dietrich Moerman Many, many updates, fixes and additions. Topics are replyable, however y...
dietrichm authored
142
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
143 //
144 // Eventually (un)subscribe user to topic
145 //
146 if ( $session->sess_info['user_id'] ) {
147
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
148 $result = $db->query("SELECT COUNT(*) as subscribed FROM ".TABLE_PREFIX."subscriptions WHERE topic_id = ".$requested_topic." AND user_id = ".$session->sess_info['user_id']);
149 $subscribed = $db->fetch_result($result);
150 $subscribed = ( !$subscribed['subscribed'] ) ? false : true;
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
151
152 }
153 if ( !empty($_GET['act']) && in_array($_GET['act'], array('subscribe', 'unsubscribe')) ) {
154
155 if ( !$session->sess_info['user_id'] ) {
156
157 $functions->redir_to_login();
158
159 } else {
160
161 if ( !$subscribed && $_GET['act'] == 'subscribe' ) {
162
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
163 $result = $db->query("INSERT INTO ".TABLE_PREFIX."subscriptions VALUES(".$requested_topic.", ".$session->sess_info['user_id'].")");
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
164 $subscribed = true;
165 $template->parse('msgbox', 'global', array(
166 'box_title' => $lang['Note'],
167 'content' => $lang['SubscribedTopic']
168 ));
169
170 } elseif ( $subscribed && $_GET['act'] == 'unsubscribe' ) {
171
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
172 $result = $db->query("DELETE FROM ".TABLE_PREFIX."subscriptions WHERE topic_id = ".$requested_topic." AND user_id = ".$session->sess_info['user_id']);
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
173 $subscribed = false;
174 $template->parse('msgbox', 'global', array(
175 'box_title' => $lang['Note'],
176 'content' => $lang['UnsubscribedTopic']
177 ));
178
179 }
180
181 }
182
183 }
184
185 //
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
186 // Get all the posts in one query
187 //
6e59cec Dietrich Moerman Smaller query when possible.
dietrichm authored
188
02e1a0b Dietrich Moerman paging
dietrichm authored
189 $forum_moderators = $functions->get_mods_list($topicdata['forum_id']);
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
190
9616ff2 Dietrich Moerman Replace level integers with constants.
dietrichm authored
191 $new_topic_link = ( $functions->auth($topicdata['auth'], 'post', $topicdata['forum_id']) && ( $topicdata['forum_status'] || $functions->get_user_level() == LEVEL_ADMIN ) ) ? '<a href="'.$functions->make_url('post.php', array('forum' => $topicdata['forum_id'])).'">'.$lang['PostNewTopic'].'</a>' : '';
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
192
9616ff2 Dietrich Moerman Replace level integers with constants.
dietrichm authored
193 $reply_link = ( ( !$topicdata['status_locked'] || $functions->auth($topicdata['auth'], 'lock', $topicdata['forum_id']) ) && ( $topicdata['forum_status'] || $functions->get_user_level() == LEVEL_ADMIN ) && $functions->auth($topicdata['auth'], 'reply', $topicdata['forum_id']) ) ? '<a href="'.$functions->make_url('post.php', array('topic' => $requested_topic)).'">'.$lang['PostReply'].'</a>' : '';
02e1a0b Dietrich Moerman paging
dietrichm authored
194
195 //
196 // Get page number
197 //
bc7be3b Dietrich Moerman finished topic view, fixed paging bug, ...
dietrichm authored
198 $numpages = ceil(intval($topicdata['count_replies']+1) / $functions->get_config('posts_per_page'));
5b0fa3c Dietrich Moerman finished paging for topics
dietrichm authored
199 if ( empty($post_in_topic) )
2fd9938 Dietrich Moerman better integer detection
dietrichm authored
200 $page = ( !empty($_GET['page']) && valid_int($_GET['page']) && intval($_GET['page']) <= $numpages ) ? intval($_GET['page']) : 1;
5b0fa3c Dietrich Moerman finished paging for topics
dietrichm authored
201 else
202 $page = ceil(intval($post_in_topic) / $functions->get_config('posts_per_page'));
02e1a0b Dietrich Moerman paging
dietrichm authored
203 $limit_start = ( $page - 1 ) * $functions->get_config('posts_per_page');
204 $limit_end = $functions->get_config('posts_per_page');
bc7be3b Dietrich Moerman finished topic view, fixed paging bug, ...
dietrichm authored
205 $page_links = $functions->make_page_links($numpages, $page, $topicdata['count_replies']+1, $functions->get_config('posts_per_page'), 'topic.php', $requested_topic);
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
206
207 //
208 // Output the posts
209 //
7d10ecb Dietrich Moerman major template name changes
dietrichm authored
210 $template->parse('header', 'topic', array(
4f4e6d4 Dietrich Moerman Added bad words filter.
dietrichm authored
211 'topic_name' => '<a href="'.$functions->make_url('topic.php', array('id' => $requested_topic)).'">'.$topic_title.'</a>',
6c6cce3 Dietrich Moerman Added hide moderator list feature settable per forum.
dietrichm authored
212 'forum_moderators' => ( !$topicdata['hide_mods_list'] ) ? sprintf($lang['ModeratorList'], $forum_moderators) : '',
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
213 'new_topic_link' => $new_topic_link,
02e1a0b Dietrich Moerman paging
dietrichm authored
214 'reply_link' => $reply_link,
fb31073 Dietrich Moerman language variables controlled by template parser
dietrichm authored
215 'page_links' => $page_links
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
216 ));
217
02e1a0b Dietrich Moerman paging
dietrichm authored
218 $avatars_query_part = ( !$functions->get_config('hide_avatars') ) ? ', u.avatar_type, u.avatar_remote' : '';
4591049 Dietrich Moerman Added feature 1061847: Hide user information in posts.
dietrichm authored
219 $userinfo_query_part = ( !$functions->get_config('hide_userinfo') ) ? ', u.posts, u.regdate, u.location' : '';
02e1a0b Dietrich Moerman paging
dietrichm authored
220 $signatures_query_part1 = ( !$functions->get_config('hide_signatures') ) ? ', p.enable_sig' : '';
221 $signatures_query_part2 = ( !$functions->get_config('hide_signatures') ) ? ', u.signature' : '';
222
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
223 $result = $db->query("SELECT p.id, p.poster_id, p.poster_guest, p.poster_ip_addr, p.content, p.post_time, p.enable_bbcode, p.enable_smilies".$signatures_query_part1.", p.enable_html, p.post_edit_time, p.post_edit_by, u.displayed_name AS poster_name, u.level AS poster_level, u.rank".$avatars_query_part.$userinfo_query_part.$signatures_query_part2." FROM ( ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."members u ON p.poster_id = u.id ) WHERE p.topic_id = ".$requested_topic." ORDER BY p.post_time ASC LIMIT ".$limit_start.", ".$limit_end);
02e1a0b Dietrich Moerman paging
dietrichm authored
224
19ee164 Dietrich Moerman changed to replies instead of posts
dietrichm authored
225 $i = (( $page - 1 ) * $functions->get_config('posts_per_page') - 1);
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
226 $new_post_anchor_set = false;
227
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
228 while ( $postsdata = $db->fetch_result($result) ) {
229
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
230 //
231 // Loop through the posts
232 //
233
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
234 //
235 // Used for switching colors in template
236 //
14cc7d6 Dietrich Moerman num_rows and isset removing
dietrichm authored
237 $colornum = ( $i % 2 ) ? 1 : 2;
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
238
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
239 //
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
240 // Post count
241 //
02e1a0b Dietrich Moerman paging
dietrichm authored
242 $i++;
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
243
2f16b78 Dietrich Moerman better detect new post in topic
dietrichm authored
244 if ( $session->sess_info['user_id'] ) {
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
245
2f16b78 Dietrich Moerman better detect new post in topic
dietrichm authored
246 $previous_view = ( array_key_exists($requested_topic, $_SESSION['viewed_topics']) ) ? $_SESSION['viewed_topics'][$requested_topic] : $_SESSION['previous_visit'];
247
248 if ( !$new_post_anchor_set && $previous_view < $postsdata['post_time'] ) {
249
250 $new_post_anchor = '<a name="newpost"></a>';
251 $new_post_anchor_set = true;
252
253 } else {
254
255 $new_post_anchor = '';
256
257 }
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
258
259 } else {
260
261 $new_post_anchor = '';
262
263 }
264
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
265 //
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
266 // This poster was logged in
267 //
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
268 if ( !empty($postsdata['poster_id']) ) {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
269
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
270 //
271 // Its name and profile link
272 //
273 $poster_name = $functions->make_profile_link($postsdata['poster_id'], $postsdata['poster_name'], $postsdata['poster_level']);
274
275 //
276 // Its rank
277 // If he has a custom rank, use it, otherwise use the level information
278 //
279 if ( !empty($postsdata['rank']) ) {
280
277546d Dietrich Moerman Final fix for Cyrillic (and other) character sets.
dietrichm authored
281 $poster_rank = unhtml(stripslashes($postsdata['rank']));
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
282
283 } else {
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
284
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
285 switch ( $postsdata['poster_level'] ) {
286
287 case 3:
288 $poster_rank = $lang['Administrator'];
289 break;
290 case 2:
291 $poster_rank = $lang['Moderator'];
292 break;
293 case 1:
294 $poster_rank = $lang['Member'];
295 break;
296
297 }
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
298
299 }
300
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
301 //
302 // User's avatar
303 //
11df2df Dietrich Moerman Added force avatars width and height config settings.
dietrichm authored
304 if ( $functions->get_config('hide_avatars') || !$postsdata['avatar_type'] ) {
305
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
306 $avatar = '';
11df2df Dietrich Moerman Added force avatars width and height config settings.
dietrichm authored
307
308 } elseif ( intval($postsdata['avatar_type']) === 1 ) {
309
310 $avatar_force_width = ( $functions->get_config('avatars_force_width') ) ? ' width="'.intval($functions->get_config('avatars_force_width')).'"' : '';
311 $avatar_force_height = ( $functions->get_config('avatars_force_height') ) ? ' height="'.intval($functions->get_config('avatars_force_height')).'"' : '';
312 $avatar = '<img src="'.$postsdata['avatar_remote'].'" alt=""'.$avatar_force_width.$avatar_force_height.' />';
313
314 }
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
315
316 } else {
317
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
318 //
319 // The poster was a guest
320 //
277546d Dietrich Moerman Final fix for Cyrillic (and other) character sets.
dietrichm authored
321 $poster_name = unhtml(stripslashes($postsdata['poster_guest']));
781faf6 Dietrich Moerman Many, many updates, fixes and additions. Topics are replyable, however y...
dietrichm authored
322 $poster_rank = $lang['Guest'];
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
323 $avatar = '';
324
325 }
326
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
327
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
328 $post_topic_title = ( ( $i ) ? $lang['Re'].' ' : '' ) . $topic_title;
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
329
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
330 //
331 // Links used to control posts: quote, edit, delete...
332 //
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
333 $post_links = array();
84fea4e Dietrich Moerman Added feature #338: Allow users to delete their own posts.
dietrichm authored
334
03339db Dietrich Moerman Added block when lower leveled tries to edit posts of higher leveled.
dietrichm authored
335 if ( $session->sess_info['user_id'] && ( $postsdata['poster_id'] == $session->sess_info['user_id'] || $functions->auth($topicdata['auth'], 'edit', $topicdata['forum_id']) ) && $postsdata['poster_level'] <= $session->sess_info['user_info']['level'] )
cc1ae2c Dietrich Moerman removed buttons
dietrichm authored
336 $post_links[] = '<a href="'.$functions->make_url('edit.php', array('post' => $postsdata['id'])).'">'.$lang['Edit'].'</a>';
84fea4e Dietrich Moerman Added feature #338: Allow users to delete their own posts.
dietrichm authored
337
03339db Dietrich Moerman Added block when lower leveled tries to edit posts of higher leveled.
dietrichm authored
338 if ( $session->sess_info['user_id'] && ( ( $postsdata['poster_id'] == $session->sess_info['user_id'] && $topicdata['last_post_id'] == $postsdata['id'] ) || $functions->auth($topicdata['auth'], 'delete', $topicdata['forum_id']) ) && $postsdata['poster_level'] <= $session->sess_info['user_info']['level'] )
cc1ae2c Dietrich Moerman removed buttons
dietrichm authored
339 $post_links[] = '<a href="'.$functions->make_url('edit.php', array('post' => $postsdata['id'], 'act' => 'delete')).'">'.$lang['Delete'].'</a>';
84fea4e Dietrich Moerman Added feature #338: Allow users to delete their own posts.
dietrichm authored
340
9616ff2 Dietrich Moerman Replace level integers with constants.
dietrichm authored
341 if ( ( !$topicdata['status_locked'] || $functions->auth($topicdata['auth'], 'lock', $topicdata['forum_id']) ) && ( $topicdata['forum_status'] || $functions->get_user_level() == LEVEL_ADMIN ) && $functions->auth($topicdata['auth'], 'reply', $topicdata['forum_id']) )
48e844e Dietrich Moerman don't index quote forms
dietrichm authored
342 $post_links[] = '<a href="'.$functions->make_url('post.php', array('topic' => $requested_topic, 'quotepost' => $postsdata['id'])).'" rel="nofollow">'.$lang['Quote'].'</a>';
84fea4e Dietrich Moerman Added feature #338: Allow users to delete their own posts.
dietrichm authored
343
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
344 if ( count($post_links) )
cc1ae2c Dietrich Moerman removed buttons
dietrichm authored
345 $post_links = join($template->get_config('postlinks_item_delimiter'), $post_links);
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
346 else
347 $post_links = '';
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
348
aead24c Dietrich Moerman Added show edit post message timeout.
dietrichm authored
349 if ( $postsdata['post_edit_time'] && ( $postsdata['post_edit_time'] > ( $postsdata['post_time'] + intval($functions->get_config('show_edited_message_timeout')) ) ) ) {
4b0d7ae Dietrich Moerman Added edit information viewing in topics.
dietrichm authored
350
ef32090 Dietrich Moerman don't fetch post editor info if editor is the same as the poster
dietrichm authored
351 if ( $postsdata['post_edit_by'] === $postsdata['poster_id'] ) {
352
353 $editer_info = $postsdata;
354
355 } else {
356
fb03288 Dietrich Moerman Better SQL error catching.
dietrichm authored
357 $result2 = $db->query("SELECT displayed_name AS poster_name, level AS poster_level FROM ".TABLE_PREFIX."members WHERE id = ".$postsdata['post_edit_by']);
ef32090 Dietrich Moerman don't fetch post editor info if editor is the same as the poster
dietrichm authored
358 $editer_info = $db->fetch_result($result2);
359
360 }
361
f1d6ba0 Dietrich Moerman unknown user edited
dietrichm authored
362 $post_editby = ( $postsdata['post_edit_by'] ) ? $functions->make_profile_link($postsdata['post_edit_by'], $editer_info['poster_name'], $editer_info['poster_level']) : $lang['Unknown'];
363 $post_editinfo = sprintf($template->get_config('post_editinfo_format'), sprintf($lang['PostEditInfo'], $post_editby, $functions->make_date($postsdata['post_edit_time'])));
4b0d7ae Dietrich Moerman Added edit information viewing in topics.
dietrichm authored
364
365 } else {
366
367 $post_editinfo = '';
368
369 }
370
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
371 //
372 // Output the post
373 //
7d10ecb Dietrich Moerman major template name changes
dietrichm authored
374 $template->parse('post', 'topic', array(
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
375 'poster_name' => $poster_name,
781faf6 Dietrich Moerman Many, many updates, fixes and additions. Topics are replyable, however y...
dietrichm authored
376 'poster_rank' => $poster_rank,
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
377 'poster_avatar' => $avatar,
4591049 Dietrich Moerman Added feature 1061847: Hide user information in posts.
dietrichm authored
378 'posts' => ( !empty($postsdata['poster_id']) && !$functions->get_config('hide_userinfo') ) ? $lang['Posts'].': '.$postsdata['posts'] : '',
279efcc Dietrich Moerman Added feature #370: Date and Time Translation.
dietrichm authored
379 'registered' => ( !empty($postsdata['poster_id']) && !$functions->get_config('hide_userinfo') ) ? $lang['Registered'].': '.$functions->make_date($postsdata['regdate'], 'M y') : '',
277546d Dietrich Moerman Final fix for Cyrillic (and other) character sets.
dietrichm authored
380 'location' => ( !empty($postsdata['poster_id']) && !empty($postsdata['location']) && !$functions->get_config('hide_userinfo') ) ? $lang['Location'].': '.unhtml(stripslashes($postsdata['location'])) : '',
07795a4 Dietrich Moerman Added jump to new post in topic link.
dietrichm authored
381 'topic_title' => $post_topic_title,
5546f0d Dietrich Moerman Don't let Google index all post links with duplicate content.
dietrichm authored
382 'post_anchor' => '<a href="'.$functions->make_url('topic.php', array('post' => $postsdata['id'])).'#post'.$postsdata['id'].'" name="post'.$postsdata['id'].'" rel="nofollow">#'.$i.'</a>'.$new_post_anchor,
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
383 'post_date' => $functions->make_date($postsdata['post_time']),
384 'post_links' => $post_links,
4f4e6d4 Dietrich Moerman Added bad words filter.
dietrichm authored
385 'post_content' => $functions->markup($functions->replace_badwords(stripslashes($postsdata['content'])), $postsdata['enable_bbcode'], $postsdata['enable_smilies'], $postsdata['enable_html']),
db7b15d Dietrich Moerman extend badwords replace to signatures
dietrichm authored
386 'poster_sig' => ( !$functions->get_config('hide_signatures') && !empty($postsdata['signature']) && $postsdata['enable_sig'] ) ? sprintf($template->get_config('sig_format'), $functions->markup($functions->replace_badwords(stripslashes($postsdata['signature'])), $functions->get_config('sig_allow_bbcode'), $functions->get_config('sig_allow_smilies'))) : '',
4b0d7ae Dietrich Moerman Added edit information viewing in topics.
dietrichm authored
387 'post_editinfo' => $post_editinfo,
11c873a Dietrich Moerman Added to ACP: IP address lookup.
dietrichm authored
388 'poster_ip_addr' => ( !empty($postsdata['poster_ip_addr']) && $functions->get_user_level() == LEVEL_ADMIN ) ? sprintf($template->get_config('poster_ip_addr_format'), sprintf($lang['ViewingIP'], '<a href="'.$functions->make_url('admin.php', array('act' => 'iplookup', 'ip' => $postsdata['poster_ip_addr'])).'">'.$postsdata['poster_ip_addr'].'</a>')) : '',
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
389 'colornum' => $colornum
390 ));
391
392 }
393
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
394 //
395 // Links for controlling topics: delete, move, lock, sticky...
396 //
397 $action_links = array();
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
398
399 if ( $session->sess_info['user_id'] ) {
400
401 if ( !$subscribed )
402 $action_links[] = '<a href="'.$functions->make_url('topic.php', array('id' => $requested_topic, 'act' => 'subscribe')).'">'.$lang['SubscribeTopic'].'</a>';
403 else
404 $action_links[] = '<a href="'.$functions->make_url('topic.php', array('id' => $requested_topic, 'act' => 'unsubscribe')).'">'.$lang['UnsubscribeTopic'].'</a>';
405
406 }
407
14286cd Dietrich Moerman Added trash topic feature (moves topic to predefined trash forum).
dietrichm authored
408 if ( $functions->auth($topicdata['auth'], 'delete', $topicdata['forum_id']) )
02e1a0b Dietrich Moerman paging
dietrichm authored
409 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'delete')).'">'.$lang['DeleteTopic'].'</a>';
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
410
a9fabfb Dietrich Moerman fix for only 1 forum
dietrichm authored
411 if ( $functions->auth($topicdata['auth'], 'move', $topicdata['forum_id']) && intval($functions->get_stats('viewable_forums')) > 1 )
02e1a0b Dietrich Moerman paging
dietrichm authored
412 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'move')).'">'.$lang['MoveTopic'].'</a>';
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
413
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
414 if ( $functions->auth($topicdata['auth'], 'lock', $topicdata['forum_id']) ) {
415
416 if ( $topicdata['status_locked'] )
02e1a0b Dietrich Moerman paging
dietrichm authored
417 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'unlock')).'">'.$lang['UnlockTopic'].'</a>';
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
418 else
02e1a0b Dietrich Moerman paging
dietrichm authored
419 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'lock')).'">'.$lang['LockTopic'].'</a>';
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
420
421 }
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
422
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
423 if ( $functions->auth($topicdata['auth'], 'sticky', $topicdata['forum_id']) ) {
424
425 if ( $topicdata['status_sticky'] )
02e1a0b Dietrich Moerman paging
dietrichm authored
426 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'unsticky')).'">'.$lang['MakeNormalTopic'].'</a>';
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
427 else
02e1a0b Dietrich Moerman paging
dietrichm authored
428 $action_links[] = '<a href="'.$functions->make_url('edit.php', array('topic' => $requested_topic, 'act' => 'sticky')).'">'.$lang['MakeSticky'].'</a>';
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
429
430 }
7005d31 Dietrich Moerman Added topic subscription feature.
dietrichm authored
431
cc1ae2c Dietrich Moerman removed buttons
dietrichm authored
432 $action_links = join($template->get_config('item_delimiter'), $action_links);
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
433
7d10ecb Dietrich Moerman major template name changes
dietrichm authored
434 $template->parse('footer', 'topic', array(
d0dfd63 Dietrich Moerman Changes to templates, new buttons, small fixes. See Changelog.txt.
dietrichm authored
435 'new_topic_link' => $new_topic_link,
436 'reply_link' => $reply_link,
02e1a0b Dietrich Moerman paging
dietrichm authored
437 'page_links' => $page_links,
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
438 'action_links' => $action_links
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
439 ));
440
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
441 //
442 // Neat feature: the quick reply
443 // Only shown if enabled, if user can reply and if user can post in lcoked forum...
444 //
9616ff2 Dietrich Moerman Replace level integers with constants.
dietrichm authored
445 if ( $functions->get_config('enable_quickreply') && ( !$topicdata['status_locked'] || $functions->auth($topicdata['auth'], 'lock', $topicdata['forum_id']) ) && ( $topicdata['forum_status'] || $functions->get_user_level() == LEVEL_ADMIN ) && $functions->auth($topicdata['auth'], 'reply', $topicdata['forum_id']) ) {
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
446
38780cd Dietrich Moerman Added feature that saves the guest's username in the session.
dietrichm authored
447 //
448 // Get session saved guest's username if there is one
449 //
277546d Dietrich Moerman Final fix for Cyrillic (and other) character sets.
dietrichm authored
450 $username = ( !$session->sess_info['user_id'] && !empty($_SESSION['user']) ) ? unhtml(stripslashes($_SESSION['user'])) : '';
38780cd Dietrich Moerman Added feature that saves the guest's username in the session.
dietrichm authored
451
dd63bfe Dietrich Moerman Added auto subscribe feature.
dietrichm authored
452 $subscribe_topic = ( $session->sess_info['user_id'] && $session->sess_info['user_info']['auto_subscribe_reply'] ) ? 1 : 0;
453
c9b5378 Dietrich Moerman OMG HUGE update. Check Changelog.txt. ;)
dietrichm authored
454 $template->parse('quick_reply', 'topic', array(
02e1a0b Dietrich Moerman paging
dietrichm authored
455 'form_begin' => '<form action="'.$functions->make_url('post.php', array('topic' => $requested_topic)).'" method="post">',
da53918 Dietrich Moerman Removed obsolete username_max_length.
dietrichm authored
456 'username_input' => ( $session->sess_info['user_id'] ) ? '<a href="'.$functions->make_url('profile.php', array('id' => $session->sess_info['user_info']['id'])).'">'.unhtml(stripslashes($session->sess_info['user_info']['displayed_name'])).'</a>' : '<input type="text" size="25" maxlength="255" name="user" value="'.$username.'" />',
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
457 'content_input' => '<textarea rows="'.$template->get_config('quick_reply_textarea_rows').'" cols="'.$template->get_config('textarea_cols').'" name="content"></textarea>',
dd63bfe Dietrich Moerman Added auto subscribe feature.
dietrichm authored
458 'submit_button' => '<input type="submit" name="submit" value="'.$lang['OK'].'" /><input type="hidden" name="enable_bbcode" value="1" /><input type="hidden" name="enable_smilies" value="1" /><input type="hidden" name="enable_sig" value="1" /><input type="hidden" name="subscribe_topic" value="'.$subscribe_topic.'" />',
7de99fb Dietrich Moerman Added preview feature for posting new topics and replies.
dietrichm authored
459 'preview_button' => '<input type="submit" name="preview" value="'.$lang['Preview'].'" />',
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
460 'reset_button' => '<input type="reset" value="'.$lang['Reset'].'" />',
bd5a48a Dietrich Moerman tidier
dietrichm authored
461 'form_end' => '</form>'
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
462 ));
463
464 }
465
2f16b78 Dietrich Moerman better detect new post in topic
dietrichm authored
466 $_SESSION['viewed_topics'][$requested_topic] = time();
467
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
468 } else {
469
470 //
b723e1c Dietrich Moerman This is UseBB 0.2. Official release will follow very soon! :D
dietrichm authored
471 // The user is not granted to view this topic
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
472 //
473 $functions->redir_to_login();
474
475 }
476
477 }
478
479 //
480 // Include the page footer
481 //
482 require(ROOT_PATH.'sources/page_foot.php');
483
484 } else {
485
486 //
487 // There's no forum ID! Get us back to the index...
488 //
f24e050 Dietrich Moerman New redirect functions provide easier and more robust redirecting.
dietrichm authored
489 $functions->redirect('index.php');
837f69d Dietrich Moerman Many, many incomplete updates. Please don't use this CVS revision, as it...
dietrichm authored
490
491 }
492
493 ?>
Something went wrong with that request. Please try again.