2003-03-06 02:03:37 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
|
|
|
* report.php
|
|
|
|
* -------------------
|
|
|
|
* begin : July 4, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
define('IN_PHPBB', true);
|
|
|
|
$phpbb_root_path = './';
|
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
|
|
|
|
|
|
|
// Start session management
|
|
|
|
$user->start();
|
|
|
|
$user->setup();
|
|
|
|
$auth->acl($user->data);
|
2003-04-26 01:17:40 +00:00
|
|
|
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
// var definitions
|
|
|
|
$post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : 0;
|
|
|
|
$reason_id = (!empty($_REQUEST['reason_id'])) ? intval($_REQUEST['reason_id']) : 0;
|
2003-04-09 22:00:23 +00:00
|
|
|
$notify = (!empty($_REQUEST['notify']) && $user->data['user_id'] != ANONYMOUS) ? TRUE : FALSE;
|
2003-03-06 02:03:37 +00:00
|
|
|
$description = (!empty($_REQUEST['description'])) ? stripslashes($_REQUEST['description']) : '';
|
|
|
|
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Has the report been cancelled?
|
|
|
|
if (isset($_POST['cancel']))
|
|
|
|
{
|
|
|
|
redirect("viewtopic.$phpEx$SID&p=$post_id#$post_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Grab all relevant data
|
2003-03-06 02:03:37 +00:00
|
|
|
$sql = 'SELECT f.*, t.*, p.*
|
|
|
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
|
|
WHERE p.post_id = $post_id
|
|
|
|
AND p.topic_id = t.topic_id
|
|
|
|
AND p.forum_id = f.forum_id";
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
if (!($forum_data = $db->sql_fetchrow($result)))
|
2003-03-06 02:03:37 +00:00
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
trigger_error($user->lang['POST_NOT_EXIST']);
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
$forum_id = $forum_data['forum_id'];
|
|
|
|
$topic_id = $forum_data['topic_id'];
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Check required permissions
|
|
|
|
$acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
|
|
|
|
foreach ($acl_check_ary as $acl => $error)
|
2003-03-06 02:03:37 +00:00
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
if (!$auth->acl_get($acl, $forum_id))
|
|
|
|
{
|
|
|
|
trigger_error($user->lang[$error]);
|
|
|
|
}
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
2003-04-26 01:17:40 +00:00
|
|
|
unset($acl_check_ary);
|
|
|
|
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
// Has the report been confirmed?
|
|
|
|
if (!empty($_POST['reason_id']))
|
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
$sql = 'SELECT reason_name
|
|
|
|
FROM ' . REASONS_TABLE . "
|
|
|
|
WHERE reason_id = $reason_id";
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
if (!($row = $db->sql_fetchrow($result)) || (!$description && $row['reason_name'] == 'other'))
|
2003-04-09 22:00:23 +00:00
|
|
|
{
|
|
|
|
trigger_error('EMPTY_REPORT');
|
|
|
|
}
|
2003-04-26 01:17:40 +00:00
|
|
|
$db->sql_freeresult($result);
|
2003-04-09 22:00:23 +00:00
|
|
|
|
2003-03-06 02:03:37 +00:00
|
|
|
$sql_ary = array(
|
|
|
|
'reason_id' => (int) $reason_id,
|
|
|
|
'post_id' => (int) $post_id,
|
|
|
|
'user_id' => (int) $user->user_id,
|
2003-04-09 22:00:23 +00:00
|
|
|
'user_notify' => (int) $notify,
|
2003-03-06 02:03:37 +00:00
|
|
|
'report_time' => (int) time(),
|
|
|
|
'report_text' => (string) $description
|
|
|
|
);
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' .
|
|
|
|
$db->sql_build_array('INSERT', $sql_ary);
|
2003-03-06 02:03:37 +00:00
|
|
|
$db->sql_query($sql);
|
|
|
|
|
|
|
|
if (!$row['post_reported'])
|
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
$sql = 'UPDATE ' . POSTS_TABLE . '
|
|
|
|
SET post_reported = 1
|
|
|
|
WHERE post_id = ' . $post_id;
|
|
|
|
$db->sql_query($sql);
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
2003-04-26 01:17:40 +00:00
|
|
|
|
2003-03-06 02:03:37 +00:00
|
|
|
if (!$row['topic_reported'])
|
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
|
|
|
SET topic_reported = 1
|
|
|
|
WHERE topic_id = ' . $topic_id;
|
|
|
|
$db->sql_query($sql);
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
meta_refresh(3, "viewtopic.$phpEx$SID&p=$post_id#$post_id");
|
|
|
|
|
|
|
|
$message = $user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], "<a href=\"viewtopic.$phpEx$SID&p=$post_id#$post_id\">", '</a>');
|
|
|
|
trigger_error($message);
|
2003-04-02 23:13:47 +00:00
|
|
|
|
2003-04-09 22:00:23 +00:00
|
|
|
// TODO: warn moderators or something ;)
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Generate the form
|
|
|
|
$sql = 'SELECT *
|
|
|
|
FROM ' . REASONS_TABLE . '
|
|
|
|
ORDER BY reason_priority ASC';
|
|
|
|
$result = $db->sql_query($sql);
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
$row['reason_name'] = strtoupper($row['reason_name']);
|
2003-03-06 02:03:37 +00:00
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
$reason_name = (!empty($user->lang['REPORT_REASONS']['TITLE'][$row['reason_name']])) ? $user->lang['REPORT_REASONS']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name']));
|
|
|
|
|
|
|
|
$reason_description = (!empty($user->lang['REPORT_REASONS']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['REPORT_REASONS']['DESCRIPTION'][$row['reason_name']] : $row['reason_description'];
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
$template->assign_block_vars('reason', array(
|
|
|
|
'ID' => $row['reason_id'],
|
|
|
|
'NAME' => htmlspecialchars($reason_name),
|
2003-04-26 01:17:40 +00:00
|
|
|
'DESCRIPTION' => htmlspecialchars($reason_description))
|
|
|
|
);
|
2003-03-06 02:03:37 +00:00
|
|
|
}
|
|
|
|
|
2003-04-09 22:00:23 +00:00
|
|
|
$template->assign_var('S_CAN_NOTIFY', ($user->data['user_id'] == ANONYMOUS) ? FALSE : TRUE);
|
2003-04-26 01:17:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
generate_forum_nav($forum_data);
|
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
|
|
|
|
// Start output of page
|
|
|
|
page_header($user->lang['REPORT_TO_ADMIN']);
|
|
|
|
|
2003-03-06 02:03:37 +00:00
|
|
|
$template->set_filenames(array(
|
2003-04-26 01:17:40 +00:00
|
|
|
'body' => 'report_body.html')
|
|
|
|
);
|
2003-03-06 02:03:37 +00:00
|
|
|
|
2003-05-03 23:58:45 +00:00
|
|
|
page_tail();
|
2003-03-06 02:03:37 +00:00
|
|
|
|
|
|
|
?>
|