- forum image being an additional image instead of replacing forum indicators
[phpbb.git] / phpBB / report.php
blob632854006434f359a2576cafc77e9fe96c651f6a
1 <?php
2 /**
4 * @package phpBB3
5 * @version $Id$
6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 */
11 /**
12 * @ignore
14 define('IN_PHPBB', true);
15 $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);
20 // Start session management
21 $user->session_begin();
22 $auth->acl($user->data);
23 $user->setup('mcp');
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 = request_var('report_text', '', true);
29 $user_notify = (isset($_POST['notify']) && $user->data['is_registered']) ? true : false;
30 $submit = (isset($_POST['submit'])) ? true : false;
32 if (!$post_id)
34 trigger_error('INVALID_MODE');
37 $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;p=$post_id") . "#p$post_id";
39 // Has the report been cancelled?
40 if (isset($_POST['cancel']))
42 redirect($redirect_url);
45 // Grab all relevant data
46 $sql = 'SELECT t.*, p.*
47 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
48 WHERE p.post_id = $post_id
49 AND p.topic_id = t.topic_id";
50 $result = $db->sql_query($sql);
51 $report_data = $db->sql_fetchrow($result);
52 $db->sql_freeresult($result);
54 if (!$report_data)
56 trigger_error('POST_NOT_EXIST');
59 $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
60 $topic_id = (int) $report_data['topic_id'];
62 $sql = 'SELECT *
63 FROM ' . FORUMS_TABLE . '
64 WHERE forum_id = ' . $forum_id;
65 $result = $db->sql_query($sql);
66 $forum_data = $db->sql_fetchrow($result);
67 $db->sql_freeresult($result);
69 if (!$forum_data)
71 trigger_error('FORUM_NOT_EXIST');
74 // Check required permissions
75 $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
77 foreach ($acl_check_ary as $acl => $error)
79 if (!$auth->acl_get($acl, $forum_id))
81 trigger_error($error);
84 unset($acl_check_ary);
86 if ($report_data['post_reported'])
88 $message = $user->lang['ALREADY_REPORTED'];
89 $message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
90 trigger_error($message);
93 // Submit report?
94 if ($submit && $reason_id)
96 $sql = 'SELECT *
97 FROM ' . REPORTS_REASONS_TABLE . "
98 WHERE reason_id = $reason_id";
99 $result = $db->sql_query($sql);
100 $row = $db->sql_fetchrow($result);
101 $db->sql_freeresult($result);
103 if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
105 trigger_error('EMPTY_REPORT');
108 $sql_ary = array(
109 'reason_id' => (int) $reason_id,
110 'post_id' => $post_id,
111 'user_id' => (int) $user->data['user_id'],
112 'user_notify' => (int) $user_notify,
113 'report_closed' => 0,
114 'report_time' => (int) time(),
115 'report_text' => (string) $report_text
118 $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
119 $db->sql_query($sql);
120 $report_id = $db->sql_nextid();
122 if (!$report_data['post_reported'])
124 $sql = 'UPDATE ' . POSTS_TABLE . '
125 SET post_reported = 1
126 WHERE post_id = ' . $post_id;
127 $db->sql_query($sql);
130 if (!$report_data['topic_reported'])
132 $sql = 'UPDATE ' . TOPICS_TABLE . '
133 SET topic_reported = 1
134 WHERE topic_id = ' . $report_data['topic_id'];
135 $db->sql_query($sql);
138 meta_refresh(3, $redirect_url);
140 $message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
141 trigger_error($message);
144 // Generate the reasons
145 display_reasons($reason_id);
147 $template->assign_vars(array(
148 'REPORT_TEXT' => $report_text,
149 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&amp;p=' . $post_id),
151 'S_NOTIFY' => $user_notify,
152 'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
155 generate_forum_nav($forum_data);
157 // Start output of page
158 page_header($user->lang['REPORT_POST']);
160 $template->set_filenames(array(
161 'body' => 'report_body.html')
164 page_footer();