5
* @version $Id: report.php,v 1.39 2007/10/05 14:30:06 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
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);
20
// Start session management
21
$user->session_begin();
22
$auth->acl($user->data);
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;
31
$submit = (isset($_POST['submit'])) ? true : false;
35
trigger_error('NO_POST_SELECTED');
38
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=$post_id") . "#p$post_id";
40
// Has the report been cancelled?
41
if (isset($_POST['cancel']))
43
redirect($redirect_url);
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);
57
trigger_error('POST_NOT_EXIST');
60
$forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
61
$topic_id = (int) $report_data['topic_id'];
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);
72
trigger_error('FORUM_NOT_EXIST');
75
// Check required permissions
76
$acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
78
foreach ($acl_check_ary as $acl => $error)
80
if (!$auth->acl_get($acl, $forum_id))
82
trigger_error($error);
85
unset($acl_check_ary);
87
if ($report_data['post_reported'])
89
$message = $user->lang['ALREADY_REPORTED'];
90
$message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
91
trigger_error($message);
95
if ($submit && $reason_id)
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);
104
if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
106
trigger_error('EMPTY_REPORT');
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
119
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
120
$db->sql_query($sql);
121
$report_id = $db->sql_nextid();
123
if (!$report_data['post_reported'])
125
$sql = 'UPDATE ' . POSTS_TABLE . '
126
SET post_reported = 1
127
WHERE post_id = ' . $post_id;
128
$db->sql_query($sql);
131
if (!$report_data['topic_reported'])
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);
140
meta_refresh(3, $redirect_url);
142
$message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
143
trigger_error($message);
146
// Generate the reasons
147
display_reasons($reason_id);
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),
153
'S_NOTIFY' => $user_notify,
154
'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
157
generate_forum_nav($forum_data);
159
// Start output of page
160
page_header($user->lang['REPORT_POST']);
162
$template->set_filenames(array(
163
'body' => 'report_body.html')
b'\\ No newline at end of file'