1 rizwank 1.1 <?php
2 /***************************************************************************
3 * topic_review.php
4 * -------------------
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
8 *
9 * $Id: topic_review.php,v 1.5.2.1 2002/05/03 15:58:35 the_systech Exp $
10 *
11 *
12 ***************************************************************************/
13
14 /***************************************************************************
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 *
22 rizwank 1.1 ***************************************************************************/
23
24 function topic_review($topic_id, $is_inline_review)
25 {
26 global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
27 global $userdata, $user_ip;
28 global $orig_word, $replacement_word;
29 global $starttime;
30
31 if ( !$is_inline_review )
32 {
33 if ( !isset($topic_id) )
34 {
35 message_die(GENERAL_MESSAGE, 'Topic_not_exist');
36 }
37
38 //
39 // Get topic info ...
40 //
41 $sql = "SELECT t.topic_title, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments
42 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
43 rizwank 1.1 WHERE t.topic_id = $topic_id
44 AND f.forum_id = t.forum_id";
45 if ( !($result = $db->sql_query($sql)) )
46 {
47 message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
48 }
49
50 if ( !($forum_row = $db->sql_fetchrow($result)) )
51 {
52 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
53 }
54
55 $forum_id = $forum_row['forum_id'];
56 $topic_title = $forum_row['topic_title'];
57
58 //
59 // Start session management
60 //
61 $userdata = session_pagestart($user_ip, $forum_id);
62 init_userprefs($userdata);
63 //
64 rizwank 1.1 // End session management
65 //
66
67 $is_auth = array();
68 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
69
70 if ( !$is_auth['auth_read'] )
71 {
72 message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
73 }
74 }
75
76 //
77 // Define censored word matches
78 //
79 if ( empty($orig_word) && empty($replacement_word) )
80 {
81 $orig_word = array();
82 $replacement_word = array();
83
84 obtain_word_list($orig_word, $replacement_word);
85 rizwank 1.1 }
86
87 //
88 // Dump out the page header and load viewtopic body template
89 //
90 if ( !$is_inline_review )
91 {
92 $gen_simple_header = TRUE;
93
94 $page_title = $lang['Topic_review'] . ' - ' . $topic_title;
95 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
96
97 $template->set_filenames(array(
98 'reviewbody' => 'posting_topic_review.tpl')
99 );
100 }
101
102 //
103 // Go ahead and pull all data for this topic
104 //
105 $sql = "SELECT u.username, u.user_id, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
106 rizwank 1.1 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
107 WHERE p.topic_id = $topic_id
108 AND p.poster_id = u.user_id
109 AND p.post_id = pt.post_id
110 ORDER BY p.post_time DESC
111 LIMIT " . $board_config['posts_per_page'];
112 if ( !($result = $db->sql_query($sql)) )
113 {
114 message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
115 }
116
117 //
118 // Okay, let's do the loop, yeah come on baby let's do the loop
119 // and it goes like this ...
120 //
121 if ( $row = $db->sql_fetchrow($result) )
122 {
123 $mini_post_img = $images['icon_minipost'];
124 $mini_post_alt = $lang['Post'];
125
126 $i = 0;
127 rizwank 1.1 do
128 {
129 $poster_id = $row['user_id'];
130 $poster = $row['username'];
131
132 $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
133
134 //
135 // Handle anon users posting with usernames
136 //
137 if( $poster_id == ANONYMOUS && $row['post_username'] != '' )
138 {
139 $poster = $row['post_username'];
140 $poster_rank = $lang['Guest'];
141 }
142 elseif ( $poster_id == ANONYMOUS )
143 {
144 $poster = $lang['Guest'];
145 $poster_rank = '';
146 }
147
148 rizwank 1.1 $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
149
150 $message = $row['post_text'];
151 $bbcode_uid = $row['bbcode_uid'];
152
153 //
154 // If the board has HTML off but the post has HTML
155 // on then we process it, else leave it alone
156 //
157 if ( !$board_config['allow_html'] && $row['enable_html'] )
158 {
159 $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $message);
160 }
161
162 if ( $bbcode_uid != "" )
163 {
164 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
165 }
166
167 $message = make_clickable($message);
168
169 rizwank 1.1 if ( count($orig_word) )
170 {
171 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
172 $message = preg_replace($orig_word, $replacement_word, $message);
173 }
174
175 if ( $board_config['allow_smilies'] && $row['enable_smilies'] )
176 {
177 $message = smilies_pass($message);
178 }
179
180 $message = str_replace("\n", '<br />', $message);
181
182 //
183 // Again this will be handled by the templating
184 // code at some point
185 //
186 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
187 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
188
189 $template->assign_block_vars('postrow', array(
190 rizwank 1.1 'ROW_COLOR' => '#' . $row_color,
191 'ROW_CLASS' => $row_class,
192
193 'MINI_POST_IMG' => $mini_post_img,
194 'POSTER_NAME' => $poster,
195 'POST_DATE' => $post_date,
196 'POST_SUBJECT' => $post_subject,
197 'MESSAGE' => $message,
198
199 'L_MINI_POST_ALT' => $mini_post_alt)
200 );
201
202 $i++;
203 }
204 while ( $row = $db->sql_fetchrow($result) );
205 }
206 else
207 {
208 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', '', __LINE__, __FILE__, $sql);
209 }
210
211 rizwank 1.1 $template->assign_vars(array(
212 'L_AUTHOR' => $lang['Author'],
213 'L_MESSAGE' => $lang['Message'],
214 'L_POSTED' => $lang['Posted'],
215 'L_POST_SUBJECT' => $lang['Post_subject'],
216 'L_TOPIC_REVIEW' => $lang['Topic_review'])
217 );
218
219 if ( !$is_inline_review )
220 {
221 $template->pparse('reviewbody');
222 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
223 }
224 }
225
226 ?>
|