1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @package phpBB3
|
---|
5 | * @version $Id: report.php 8479 2008-03-29 00:22:48Z naderman $
|
---|
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 | define('IN_PHPBB', true);
|
---|
15 | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
---|
16 | $phpEx = substr(strrchr(__FILE__, '.'), 1);
|
---|
17 | include($phpbb_root_path . 'common.' . $phpEx);
|
---|
18 | include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
---|
19 |
|
---|
20 | // Start session management
|
---|
21 | $user->session_begin();
|
---|
22 | $auth->acl($user->data);
|
---|
23 | $user->setup('mcp');
|
---|
24 |
|
---|
25 | $forum_id = request_var('f', 0);
|
---|
26 | $post_id = request_var('p', 0);
|
---|
27 | $reason_id = request_var('reason_id', 0);
|
---|
28 | $report_text = utf8_normalize_nfc(request_var('report_text', '', true));
|
---|
29 | $user_notify = ($user->data['is_registered']) ? request_var('notify', 0) : false;
|
---|
30 |
|
---|
31 | $submit = (isset($_POST['submit'])) ? true : false;
|
---|
32 |
|
---|
33 | if (!$post_id)
|
---|
34 | {
|
---|
35 | trigger_error('NO_POST_SELECTED');
|
---|
36 | }
|
---|
37 |
|
---|
38 | $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=$post_id") . "#p$post_id";
|
---|
39 |
|
---|
40 | // Has the report been cancelled?
|
---|
41 | if (isset($_POST['cancel']))
|
---|
42 | {
|
---|
43 | redirect($redirect_url);
|
---|
44 | }
|
---|
45 |
|
---|
46 | // Grab all relevant data
|
---|
47 | $sql = 'SELECT t.*, p.*
|
---|
48 | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
---|
49 | WHERE p.post_id = $post_id
|
---|
50 | AND p.topic_id = t.topic_id";
|
---|
51 | $result = $db->sql_query($sql);
|
---|
52 | $report_data = $db->sql_fetchrow($result);
|
---|
53 | $db->sql_freeresult($result);
|
---|
54 |
|
---|
55 | if (!$report_data)
|
---|
56 | {
|
---|
57 | trigger_error('POST_NOT_EXIST');
|
---|
58 | }
|
---|
59 |
|
---|
60 | $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
|
---|
61 | $topic_id = (int) $report_data['topic_id'];
|
---|
62 |
|
---|
63 | $sql = 'SELECT *
|
---|
64 | FROM ' . FORUMS_TABLE . '
|
---|
65 | WHERE forum_id = ' . $forum_id;
|
---|
66 | $result = $db->sql_query($sql);
|
---|
67 | $forum_data = $db->sql_fetchrow($result);
|
---|
68 | $db->sql_freeresult($result);
|
---|
69 |
|
---|
70 | if (!$forum_data)
|
---|
71 | {
|
---|
72 | trigger_error('FORUM_NOT_EXIST');
|
---|
73 | }
|
---|
74 |
|
---|
75 | // Check required permissions
|
---|
76 | $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
|
---|
77 |
|
---|
78 | foreach ($acl_check_ary as $acl => $error)
|
---|
79 | {
|
---|
80 | if (!$auth->acl_get($acl, $forum_id))
|
---|
81 | {
|
---|
82 | trigger_error($error);
|
---|
83 | }
|
---|
84 | }
|
---|
85 | unset($acl_check_ary);
|
---|
86 |
|
---|
87 | if ($report_data['post_reported'])
|
---|
88 | {
|
---|
89 | $message = $user->lang['ALREADY_REPORTED'];
|
---|
90 | $message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
|
---|
91 | trigger_error($message);
|
---|
92 | }
|
---|
93 |
|
---|
94 | // Submit report?
|
---|
95 | if ($submit && $reason_id)
|
---|
96 | {
|
---|
97 | $sql = 'SELECT *
|
---|
98 | FROM ' . REPORTS_REASONS_TABLE . "
|
---|
99 | WHERE reason_id = $reason_id";
|
---|
100 | $result = $db->sql_query($sql);
|
---|
101 | $row = $db->sql_fetchrow($result);
|
---|
102 | $db->sql_freeresult($result);
|
---|
103 |
|
---|
104 | if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
|
---|
105 | {
|
---|
106 | trigger_error('EMPTY_REPORT');
|
---|
107 | }
|
---|
108 |
|
---|
109 | $sql_ary = array(
|
---|
110 | 'reason_id' => (int) $reason_id,
|
---|
111 | 'post_id' => $post_id,
|
---|
112 | 'user_id' => (int) $user->data['user_id'],
|
---|
113 | 'user_notify' => (int) $user_notify,
|
---|
114 | 'report_closed' => 0,
|
---|
115 | 'report_time' => (int) time(),
|
---|
116 | 'report_text' => (string) $report_text
|
---|
117 | );
|
---|
118 |
|
---|
119 | $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
---|
120 | $db->sql_query($sql);
|
---|
121 | $report_id = $db->sql_nextid();
|
---|
122 |
|
---|
123 | if (!$report_data['post_reported'])
|
---|
124 | {
|
---|
125 | $sql = 'UPDATE ' . POSTS_TABLE . '
|
---|
126 | SET post_reported = 1
|
---|
127 | WHERE post_id = ' . $post_id;
|
---|
128 | $db->sql_query($sql);
|
---|
129 | }
|
---|
130 |
|
---|
131 | if (!$report_data['topic_reported'])
|
---|
132 | {
|
---|
133 | $sql = 'UPDATE ' . TOPICS_TABLE . '
|
---|
134 | SET topic_reported = 1
|
---|
135 | WHERE topic_id = ' . $report_data['topic_id'] . '
|
---|
136 | OR topic_moved_id = ' . $report_data['topic_id'];
|
---|
137 | $db->sql_query($sql);
|
---|
138 | }
|
---|
139 |
|
---|
140 | meta_refresh(3, $redirect_url);
|
---|
141 |
|
---|
142 | $message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
|
---|
143 | trigger_error($message);
|
---|
144 | }
|
---|
145 |
|
---|
146 | // Generate the reasons
|
---|
147 | display_reasons($reason_id);
|
---|
148 |
|
---|
149 | $template->assign_vars(array(
|
---|
150 | 'REPORT_TEXT' => $report_text,
|
---|
151 | 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id),
|
---|
152 |
|
---|
153 | 'S_NOTIFY' => $user_notify,
|
---|
154 | 'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
|
---|
155 | );
|
---|
156 |
|
---|
157 | generate_forum_nav($forum_data);
|
---|
158 |
|
---|
159 | // Start output of page
|
---|
160 | page_header($user->lang['REPORT_POST']);
|
---|
161 |
|
---|
162 | $template->set_filenames(array(
|
---|
163 | 'body' => 'report_body.html')
|
---|
164 | );
|
---|
165 |
|
---|
166 | page_footer();
|
---|
167 |
|
---|
168 | ?>
|
---|