phpBB

Code Changes

File: includes/mcp/mcp_reports.php

  Unmodified   Added   Modified   Removed
Line 65Line 65
		{
case 'report_details':


		{
case 'report_details':


				$user->add_lang('posting');

				$user->add_lang(array('posting', 'viewforum', 'viewtopic'));


$post_id = request_var('p', 0);



$post_id = request_var('p', 0);


Line 77Line 77
					WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '
AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id

					WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . '
AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id

 
						AND r.pm_id = 0

					ORDER BY report_closed ASC';
$result = $db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result);

					ORDER BY report_closed ASC';
$result = $db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result);

Line 115Line 116
				{
$template->assign_vars(array(
'S_TOPIC_REVIEW' => true,

				{
$template->assign_vars(array(
'S_TOPIC_REVIEW' => true,

 
						'S_BBCODE_ALLOWED'	=> $post_info['enable_bbcode'],

						'TOPIC_TITLE'		=> $post_info['topic_title'])
);
}

						'TOPIC_TITLE'		=> $post_info['topic_title'])
);
}

Line 146Line 148

$message = bbcode_nl2br($message);
$message = smiley_text($message);


$message = bbcode_nl2br($message);
$message = smiley_text($message);

 
				$report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));


if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
{


if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
{

					$extensions = $cache->obtain_attach_extensions($post_info['forum_id']);


 
					$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id . '
AND in_message = 0

					$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id . '
AND in_message = 0

						ORDER BY filetime DESC, post_msg_id ASC';

						ORDER BY filetime DESC';

					$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))

					$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))

Line 191Line 192
					'S_POST_REPORTED'		=> $post_info['post_reported'],
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
'S_POST_LOCKED' => $post_info['post_edit_locked'],

					'S_POST_REPORTED'		=> $post_info['post_reported'],
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
'S_POST_LOCKED' => $post_info['post_edit_locked'],

 
					'S_REPORT_CLOSED'		=> $report['report_closed'],

					'S_USER_NOTES'			=> true,

'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',

					'S_USER_NOTES'			=> true,

'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',

Line 200Line 202
					'U_MCP_USER_NOTES'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',
'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '',

					'U_MCP_USER_NOTES'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '',
'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '',

 
					'U_VIEW_FORUM'				=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $post_info['forum_id']),

					'U_VIEW_POST'				=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),

'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),

					'U_VIEW_POST'				=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']),

'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),

					'MINI_POST_IMG'			=> ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),

					'MINI_POST_IMG'			=> ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),

					'UNAPPROVED_IMG'		=> $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),

'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;f=' . $post_info['forum_id']) . '">', '</a>'),

					'UNAPPROVED_IMG'		=> $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),

'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;f=' . $post_info['forum_id']) . '">', '</a>'),

Line 245Line 248

$forum_info = array();
$forum_list_reports = get_forum_list('m_report', false, true);


$forum_info = array();
$forum_list_reports = get_forum_list('m_report', false, true);

 
				$forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs





				if ($topic_id && $forum_id)











				// Remove forums we cannot read
foreach ($forum_list_reports as $k => $forum_data)
{
if (!isset($forum_list_read[$forum_data['forum_id']]))
{
unset($forum_list_reports[$k]);
}
}
unset($forum_list_read);

if ($topic_id)

				{
$topic_info = get_topic_data(array($topic_id));


				{
$topic_info = get_topic_data(array($topic_id));


Line 255Line 269
						trigger_error('TOPIC_NOT_EXIST');
}


						trigger_error('TOPIC_NOT_EXIST');
}


					$topic_info = $topic_info[$topic_id];
$forum_id = $topic_info['forum_id'];
}
else if ($topic_id && !$forum_id)

					if ($forum_id != $topic_info[$topic_id]['forum_id'])




				{
$topic_id = 0;

				{
$topic_id = 0;

 
					}
else
{
$topic_info = $topic_info[$topic_id];
$forum_id = (int) $topic_info['forum_id'];
}

				}

$forum_list = array();

				}

$forum_list = array();

Line 317Line 334
				mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);

$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;

				mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);

