]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2_old/includes/topic_review.php
Baseline
[www.vanrenterghem.biz.git] / phpBB2_old / includes / topic_review.php
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.3 2004/11/18 17:49:45 acydburn Exp $
10  *
11  *
12  ***************************************************************************/
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  ***************************************************************************/
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;
31         if ( !$is_inline_review )
32         {
33                 if ( !isset($topic_id) || !$topic_id)
34                 {
35                         message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
36                 }
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                         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                 }
50                 if ( !($forum_row = $db->sql_fetchrow($result)) )
51                 {
52                         message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
53                 }
54                 $db->sql_freeresult($result);
56                 $forum_id = $forum_row['forum_id'];
57                 $topic_title = $forum_row['topic_title'];
58                 
59                 //
60                 // Start session management
61                 //
62                 $userdata = session_pagestart($user_ip, $forum_id);
63                 init_userprefs($userdata);
64                 //
65                 // End session management
66                 //
68                 $is_auth = array();
69                 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
71                 if ( !$is_auth['auth_read'] )
72                 {
73                         message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
74                 }
75         }
77         //
78         // Define censored word matches
79         //
80         if ( empty($orig_word) && empty($replacement_word) )
81         {
82                 $orig_word = array();
83                 $replacement_word = array();
85                 obtain_word_list($orig_word, $replacement_word);
86         }
88         //
89         // Dump out the page header and load viewtopic body template
90         //
91         if ( !$is_inline_review )
92         {
93                 $gen_simple_header = TRUE;
95                 $page_title = $lang['Topic_review'] . ' - ' . $topic_title;
96                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
98                 $template->set_filenames(array(
99                         'reviewbody' => 'posting_topic_review.tpl')
100                 );
101         }
103         //
104         // Go ahead and pull all data for this topic
105         //
106         $sql = "SELECT u.username, u.user_id, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
107                 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
108                 WHERE p.topic_id = $topic_id
109                         AND p.poster_id = u.user_id
110                         AND p.post_id = pt.post_id
111                 ORDER BY p.post_time DESC
112                 LIMIT " . $board_config['posts_per_page'];
113         if ( !($result = $db->sql_query($sql)) )
114         {
115                 message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
116         }
118         //
119         // Okay, let's do the loop, yeah come on baby let's do the loop
120         // and it goes like this ...
121         //
122         if ( $row = $db->sql_fetchrow($result) )
123         {
124                 $mini_post_img = $images['icon_minipost'];
125                 $mini_post_alt = $lang['Post'];
127                 $i = 0;
128                 do
129                 {
130                         $poster_id = $row['user_id'];
131                         $poster = $row['username'];
133                         $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
135                         //
136                         // Handle anon users posting with usernames
137                         //
138                         if( $poster_id == ANONYMOUS && $row['post_username'] != '' )
139                         {
140                                 $poster = $row['post_username'];
141                                 $poster_rank = $lang['Guest'];
142                         }
143                         elseif ( $poster_id == ANONYMOUS )
144                         {
145                                 $poster = $lang['Guest'];
146                                 $poster_rank = '';
147                         }
149                         $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
151                         $message = $row['post_text'];
152                         $bbcode_uid = $row['bbcode_uid'];
154                         //
155                         // If the board has HTML off but the post has HTML
156                         // on then we process it, else leave it alone
157                         //
158                         if ( !$board_config['allow_html'] && $row['enable_html'] )
159                         {
160                                 $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\2&gt;', $message);
161                         }
163                         if ( $bbcode_uid != "" )
164                         {
165                                 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
166                         }
168                         $message = make_clickable($message);
170                         if ( count($orig_word) )
171                         {
172                                 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
173                                 $message = preg_replace($orig_word, $replacement_word, $message);
174                         }
176                         if ( $board_config['allow_smilies'] && $row['enable_smilies'] )
177                         {
178                                 $message = smilies_pass($message);
179                         }
181                         $message = str_replace("\n", '<br />', $message);
183                         //
184                         // Again this will be handled by the templating
185                         // code at some point
186                         //
187                         $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
188                         $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
190                         $template->assign_block_vars('postrow', array(
191                                 'ROW_COLOR' => '#' . $row_color, 
192                                 'ROW_CLASS' => $row_class, 
194                                 'MINI_POST_IMG' => $mini_post_img, 
195                                 'POSTER_NAME' => $poster, 
196                                 'POST_DATE' => $post_date, 
197                                 'POST_SUBJECT' => $post_subject, 
198                                 'MESSAGE' => $message,
199                                         
200                                 'L_MINI_POST_ALT' => $mini_post_alt)
201                         );
203                         $i++;
204                 }
205                 while ( $row = $db->sql_fetchrow($result) );
206         }
207         else
208         {
209                 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', '', __LINE__, __FILE__, $sql);
210         }
211         $db->sql_freeresult($result);
213         $template->assign_vars(array(
214                 'L_AUTHOR' => $lang['Author'],
215                 'L_MESSAGE' => $lang['Message'],
216                 'L_POSTED' => $lang['Posted'],
217                 'L_POST_SUBJECT' => $lang['Post_subject'], 
218                 'L_TOPIC_REVIEW' => $lang['Topic_review'])
219         );
221         if ( !$is_inline_review )
222         {
223                 $template->pparse('reviewbody');
224                 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
225         }
228 ?>