|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
*
|
|
|
f2e824 |
* @package phpBB3
|
|
|
f2e824 |
* @version $Id: report.php 8479 2008-03-29 00:22:48Z naderman $
|
|
|
f2e824 |
* @copyright (c) 2005 phpBB Group
|
|
|
f2e824 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
f2e824 |
*
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
|
|
|
f2e824 |
/**
|
|
|
f2e824 |
* @ignore
|
|
|
f2e824 |
*/
|
|
|
f2e824 |
define('IN_PHPBB', true);
|
|
|
f2e824 |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
|
|
|
f2e824 |
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
|
f2e824 |
include($phpbb_root_path . 'common.' . $phpEx);
|
|
|
f2e824 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Start session management
|
|
|
f2e824 |
$user->session_begin();
|
|
|
f2e824 |
$auth->acl($user->data);
|
|
|
f2e824 |
$user->setup('mcp');
|
|
|
f2e824 |
|
|
|
f2e824 |
$forum_id = request_var('f', 0);
|
|
|
f2e824 |
$post_id = request_var('p', 0);
|
|
|
f2e824 |
$reason_id = request_var('reason_id', 0);
|
|
|
f2e824 |
$report_text = utf8_normalize_nfc(request_var('report_text', '', true));
|
|
|
f2e824 |
$user_notify = ($user->data['is_registered']) ? request_var('notify', 0) : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
$submit = (isset($_POST['submit'])) ? true : false;
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$post_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('NO_POST_SELECTED');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=$post_id") . "#p$post_id";
|
|
|
f2e824 |
|
|
|
f2e824 |
// Has the report been cancelled?
|
|
|
f2e824 |
if (isset($_POST['cancel']))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
redirect($redirect_url);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Grab all relevant data
|
|
|
f2e824 |
$sql = 'SELECT t.*, p.*
|
|
|
f2e824 |
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
|
|
|
f2e824 |
WHERE p.post_id = $post_id
|
|
|
f2e824 |
AND p.topic_id = t.topic_id";
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$report_data = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$report_data)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('POST_NOT_EXIST');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id;
|
|
|
f2e824 |
$topic_id = (int) $report_data['topic_id'];
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'SELECT *
|
|
|
f2e824 |
FROM ' . FORUMS_TABLE . '
|
|
|
f2e824 |
WHERE forum_id = ' . $forum_id;
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$forum_data = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$forum_data)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('FORUM_NOT_EXIST');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Check required permissions
|
|
|
f2e824 |
$acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
|
|
|
f2e824 |
|
|
|
f2e824 |
foreach ($acl_check_ary as $acl => $error)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
if (!$auth->acl_get($acl, $forum_id))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error($error);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
}
|
|
|
f2e824 |
unset($acl_check_ary);
|
|
|
f2e824 |
|
|
|
f2e824 |
if ($report_data['post_reported'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$message = $user->lang['ALREADY_REPORTED'];
|
|
|
f2e824 |
$message .= '
' . sprintf($user->lang['RETURN_TOPIC'], '', '');
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Submit report?
|
|
|
f2e824 |
if ($submit && $reason_id)
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'SELECT *
|
|
|
f2e824 |
FROM ' . REPORTS_REASONS_TABLE . "
|
|
|
f2e824 |
WHERE reason_id = $reason_id";
|
|
|
f2e824 |
$result = $db->sql_query($sql);
|
|
|
f2e824 |
$row = $db->sql_fetchrow($result);
|
|
|
f2e824 |
$db->sql_freeresult($result);
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$row || (!$report_text && strtolower($row['reason_title']) == 'other'))
|
|
|
f2e824 |
{
|
|
|
f2e824 |
trigger_error('EMPTY_REPORT');
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql_ary = array(
|
|
|
f2e824 |
'reason_id' => (int) $reason_id,
|
|
|
f2e824 |
'post_id' => $post_id,
|
|
|
f2e824 |
'user_id' => (int) $user->data['user_id'],
|
|
|
f2e824 |
'user_notify' => (int) $user_notify,
|
|
|
f2e824 |
'report_closed' => 0,
|
|
|
f2e824 |
'report_time' => (int) time(),
|
|
|
f2e824 |
'report_text' => (string) $report_text
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
$report_id = $db->sql_nextid();
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$report_data['post_reported'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
|
f2e824 |
SET post_reported = 1
|
|
|
f2e824 |
WHERE post_id = ' . $post_id;
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
if (!$report_data['topic_reported'])
|
|
|
f2e824 |
{
|
|
|
f2e824 |
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
f2e824 |
SET topic_reported = 1
|
|
|
f2e824 |
WHERE topic_id = ' . $report_data['topic_id'] . '
|
|
|
f2e824 |
OR topic_moved_id = ' . $report_data['topic_id'];
|
|
|
f2e824 |
$db->sql_query($sql);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
meta_refresh(3, $redirect_url);
|
|
|
f2e824 |
|
|
|
f2e824 |
$message = $user->lang['POST_REPORTED_SUCCESS'] . '
' . sprintf($user->lang['RETURN_TOPIC'], '', '');
|
|
|
f2e824 |
trigger_error($message);
|
|
|
f2e824 |
}
|
|
|
f2e824 |
|
|
|
f2e824 |
// Generate the reasons
|
|
|
f2e824 |
display_reasons($reason_id);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->assign_vars(array(
|
|
|
f2e824 |
'REPORT_TEXT' => $report_text,
|
|
|
f2e824 |
'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id),
|
|
|
f2e824 |
|
|
|
f2e824 |
'S_NOTIFY' => $user_notify,
|
|
|
f2e824 |
'S_CAN_NOTIFY' => ($user->data['is_registered']) ? true : false)
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
generate_forum_nav($forum_data);
|
|
|
f2e824 |
|
|
|
f2e824 |
// Start output of page
|
|
|
f2e824 |
page_header($user->lang['REPORT_POST']);
|
|
|
f2e824 |
|
|
|
f2e824 |
$template->set_filenames(array(
|
|
|
f2e824 |
'body' => 'report_body.html')
|
|
|
f2e824 |
);
|
|
|
f2e824 |
|
|
|
f2e824 |
page_footer();
|
|
|
f2e824 |
|
|
|
f2e824 |
?>
|