$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;

				$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';

				$limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : '';


if ($mode == 'reports')
{


if ($mode == 'reports')
{

Line 334Line 351
						$report_state
AND r.post_id = p.post_id
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '

						$report_state
AND r.post_id = p.post_id
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '

						' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . '

						' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . '

						' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
AND t.topic_id = p.topic_id

						' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
AND t.topic_id = p.topic_id

 
						AND r.pm_id = 0

						$limit_time_sql
ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);

						$limit_time_sql
ORDER BY $sort_order_sql";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);

Line 359Line 377
							AND r.post_id = p.post_id
AND u.user_id = p.poster_id
AND ru.user_id = r.user_id

							AND r.post_id = p.post_id
AND u.user_id = p.poster_id
AND ru.user_id = r.user_id

 
							AND r.pm_id = 0

						ORDER BY ' . $sort_order_sql;
$result = $db->sql_query($sql);


						ORDER BY ' . $sort_order_sql;
$result = $db->sql_query($sql);


Line 426Line 445
/**
* Closes a report
*/

/**
* Closes a report
*/

function close_report($report_id_list, $mode, $action)

function close_report($report_id_list, $mode, $action, $pm = false)

{

{

	global $db, $template, $user, $config;

	global $db, $template, $user, $config, $auth;

	global $phpEx, $phpbb_root_path;


	global $phpEx, $phpbb_root_path;


	$sql = 'SELECT r.post_id
FROM ' . REPORTS_TABLE . ' r
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list);






	$pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 ';
$id_column = ($pm) ? 'pm_id' : 'post_id';
$module = ($pm) ? 'pm_reports' : 'reports';
$pm_prefix = ($pm) ? 'PM_' : '';

$sql = "SELECT r.$id_column
FROM " . REPORTS_TABLE . ' r
WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where;

	$result = $db->sql_query($sql);

$post_id_list = array();
while ($row = $db->sql_fetchrow($result))
{

	$result = $db->sql_query($sql);

$post_id_list = array();
while ($row = $db->sql_fetchrow($result))
{

		$post_id_list[] = $row['post_id'];

		$post_id_list[] = $row[$id_column];

	}
$post_id_list = array_unique($post_id_list);


	}
$post_id_list = array_unique($post_id_list);


 
	if ($pm)
{
if (!$auth->acl_getf_global('m_report'))
{
trigger_error('NOT_AUTHORISED');
}
}
else
{

	if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))
{
trigger_error('NOT_AUTHORISED');

	if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report')))
{
trigger_error('NOT_AUTHORISED');

 
		}

	}

if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false)
{
$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=reports');

	}

if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false)
{
$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=reports');

 
	}
elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false)
{
$redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=pm_reports');

	}
else if ($action == 'close' && !request_var('r', 0))
{

	}
else if ($action == 'close' && !request_var('r', 0))
{

		$redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&amp;mode=reports');

		$redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&amp;mode=' . $module);

	}
else
{

	}
