1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @package mcp
|
---|
5 | * @version $Id$
|
---|
6 | * @copyright (c) 2005 phpBB Group
|
---|
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * @ignore
|
---|
13 | */
|
---|
14 | if (!defined('IN_PHPBB'))
|
---|
15 | {
|
---|
16 | exit;
|
---|
17 | }
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * mcp_reports
|
---|
21 | * Handling the reports queue
|
---|
22 | * @package mcp
|
---|
23 | */
|
---|
24 | class mcp_reports
|
---|
25 | {
|
---|
26 | var $p_master;
|
---|
27 | var $u_action;
|
---|
28 |
|
---|
29 | function mcp_reports(&$p_master)
|
---|
30 | {
|
---|
31 | $this->p_master = &$p_master;
|
---|
32 | }
|
---|
33 |
|
---|
34 | function main($id, $mode)
|
---|
35 | {
|
---|
36 | global $auth, $db, $user, $template, $cache;
|
---|
37 | global $config, $phpbb_root_path, $phpEx, $action;
|
---|
38 |
|
---|
39 | include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
---|
40 |
|
---|
41 | $forum_id = request_var('f', 0);
|
---|
42 | $start = request_var('start', 0);
|
---|
43 |
|
---|
44 | $this->page_title = 'MCP_REPORTS';
|
---|
45 |
|
---|
46 | switch ($action)
|
---|
47 | {
|
---|
48 | case 'close':
|
---|
49 | case 'delete':
|
---|
50 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
---|
51 |
|
---|
52 | $report_id_list = request_var('report_id_list', array(0));
|
---|
53 |
|
---|
54 | if (!sizeof($report_id_list))
|
---|
55 | {
|
---|
56 | trigger_error('NO_REPORT_SELECTED');
|
---|
57 | }
|
---|
58 |
|
---|
59 | close_report($report_id_list, $mode, $action);
|
---|
60 |
|
---|
61 | break;
|
---|
62 | }
|
---|
63 |
|
---|
64 | switch ($mode)
|
---|
65 | {
|
---|
66 | case 'report_details':
|
---|
67 |
|
---|
68 | $user->add_lang(array('posting', 'viewforum', 'viewtopic'));
|
---|
69 |
|
---|
70 | $post_id = request_var('p', 0);
|
---|
71 |
|
---|
72 | // closed reports are accessed by report id
|
---|
73 | $report_id = request_var('r', 0);
|
---|
74 |
|
---|
75 | $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
|
---|
76 | FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
|
---|
77 | WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '
|
---|
78 | AND rr.reason_id = r.reason_id
|
---|
79 | AND r.user_id = u.user_id
|
---|
80 | AND r.pm_id = 0
|
---|
81 | ORDER BY report_closed ASC';
|
---|
82 | $result = $db->sql_query_limit($sql, 1);
|
---|
83 | $report = $db->sql_fetchrow($result);
|
---|
84 | $db->sql_freeresult($result);
|
---|
85 |
|
---|
86 | if (!$report)
|
---|
87 | {
|
---|
88 | trigger_error('NO_REPORT');
|
---|
89 | }
|
---|
90 |
|
---|
91 | if (!$report_id && $report['report_closed'])
|
---|
92 | {
|
---|
93 | trigger_error('REPORT_CLOSED');
|
---|
94 | }
|
---|
95 |
|
---|
96 | $post_id = $report['post_id'];
|
---|
97 | $report_id = $report['report_id'];
|
---|
98 |
|
---|
99 | $post_info = get_post_data(array($post_id), 'm_report', true);
|
---|
100 |
|
---|
101 | if (!sizeof($post_info))
|
---|
102 | {
|
---|
103 | trigger_error('NO_REPORT_SELECTED');
|
---|
104 | }
|
---|
105 |
|
---|
106 | $post_info = $post_info[$post_id];
|
---|
107 |
|
---|
108 | $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
|
---|
109 | if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]))
|
---|
110 | {
|
---|
111 | $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
|
---|
112 | $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
|
---|
113 | }
|
---|
114 |
|
---|
115 | if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false))
|
---|
116 | {
|
---|
117 | $template->assign_vars(array(
|
---|
118 | 'S_TOPIC_REVIEW' => true,
|
---|
119 | 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'],
|
---|
120 | 'TOPIC_TITLE' => $post_info['topic_title'])
|
---|
121 | );
|
---|
122 | }
|
---|
123 |
|
---|
124 | $topic_tracking_info = $extensions = $attachments = array();
|
---|
125 | // Get topic tracking info
|
---|
126 | if ($config['load_db_lastread'])
|
---|
127 | {
|
---|
128 | $tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
---|
129 | $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
---|
130 | unset($tmp_topic_data);
|
---|
131 | }
|
---|
132 | else
|
---|
133 | {
|
---|
134 | $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
---|
135 | }
|
---|
136 |
|
---|
137 | $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
---|
138 |
|
---|
139 | // Process message, leave it uncensored
|
---|
140 | $message = $post_info['post_text'];
|
---|
141 |
|
---|
142 | if ($post_info['bbcode_bitfield'])
|
---|
143 | {
|
---|
144 | include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
---|
145 | $bbcode = new bbcode($post_info['bbcode_bitfield']);
|
---|
146 | $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
---|
147 | }
|
---|
148 |
|
---|
149 | $message = bbcode_nl2br($message);
|
---|
150 | $message = smiley_text($message);
|
---|
151 |
|
---|
152 | if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
|
---|
153 | {
|
---|
154 | $sql = 'SELECT *
|
---|
155 | FROM ' . ATTACHMENTS_TABLE . '
|
---|
156 | WHERE post_msg_id = ' . $post_id . '
|
---|
157 | AND in_message = 0
|
---|
158 | ORDER BY filetime DESC';
|
---|
159 | $result = $db->sql_query($sql);
|
---|
160 |
|
---|
161 | while ($row = $db->sql_fetchrow($result))
|
---|
162 | {
|
---|
163 | $attachments[] = $row;
|
---|
164 | }
|
---|
165 | $db->sql_freeresult($result);
|
---|
166 |
|
---|
167 | if (sizeof($attachments))
|
---|
168 | {
|
---|
169 | $update_count = array();
|
---|
170 | parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
|
---|
171 | }
|
---|
172 |
|
---|
173 | // Display not already displayed Attachments for this post, we already parsed them. ;)
|
---|
174 | if (!empty($attachments))
|
---|
175 | {
|
---|
176 | $template->assign_var('S_HAS_ATTACHMENTS', true);
|
---|
177 |
|
---|
178 | foreach ($attachments as $attachment)
|
---|
179 | {
|
---|
180 | $template->assign_block_vars('attachment', array(
|
---|
181 | 'DISPLAY_ATTACHMENT' => $attachment)
|
---|
182 | );
|
---|
183 | }
|
---|
184 | }
|
---|
185 | }
|
---|
186 |
|
---|
187 | $template->assign_vars(array(
|
---|
188 | 'S_MCP_REPORT' => true,
|
---|
189 | 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
---|
190 | 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
---|
191 | 'S_POST_REPORTED' => $post_info['post_reported'],
|
---|
192 | 'S_POST_UNAPPROVED' => !$post_info['post_approved'],
|
---|
193 | 'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
---|
194 | 'S_USER_NOTES' => true,
|
---|
195 |
|
---|
196 | 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',
|
---|
197 | 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
---|
198 | 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
---|
199 | 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']),
|
---|
200 | 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
|
---|
201 | 'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',
|
---|
202 | 'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '',
|
---|
203 | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $post_info['forum_id']),
|
---|
204 | 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
|
---|
205 | 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),
|
---|
206 |
|
---|
207 | 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
---|
208 | 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
---|
209 | 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
---|
210 |
|
---|
211 | 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'),
|
---|
212 | 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
---|
213 | 'REPORT_DATE' => $user->format_date($report['report_time']),
|
---|
214 | 'REPORT_ID' => $report_id,
|
---|
215 | 'REPORT_REASON_TITLE' => $reason['title'],
|
---|
216 | 'REPORT_REASON_DESCRIPTION' => $reason['description'],
|
---|
217 | 'REPORT_TEXT' => $report['report_text'],
|
---|
218 |
|
---|
219 | 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
---|
220 | 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
---|
221 | 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
---|
222 | 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
---|
223 |
|
---|
224 | 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']),
|
---|
225 | 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']),
|
---|
226 | 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']),
|
---|
227 | 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']),
|
---|
228 |
|
---|
229 | 'POST_PREVIEW' => $message,
|
---|
230 | 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'],
|
---|
231 | 'POST_DATE' => $user->format_date($post_info['post_time']),
|
---|
232 | 'POST_IP' => $post_info['poster_ip'],
|
---|
233 | 'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
|
---|
234 | 'POST_ID' => $post_info['post_id'],
|
---|
235 |
|
---|
236 | 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '',
|
---|
237 | ));
|
---|
238 |
|
---|
239 | $this->tpl_name = 'mcp_post';
|
---|
240 |
|
---|
241 | break;
|
---|
242 |
|
---|
243 | case 'reports':
|
---|
244 | case 'reports_closed':
|
---|
245 | $topic_id = request_var('t', 0);
|
---|
246 |
|
---|
247 | $forum_info = array();
|
---|
248 | $forum_list_reports = get_forum_list('m_report', false, true);
|
---|
249 | $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs
|
---|
250 |
|
---|
251 | // Remove forums we cannot read
|
---|
252 | foreach ($forum_list_reports as $k => $forum_data)
|
---|
253 | {
|
---|
254 | if (!isset($forum_list_read[$forum_data['forum_id']]))
|
---|
255 | {
|
---|
256 | unset($forum_list_reports[$k]);
|
---|
257 | }
|
---|
258 | }
|
---|
259 | unset($forum_list_read);
|
---|
260 |
|
---|
261 | if ($topic_id)
|
---|
262 | {
|
---|
263 | $topic_info = get_topic_data(array($topic_id));
|
---|
264 |
|
---|
265 | if (!sizeof($topic_info))
|
---|
266 | {
|
---|
267 | trigger_error('TOPIC_NOT_EXIST');
|
---|
268 | }
|
---|
269 |
|
---|
270 | if ($forum_id != $topic_info[$topic_id]['forum_id'])
|
---|
271 | {
|
---|
272 | $topic_id = 0;
|
---|
273 | }
|
---|
274 | else
|
---|
275 | {
|
---|
276 | $topic_info = $topic_info[$topic_id];
|
---|
277 | $forum_id = (int) $topic_info['forum_id'];
|
---|
278 | }
|
---|
279 | }
|
---|
280 |
|
---|
281 | $forum_list = array();
|
---|
282 |
|
---|
283 | if (!$forum_id)
|
---|
284 | {
|
---|
285 | foreach ($forum_list_reports as $row)
|
---|
286 | {
|
---|
287 | $forum_list[] = $row['forum_id'];
|
---|
288 | }
|
---|
289 |
|
---|
290 | if (!sizeof($forum_list))
|
---|
291 | {
|
---|
292 | trigger_error('NOT_MODERATOR');
|
---|
293 | }
|
---|
294 |
|
---|
295 | $global_id = $forum_list[0];
|
---|
296 |
|
---|
297 | $sql = 'SELECT SUM(forum_topics) as sum_forum_topics
|
---|
298 | FROM ' . FORUMS_TABLE . '
|
---|
299 | WHERE ' . $db->sql_in_set('forum_id', $forum_list);
|
---|
300 | $result = $db->sql_query($sql);
|
---|
301 | $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
|
---|
302 | $db->sql_freeresult($result);
|
---|
303 | }
|
---|
304 | else
|
---|
305 | {
|
---|
306 | $forum_info = get_forum_data(array($forum_id), 'm_report');
|
---|
307 |
|
---|
308 | if (!sizeof($forum_info))
|
---|
309 | {
|
---|
310 | trigger_error('NOT_MODERATOR');
|
---|
311 | }
|
---|
312 |
|
---|
313 | $forum_info = $forum_info[$forum_id];
|
---|
314 | $forum_list = array($forum_id);
|
---|
315 | $global_id = $forum_id;
|
---|
316 | }
|
---|
317 |
|
---|
318 | $forum_list[] = 0;
|
---|
319 | $forum_data = array();
|
---|
320 |
|
---|
321 | $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
|
---|
322 | foreach ($forum_list_reports as $row)
|
---|
323 | {
|
---|
324 | $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>';
|
---|
325 | $forum_data[$row['forum_id']] = $row;
|
---|
326 | }
|
---|
327 | unset($forum_list_reports);
|
---|
328 |
|
---|
329 | $sort_days = $total = 0;
|
---|
330 | $sort_key = $sort_dir = '';
|
---|
331 | $sort_by_sql = $sort_order_sql = array();
|
---|
332 | mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
|
---|
333 |
|
---|
334 | $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
|
---|
335 | $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : '';
|
---|
336 |
|
---|
337 | if ($mode == 'reports')
|
---|
338 | {
|
---|
339 | $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0';
|
---|
340 | }
|
---|
341 | else
|
---|
342 | {
|
---|
343 | $report_state = 'AND r.report_closed = 1';
|
---|
344 | }
|
---|
345 |
|
---|
346 | $sql = 'SELECT r.report_id
|
---|
347 | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . '
|
---|
348 | WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "
|
---|
349 | $report_state
|
---|
350 | AND r.post_id = p.post_id
|
---|
351 | " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
|
---|
352 | ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . '
|
---|
353 | ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
---|
354 | AND t.topic_id = p.topic_id
|
---|
355 | AND r.pm_id = 0
|
---|
356 | $limit_time_sql
|
---|
357 | ORDER BY $sort_order_sql";
|
---|
358 | $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
---|
359 |
|
---|
360 | $i = 0;
|
---|
361 | $report_ids = array();
|
---|
362 | while ($row = $db->sql_fetchrow($result))
|
---|
363 | {
|
---|
364 | $report_ids[] = $row['report_id'];
|
---|
365 | $row_num[$row['report_id']] = $i++;
|
---|
366 | }
|
---|
367 | $db->sql_freeresult($result);
|
---|
368 |
|
---|
369 | if (sizeof($report_ids))
|
---|
370 | {
|
---|
371 | $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id
|
---|
372 | FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru
|
---|
373 | WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . '
|
---|
374 | AND t.topic_id = p.topic_id
|
---|
375 | AND r.post_id = p.post_id
|
---|
376 | AND u.user_id = p.poster_id
|
---|
377 | AND ru.user_id = r.user_id
|
---|
378 | AND r.pm_id = 0
|
---|
379 | ORDER BY ' . $sort_order_sql;
|
---|
380 | $result = $db->sql_query($sql);
|
---|
381 |
|
---|
382 | $report_data = $rowset = array();
|
---|
383 | while ($row = $db->sql_fetchrow($result))
|
---|
384 | {
|
---|
385 | $global_topic = ($row['forum_id']) ? false : true;
|
---|
386 | if ($global_topic)
|
---|
387 | {
|
---|
388 | $row['forum_id'] = $global_id;
|
---|
389 | }
|
---|
390 |
|
---|
391 | $template->assign_block_vars('postrow', array(
|
---|
392 | 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
|
---|
393 | 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'],
|
---|
394 | 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"),
|
---|
395 |
|
---|
396 | 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
---|
397 | 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
---|
398 | 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
---|
399 | 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
---|
400 |
|
---|
401 | 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
---|
402 | 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
---|
403 | 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
---|
404 | 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']),
|
---|
405 |
|
---|
406 | 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'],
|
---|
407 | 'POST_ID' => $row['post_id'],
|
---|
408 | 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
---|
409 | 'POST_TIME' => $user->format_date($row['post_time']),
|
---|
410 | 'REPORT_ID' => $row['report_id'],
|
---|
411 | 'REPORT_TIME' => $user->format_date($row['report_time']),
|
---|
412 | 'TOPIC_TITLE' => $row['topic_title'])
|
---|
413 | );
|
---|
414 | }
|
---|
415 | $db->sql_freeresult($result);
|
---|
416 | unset($report_ids, $row);
|
---|
417 | }
|
---|
418 |
|
---|
419 | // Now display the page
|
---|
420 | $template->assign_vars(array(
|
---|
421 | 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'],
|
---|
422 | 'L_TITLE' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'],
|
---|
423 | 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
---|
424 |
|
---|
425 | 'S_MCP_ACTION' => $this->u_action,
|
---|
426 | 'S_FORUM_OPTIONS' => $forum_options,
|
---|
427 | 'S_CLOSED' => ($mode == 'reports_closed') ? true : false,
|
---|
428 |
|
---|
429 | 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start),
|
---|
430 | 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
|
---|
431 | 'TOPIC_ID' => $topic_id,
|
---|
432 | 'TOTAL' => $total,
|
---|
433 | 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total),
|
---|
434 | )
|
---|
435 | );
|
---|
436 |
|
---|
437 | $this->tpl_name = 'mcp_reports';
|
---|
438 | break;
|
---|
439 | }
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * Closes a report
|
---|
445 | */
|
---|
446 | function close_report($report_id_list, $mode, $action, $pm = false)
|
---|
447 | {
|
---|
448 | global $db, $template, $user, $config, $auth;
|
---|
449 | global $phpEx, $phpbb_root_path;
|
---|
450 |
|
---|
451 | $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 ';
|
---|
452 | $id_column = ($pm) ? 'pm_id' : 'post_id';
|
---|
453 | $module = ($pm) ? 'pm_reports' : 'reports';
|
---|
454 | $pm_prefix = ($pm) ? 'PM_' : '';
|
---|
455 |
|
---|
456 | $sql = "SELECT r.$id_column
|
---|
457 | FROM " . REPORTS_TABLE . ' r
|
---|
458 | WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where;
|
---|
459 | $result = $db->sql_query($sql);
|
---|
460 |
|
---|
461 | $post_id_list = array();
|
---|
462 | while ($row = $db->sql_fetchrow($result))
|
---|
463 | {
|
---|
464 | $post_id_list[] = $row[$id_column];
|
---|
465 | }
|
---|
466 | $post_id_list = array_unique($post_id_list);
|
---|
467 |
|
---|
468 | if ($pm)
|
---|
469 | {
|
---|
470 | if (!$auth->acl_getf_global('m_report'))
|
---|
471 | {
|
---|
472 | trigger_error('NOT_AUTHORISED');
|
---|
473 | }
|
---|
474 | }
|
---|
475 | else
|
---|
476 | {
|
---|
477 | if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))
|
---|
478 | {
|
---|
479 | trigger_error('NOT_AUTHORISED');
|
---|
480 | }
|
---|
481 | }
|
---|
482 |
|
---|
483 | if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false)
|
---|
484 | {
|
---|
485 | $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports');
|
---|
486 | }
|
---|
487 | elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)
|
---|
488 | {
|
---|
489 | $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports');
|
---|
490 | }
|
---|
491 | else if ($action == 'close' && !request_var('r', 0))
|
---|
492 | {
|
---|
493 | $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module);
|
---|
494 | }
|
---|
495 | else
|
---|
496 | {
|
---|
497 | $redirect = request_var('redirect', build_url(array('quickmod')));
|
---|
498 | }
|
---|
499 | $success_msg = '';
|
---|
500 | $forum_ids = array();
|
---|
501 | $topic_ids = array();
|
---|
502 |
|
---|
503 | $s_hidden_fields = build_hidden_fields(array(
|
---|
504 | 'i' => $module,
|
---|
505 | 'mode' => $mode,
|
---|
506 | 'report_id_list' => $report_id_list,
|
---|
507 | 'action' => $action,
|
---|
508 | 'redirect' => $redirect)
|
---|
509 | );
|
---|
510 |
|
---|
511 | if (confirm_box(true))
|
---|
512 | {
|
---|
513 | $post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report');
|
---|
514 |
|
---|
515 | $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
|
---|
516 | FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
|
---|
517 | WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . '
|
---|
518 | ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '
|
---|
519 | AND r.user_id = u.user_id' . $pm_where;
|
---|
520 | $result = $db->sql_query($sql);
|
---|
521 |
|
---|
522 | $reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();
|
---|
523 | while ($report = $db->sql_fetchrow($result))
|
---|
524 | {
|
---|
525 | $reports[$report['report_id']] = $report;
|
---|
526 | $report_id_list[] = $report['report_id'];
|
---|
527 |
|
---|
528 | if (!$report['report_closed'])
|
---|
529 | {
|
---|
530 | $close_report_posts[] = $report[$id_column];
|
---|
531 |
|
---|
532 | if (!$pm)
|
---|
533 | {
|
---|
534 | $close_report_topics[] = $post_info[$report['post_id']]['topic_id'];
|
---|
535 | }
|
---|
536 | }
|
---|
537 |
|
---|
538 | if ($report['user_notify'] && !$report['report_closed'])
|
---|
539 | {
|
---|
540 | $notify_reporters[$report['report_id']] = &$reports[$report['report_id']];
|
---|
541 | }
|
---|
542 | }
|
---|
543 | $db->sql_freeresult($result);
|
---|
544 |
|
---|
545 | if (sizeof($reports))
|
---|
546 | {
|
---|
547 | $close_report_posts = array_unique($close_report_posts);
|
---|
548 | $close_report_topics = array_unique($close_report_topics);
|
---|
549 |
|
---|
550 | if (!$pm && sizeof($close_report_posts))
|
---|
551 | {
|
---|
552 | // Get a list of topics that still contain reported posts
|
---|
553 | $sql = 'SELECT DISTINCT topic_id
|
---|
554 | FROM ' . POSTS_TABLE . '
|
---|
555 | WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
|
---|
556 | AND post_reported = 1
|
---|
557 | AND ' . $db->sql_in_set('post_id', $close_report_posts, true);
|
---|
558 | $result = $db->sql_query($sql);
|
---|
559 |
|
---|
560 | $keep_report_topics = array();
|
---|
561 | while ($row = $db->sql_fetchrow($result))
|
---|
562 | {
|
---|
563 | $keep_report_topics[] = $row['topic_id'];
|
---|
564 | }
|
---|
565 | $db->sql_freeresult($result);
|
---|
566 |
|
---|
567 | $close_report_topics = array_diff($close_report_topics, $keep_report_topics);
|
---|
568 | unset($keep_report_topics);
|
---|
569 | }
|
---|
570 |
|
---|
571 | $db->sql_transaction('begin');
|
---|
572 |
|
---|
573 | if ($action == 'close')
|
---|
574 | {
|
---|
575 | $sql = 'UPDATE ' . REPORTS_TABLE . '
|
---|
576 | SET report_closed = 1
|
---|
577 | WHERE ' . $db->sql_in_set('report_id', $report_id_list);
|
---|
578 | }
|
---|
579 | else
|
---|
580 | {
|
---|
581 | $sql = 'DELETE FROM ' . REPORTS_TABLE . '
|
---|
582 | WHERE ' . $db->sql_in_set('report_id', $report_id_list);
|
---|
583 | }
|
---|
584 | $db->sql_query($sql);
|
---|
585 |
|
---|
586 |
|
---|
587 | if (sizeof($close_report_posts))
|
---|
588 | {
|
---|
589 | if ($pm)
|
---|
590 | {
|
---|
591 | $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
|
---|
592 | SET message_reported = 0
|
---|
593 | WHERE ' . $db->sql_in_set('msg_id', $close_report_posts);
|
---|
594 | $db->sql_query($sql);
|
---|
595 |
|
---|
596 | if ($action == 'delete')
|
---|
597 | {
|
---|
598 | delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX);
|
---|
599 | }
|
---|
600 | }
|
---|
601 | else
|
---|
602 | {
|
---|
603 | $sql = 'UPDATE ' . POSTS_TABLE . '
|
---|
604 | SET post_reported = 0
|
---|
605 | WHERE ' . $db->sql_in_set('post_id', $close_report_posts);
|
---|
606 | $db->sql_query($sql);
|
---|
607 |
|
---|
608 | if (sizeof($close_report_topics))
|
---|
609 | {
|
---|
610 | $sql = 'UPDATE ' . TOPICS_TABLE . '
|
---|
611 | SET topic_reported = 0
|
---|
612 | WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
|
---|
613 | OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics);
|
---|
614 | $db->sql_query($sql);
|
---|
615 | }
|
---|
616 | }
|
---|
617 | }
|
---|
618 |
|
---|
619 | $db->sql_transaction('commit');
|
---|
620 | }
|
---|
621 | unset($close_report_posts, $close_report_topics);
|
---|
622 |
|
---|
623 | foreach ($reports as $report)
|
---|
624 | {
|
---|
625 | if ($pm)
|
---|
626 | {
|
---|
627 | add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']);
|
---|
628 | }
|
---|
629 | else
|
---|
630 | {
|
---|
631 | add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']);
|
---|
632 | }
|
---|
633 | }
|
---|
634 |
|
---|
635 | $messenger = new messenger();
|
---|
636 |
|
---|
637 | // Notify reporters
|
---|
638 | if (sizeof($notify_reporters))
|
---|
639 | {
|
---|
640 | foreach ($notify_reporters as $report_id => $reporter)
|
---|
641 | {
|
---|
642 | if ($reporter['user_id'] == ANONYMOUS)
|
---|
643 | {
|
---|
644 | continue;
|
---|
645 | }
|
---|
646 |
|
---|
647 | $post_id = $reporter[$id_column];
|
---|
648 |
|
---|
649 | $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']);
|
---|
650 |
|
---|
651 | $messenger->to($reporter['user_email'], $reporter['username']);
|
---|
652 | $messenger->im($reporter['user_jabber'], $reporter['username']);
|
---|
653 |
|
---|
654 | if ($pm)
|
---|
655 | {
|
---|
656 | $messenger->assign_vars(array(
|
---|
657 | 'USERNAME' => htmlspecialchars_decode($reporter['username']),
|
---|
658 | 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']),
|
---|
659 | 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])),
|
---|
660 | ));
|
---|
661 | }
|
---|
662 | else
|
---|
663 | {
|
---|
664 | $messenger->assign_vars(array(
|
---|
665 | 'USERNAME' => htmlspecialchars_decode($reporter['username']),
|
---|
666 | 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']),
|
---|
667 | 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])),
|
---|
668 | 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title'])))
|
---|
669 | );
|
---|
670 | }
|
---|
671 |
|
---|
672 | $messenger->send($reporter['user_notify_type']);
|
---|
673 | }
|
---|
674 | }
|
---|
675 |
|
---|
676 | if (!$pm)
|
---|
677 | {
|
---|
678 | foreach ($post_info as $post)
|
---|
679 | {
|
---|
680 | $forum_ids[$post['forum_id']] = $post['forum_id'];
|
---|
681 | $topic_ids[$post['topic_id']] = $post['topic_id'];
|
---|
682 | }
|
---|
683 | }
|
---|
684 |
|
---|
685 | unset($notify_reporters, $post_info, $reports);
|
---|
686 |
|
---|
687 | $messenger->save_queue();
|
---|
688 |
|
---|
689 | $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS';
|
---|
690 | }
|
---|
691 | else
|
---|
692 | {
|
---|
693 | confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
|
---|
694 | }
|
---|
695 |
|
---|
696 | $redirect = request_var('redirect', "index.$phpEx");
|
---|
697 | $redirect = reapply_sid($redirect);
|
---|
698 |
|
---|
699 | if (!$success_msg)
|
---|
700 | {
|
---|
701 | redirect($redirect);
|
---|
702 | }
|
---|
703 | else
|
---|
704 | {
|
---|
705 | meta_refresh(3, $redirect);
|
---|
706 |
|
---|
707 | $return_forum = '';
|
---|
708 | $return_topic = '';
|
---|
709 |
|
---|
710 | if (!$pm)
|
---|
711 | {
|
---|
712 | if (sizeof($forum_ids) === 1)
|
---|
713 | {
|
---|
714 | $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
|
---|
715 | }
|
---|
716 |
|
---|
717 | if (sizeof($topic_ids) === 1)
|
---|
718 | {
|
---|
719 | $return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
|
---|
720 | }
|
---|
721 | }
|
---|
722 |
|
---|
723 | trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
|
---|
724 | }
|
---|
725 | }
|
---|
726 |
|
---|
727 | ?>
|
---|