else
{

Line 465Line 503
	$topic_ids = array();

$s_hidden_fields = build_hidden_fields(array(

	$topic_ids = array();

$s_hidden_fields = build_hidden_fields(array(

		'i'					=> 'reports',

		'i'					=> $module,

		'mode'				=> $mode,
'report_id_list' => $report_id_list,
'action' => $action,

		'mode'				=> $mode,
'report_id_list' => $report_id_list,
'action' => $action,

Line 474Line 512

if (confirm_box(true))
{


if (confirm_box(true))
{

		$post_info = get_post_data($post_id_list, 'm_report');

		$post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report');





		$sql = 'SELECT r.report_id, r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u

		$sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u

			WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . '
' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '

			WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . '
' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . '

				AND r.user_id = u.user_id';

				AND r.user_id = u.user_id' . $pm_where;

		$result = $db->sql_query($sql);

$reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();

		$result = $db->sql_query($sql);

$reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array();

Line 491Line 529

if (!$report['report_closed'])
{


if (!$report['report_closed'])
{

				$close_report_posts[] = $report['post_id'];




				$close_report_posts[] = $report[$id_column];

if (!$pm)
{

				$close_report_topics[] = $post_info[$report['post_id']]['topic_id'];

				$close_report_topics[] = $post_info[$report['post_id']]['topic_id'];

 
				}

			}

if ($report['user_notify'] && !$report['report_closed'])

			}

if ($report['user_notify'] && !$report['report_closed'])

Line 507Line 549
			$close_report_posts = array_unique($close_report_posts);
$close_report_topics = array_unique($close_report_topics);


			$close_report_posts = array_unique($close_report_posts);
$close_report_topics = array_unique($close_report_topics);


			if (sizeof($close_report_posts))

			if (!$pm && sizeof($close_report_posts))

			{
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id

			{
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id

Line 545Line 587


if (sizeof($close_report_posts))



if (sizeof($close_report_posts))

 
			{
if ($pm)
{
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
SET message_reported = 0
WHERE ' . $db->sql_in_set('msg_id', $close_report_posts);
$db->sql_query($sql);

if ($action == 'delete')
{
delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX);
}
}
else

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0

			{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0

Line 555Line 611
				{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0

				{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0

						WHERE ' . $db->sql_in_set('topic_id', $close_report_topics);


							WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . '
OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics);

					$db->sql_query($sql);

					$db->sql_query($sql);

 
					}

				}
}


				}
}


Line 565Line 623
		unset($close_report_posts, $close_report_topics);

foreach ($reports as $report)

		unset($close_report_posts, $close_report_topics);

foreach ($reports as $report)

 
		{
if ($pm)
{
add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']);
}
else

		{
add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']);

		{
add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']);

 
			}

		}

$messenger = new messenger();

		}

$messenger = new messenger();

Line 581Line 646
					continue;
}


					continue;
}


				$post_id = $reporter['post_id'];

				$post_id = $reporter[$id_column];





				$messenger->template('report_' . $action . 'd', $reporter['user_lang']);

				$messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']);


$messenger->to($reporter['user_email'], $reporter['username']);
$messenger->im($reporter['user_jabber'], $reporter['username']);



$messenger->to($reporter['user_email'], $reporter['username']);
$messenger->im($reporter['user_jabber'], $reporter['username']);


 
				if ($pm)
{
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($reporter['username']),
'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']),
'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])),
));
}
else
{

				$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($reporter['username']),
'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']),
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])),
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title'])))
);

				$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($reporter['username']),
'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']),
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])),
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title'])))
);

 
				}


$messenger->send($reporter['user_notify_type']);
}
}



$messenger->send($reporter['user_notify_type']);
}
}


 
		if (!$pm)
{

		foreach ($post_info as $post)
{
$forum_ids[$post['forum_id']] = $post['forum_id'];
$topic_ids[$post['topic_id']] = $post['topic_id'];

		foreach ($post_info as $post)
{
$forum_ids[$post['forum_id']] = $post['forum_id'];
$topic_ids[$post['topic_id']] = $post['topic_id'];

 
			}

		}

unset($notify_reporters, $post_info, $reports);

$messenger->save_queue();


		}

unset($notify_reporters, $post_info, $reports);

$messenger->save_queue();


		$success_msg = (sizeof($report_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_' . strtoupper($action) . 'D_SUCCESS';

		$success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS';

	}
else
{

	}
else
{

		confirm_box(false, $user->lang[strtoupper($action) . '_REPORT' . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);

		confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);

	}

$redirect = request_var('redirect', "index.$phpEx");

	}

$redirect = request_var('redirect', "index.$phpEx");

Line 626Line 705
	else
{
meta_refresh(3, $redirect);

	else
{
meta_refresh(3, $redirect);

 


		$return_forum = '';

		$return_forum = '';

		if (sizeof($forum_ids == 1))





		$return_topic = '';

if (!$pm)
{
if (sizeof($forum_ids) === 1)

		{
$return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
}

		{
$return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
}

		$return_topic = '';
if (sizeof($topic_ids == 1))


if (sizeof($topic_ids) === 1)

		{

		{

			$return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';


				$return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&amp;f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
}

		}

trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));

		}

trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));