indvdum@0: p_master = &$p_master; indvdum@0: } indvdum@0: indvdum@0: function main($id, $mode) indvdum@0: { indvdum@0: global $auth, $db, $user, $template, $cache; indvdum@0: global $config, $phpbb_root_path, $phpEx, $action; indvdum@0: indvdum@0: include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); indvdum@0: indvdum@0: $forum_id = request_var('f', 0); indvdum@0: $start = request_var('start', 0); indvdum@0: indvdum@0: $this->page_title = 'MCP_REPORTS'; indvdum@0: indvdum@0: switch ($action) indvdum@0: { indvdum@0: case 'close': indvdum@0: case 'delete': indvdum@0: include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); indvdum@0: indvdum@0: $report_id_list = request_var('report_id_list', array(0)); indvdum@0: indvdum@0: if (!sizeof($report_id_list)) indvdum@0: { indvdum@0: trigger_error('NO_REPORT_SELECTED'); indvdum@0: } indvdum@0: indvdum@0: close_report($report_id_list, $mode, $action); indvdum@0: indvdum@0: break; indvdum@0: } indvdum@0: indvdum@0: switch ($mode) indvdum@0: { indvdum@0: case 'report_details': indvdum@0: indvdum@0: $user->add_lang(array('posting', 'viewforum', 'viewtopic')); indvdum@0: indvdum@0: $post_id = request_var('p', 0); indvdum@0: indvdum@0: // closed reports are accessed by report id indvdum@0: $report_id = request_var('r', 0); indvdum@0: indvdum@0: $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour indvdum@0: FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u indvdum@0: WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' indvdum@0: AND rr.reason_id = r.reason_id indvdum@0: AND r.user_id = u.user_id indvdum@0: AND r.pm_id = 0 indvdum@0: ORDER BY report_closed ASC'; indvdum@0: $result = $db->sql_query_limit($sql, 1); indvdum@0: $report = $db->sql_fetchrow($result); indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: if (!$report) indvdum@0: { indvdum@0: trigger_error('NO_REPORT'); indvdum@0: } indvdum@0: indvdum@0: if (!$report_id && $report['report_closed']) indvdum@0: { indvdum@0: trigger_error('REPORT_CLOSED'); indvdum@0: } indvdum@0: indvdum@0: $post_id = $report['post_id']; indvdum@0: $report_id = $report['report_id']; indvdum@0: indvdum@0: $post_info = get_post_data(array($post_id), 'm_report', true); indvdum@0: indvdum@0: if (!sizeof($post_info)) indvdum@0: { indvdum@0: trigger_error('NO_REPORT_SELECTED'); indvdum@0: } indvdum@0: indvdum@0: $post_info = $post_info[$post_id]; indvdum@0: indvdum@0: $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); indvdum@0: if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) indvdum@0: { indvdum@0: $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; indvdum@0: $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; indvdum@0: } indvdum@0: indvdum@0: if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) indvdum@0: { indvdum@0: $template->assign_vars(array( indvdum@0: 'S_TOPIC_REVIEW' => true, indvdum@0: 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], indvdum@0: 'TOPIC_TITLE' => $post_info['topic_title']) indvdum@0: ); indvdum@0: } indvdum@0: indvdum@0: $topic_tracking_info = $extensions = $attachments = array(); indvdum@0: // Get topic tracking info indvdum@0: if ($config['load_db_lastread']) indvdum@0: { indvdum@0: $tmp_topic_data = array($post_info['topic_id'] => $post_info); indvdum@0: $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); indvdum@0: unset($tmp_topic_data); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); indvdum@0: } indvdum@0: indvdum@0: $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; indvdum@0: indvdum@0: // Process message, leave it uncensored indvdum@0: $message = $post_info['post_text']; indvdum@0: indvdum@0: if ($post_info['bbcode_bitfield']) indvdum@0: { indvdum@0: include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); indvdum@0: $bbcode = new bbcode($post_info['bbcode_bitfield']); indvdum@0: $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); indvdum@0: } indvdum@0: indvdum@0: $message = bbcode_nl2br($message); indvdum@0: $message = smiley_text($message); indvdum@0: $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); indvdum@0: indvdum@0: if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) indvdum@0: { indvdum@0: $sql = 'SELECT * indvdum@0: FROM ' . ATTACHMENTS_TABLE . ' indvdum@0: WHERE post_msg_id = ' . $post_id . ' indvdum@0: AND in_message = 0 indvdum@0: ORDER BY filetime DESC'; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $attachments[] = $row; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: if (sizeof($attachments)) indvdum@0: { indvdum@0: $update_count = array(); indvdum@0: parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); indvdum@0: } indvdum@0: indvdum@0: // Display not already displayed Attachments for this post, we already parsed them. ;) indvdum@0: if (!empty($attachments)) indvdum@0: { indvdum@0: $template->assign_var('S_HAS_ATTACHMENTS', true); indvdum@0: indvdum@0: foreach ($attachments as $attachment) indvdum@0: { indvdum@0: $template->assign_block_vars('attachment', array( indvdum@0: 'DISPLAY_ATTACHMENT' => $attachment) indvdum@0: ); indvdum@0: } indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: $template->assign_vars(array( indvdum@0: 'S_MCP_REPORT' => true, indvdum@0: 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), indvdum@0: 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), indvdum@0: 'S_POST_REPORTED' => $post_info['post_reported'], indvdum@0: 'S_POST_UNAPPROVED' => !$post_info['post_approved'], indvdum@0: 'S_POST_LOCKED' => $post_info['post_edit_locked'], indvdum@0: 'S_USER_NOTES' => true, indvdum@0: indvdum@0: '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']}") : '', indvdum@0: 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), indvdum@0: 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), indvdum@0: 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']), indvdum@0: 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), indvdum@0: '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']) : '', indvdum@0: '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']) : '', indvdum@0: 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $post_info['forum_id']), indvdum@0: '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']), indvdum@0: 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), indvdum@0: indvdum@0: 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), indvdum@0: 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), indvdum@0: 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), indvdum@0: indvdum@0: 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '', ''), indvdum@0: 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), indvdum@0: 'REPORT_DATE' => $user->format_date($report['report_time']), indvdum@0: 'REPORT_ID' => $report_id, indvdum@0: 'REPORT_REASON_TITLE' => $reason['title'], indvdum@0: 'REPORT_REASON_DESCRIPTION' => $reason['description'], indvdum@0: 'REPORT_TEXT' => $report['report_text'], indvdum@0: indvdum@0: 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), indvdum@0: 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), indvdum@0: 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), indvdum@0: 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), indvdum@0: indvdum@0: 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), indvdum@0: 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), indvdum@0: 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), indvdum@0: 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), indvdum@0: indvdum@0: 'POST_PREVIEW' => $message, indvdum@0: 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], indvdum@0: 'POST_DATE' => $user->format_date($post_info['post_time']), indvdum@0: 'POST_IP' => $post_info['poster_ip'], indvdum@0: 'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '', indvdum@0: 'POST_ID' => $post_info['post_id'], indvdum@0: indvdum@0: 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '', indvdum@0: )); indvdum@0: indvdum@0: $this->tpl_name = 'mcp_post'; indvdum@0: indvdum@0: break; indvdum@0: indvdum@0: case 'reports': indvdum@0: case 'reports_closed': indvdum@0: $topic_id = request_var('t', 0); indvdum@0: indvdum@0: $forum_info = array(); indvdum@0: $forum_list_reports = get_forum_list('m_report', false, true); indvdum@0: $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs indvdum@0: indvdum@0: // Remove forums we cannot read indvdum@0: foreach ($forum_list_reports as $k => $forum_data) indvdum@0: { indvdum@0: if (!isset($forum_list_read[$forum_data['forum_id']])) indvdum@0: { indvdum@0: unset($forum_list_reports[$k]); indvdum@0: } indvdum@0: } indvdum@0: unset($forum_list_read); indvdum@0: indvdum@0: if ($topic_id) indvdum@0: { indvdum@0: $topic_info = get_topic_data(array($topic_id)); indvdum@0: indvdum@0: if (!sizeof($topic_info)) indvdum@0: { indvdum@0: trigger_error('TOPIC_NOT_EXIST'); indvdum@0: } indvdum@0: indvdum@0: if ($forum_id != $topic_info[$topic_id]['forum_id']) indvdum@0: { indvdum@0: $topic_id = 0; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $topic_info = $topic_info[$topic_id]; indvdum@0: $forum_id = (int) $topic_info['forum_id']; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: $forum_list = array(); indvdum@0: indvdum@0: if (!$forum_id) indvdum@0: { indvdum@0: foreach ($forum_list_reports as $row) indvdum@0: { indvdum@0: $forum_list[] = $row['forum_id']; indvdum@0: } indvdum@0: indvdum@0: if (!sizeof($forum_list)) indvdum@0: { indvdum@0: trigger_error('NOT_MODERATOR'); indvdum@0: } indvdum@0: indvdum@0: $global_id = $forum_list[0]; indvdum@0: indvdum@0: $sql = 'SELECT SUM(forum_topics) as sum_forum_topics indvdum@0: FROM ' . FORUMS_TABLE . ' indvdum@0: WHERE ' . $db->sql_in_set('forum_id', $forum_list); indvdum@0: $result = $db->sql_query($sql); indvdum@0: $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); indvdum@0: $db->sql_freeresult($result); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $forum_info = get_forum_data(array($forum_id), 'm_report'); indvdum@0: indvdum@0: if (!sizeof($forum_info)) indvdum@0: { indvdum@0: trigger_error('NOT_MODERATOR'); indvdum@0: } indvdum@0: indvdum@0: $forum_info = $forum_info[$forum_id]; indvdum@0: $forum_list = array($forum_id); indvdum@0: $global_id = $forum_id; indvdum@0: } indvdum@0: indvdum@0: $forum_list[] = 0; indvdum@0: $forum_data = array(); indvdum@0: indvdum@0: $forum_options = ''; indvdum@0: foreach ($forum_list_reports as $row) indvdum@0: { indvdum@0: $forum_options .= ''; indvdum@0: $forum_data[$row['forum_id']] = $row; indvdum@0: } indvdum@0: unset($forum_list_reports); indvdum@0: indvdum@0: $sort_days = $total = 0; indvdum@0: $sort_key = $sort_dir = ''; indvdum@0: $sort_by_sql = $sort_order_sql = array(); indvdum@0: mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); indvdum@0: indvdum@0: $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; indvdum@0: $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; indvdum@0: indvdum@0: if ($mode == 'reports') indvdum@0: { indvdum@0: $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $report_state = 'AND r.report_closed = 1'; indvdum@0: } indvdum@0: indvdum@0: $sql = 'SELECT r.report_id indvdum@0: FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . ' indvdum@0: WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . " indvdum@0: $report_state indvdum@0: AND r.post_id = p.post_id indvdum@0: " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' indvdum@0: ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . ' indvdum@0: ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " indvdum@0: AND t.topic_id = p.topic_id indvdum@0: AND r.pm_id = 0 indvdum@0: $limit_time_sql indvdum@0: ORDER BY $sort_order_sql"; indvdum@0: $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); indvdum@0: indvdum@0: $i = 0; indvdum@0: $report_ids = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $report_ids[] = $row['report_id']; indvdum@0: $row_num[$row['report_id']] = $i++; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: if (sizeof($report_ids)) indvdum@0: { indvdum@0: $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id indvdum@0: FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru indvdum@0: WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' indvdum@0: AND t.topic_id = p.topic_id indvdum@0: AND r.post_id = p.post_id indvdum@0: AND u.user_id = p.poster_id indvdum@0: AND ru.user_id = r.user_id indvdum@0: AND r.pm_id = 0 indvdum@0: ORDER BY ' . $sort_order_sql; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $report_data = $rowset = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $global_topic = ($row['forum_id']) ? false : true; indvdum@0: if ($global_topic) indvdum@0: { indvdum@0: $row['forum_id'] = $global_id; indvdum@0: } indvdum@0: indvdum@0: $template->assign_block_vars('postrow', array( indvdum@0: 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', indvdum@0: 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], indvdum@0: 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), indvdum@0: indvdum@0: 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), indvdum@0: 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), indvdum@0: 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), indvdum@0: 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), indvdum@0: indvdum@0: 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), indvdum@0: 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), indvdum@0: 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), indvdum@0: 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), indvdum@0: indvdum@0: 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], indvdum@0: 'POST_ID' => $row['post_id'], indvdum@0: 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], indvdum@0: 'POST_TIME' => $user->format_date($row['post_time']), indvdum@0: 'REPORT_ID' => $row['report_id'], indvdum@0: 'REPORT_TIME' => $user->format_date($row['report_time']), indvdum@0: 'TOPIC_TITLE' => $row['topic_title']) indvdum@0: ); indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: unset($report_ids, $row); indvdum@0: } indvdum@0: indvdum@0: // Now display the page indvdum@0: $template->assign_vars(array( indvdum@0: 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], indvdum@0: 'L_TITLE' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], indvdum@0: 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', indvdum@0: indvdum@0: 'S_MCP_ACTION' => $this->u_action, indvdum@0: 'S_FORUM_OPTIONS' => $forum_options, indvdum@0: 'S_CLOSED' => ($mode == 'reports_closed') ? true : false, indvdum@0: indvdum@0: 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), indvdum@0: 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), indvdum@0: 'TOPIC_ID' => $topic_id, indvdum@0: 'TOTAL' => $total, indvdum@0: 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), indvdum@0: ) indvdum@0: ); indvdum@0: indvdum@0: $this->tpl_name = 'mcp_reports'; indvdum@0: break; indvdum@0: } indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Closes a report indvdum@0: */ indvdum@0: function close_report($report_id_list, $mode, $action, $pm = false) indvdum@0: { indvdum@0: global $db, $template, $user, $config, $auth; indvdum@0: global $phpEx, $phpbb_root_path; indvdum@0: indvdum@0: $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; indvdum@0: $id_column = ($pm) ? 'pm_id' : 'post_id'; indvdum@0: $module = ($pm) ? 'pm_reports' : 'reports'; indvdum@0: $pm_prefix = ($pm) ? 'PM_' : ''; indvdum@0: indvdum@0: $sql = "SELECT r.$id_column indvdum@0: FROM " . REPORTS_TABLE . ' r indvdum@0: WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $post_id_list = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $post_id_list[] = $row[$id_column]; indvdum@0: } indvdum@0: $post_id_list = array_unique($post_id_list); indvdum@0: indvdum@0: if ($pm) indvdum@0: { indvdum@0: if (!$auth->acl_getf_global('m_report')) indvdum@0: { indvdum@0: trigger_error('NOT_AUTHORISED'); indvdum@0: } indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) indvdum@0: { indvdum@0: trigger_error('NOT_AUTHORISED'); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false) indvdum@0: { indvdum@0: $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports'); indvdum@0: } indvdum@0: elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) indvdum@0: { indvdum@0: $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports'); indvdum@0: } indvdum@0: else if ($action == 'close' && !request_var('r', 0)) indvdum@0: { indvdum@0: $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $redirect = request_var('redirect', build_url(array('quickmod'))); indvdum@0: } indvdum@0: $success_msg = ''; indvdum@0: $forum_ids = array(); indvdum@0: $topic_ids = array(); indvdum@0: indvdum@0: $s_hidden_fields = build_hidden_fields(array( indvdum@0: 'i' => $module, indvdum@0: 'mode' => $mode, indvdum@0: 'report_id_list' => $report_id_list, indvdum@0: 'action' => $action, indvdum@0: 'redirect' => $redirect) indvdum@0: ); indvdum@0: indvdum@0: if (confirm_box(true)) indvdum@0: { indvdum@0: $post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report'); indvdum@0: indvdum@0: $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 indvdum@0: FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u indvdum@0: WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' indvdum@0: ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' indvdum@0: AND r.user_id = u.user_id' . $pm_where; indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array(); indvdum@0: while ($report = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $reports[$report['report_id']] = $report; indvdum@0: $report_id_list[] = $report['report_id']; indvdum@0: indvdum@0: if (!$report['report_closed']) indvdum@0: { indvdum@0: $close_report_posts[] = $report[$id_column]; indvdum@0: indvdum@0: if (!$pm) indvdum@0: { indvdum@0: $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if ($report['user_notify'] && !$report['report_closed']) indvdum@0: { indvdum@0: $notify_reporters[$report['report_id']] = &$reports[$report['report_id']]; indvdum@0: } indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: if (sizeof($reports)) indvdum@0: { indvdum@0: $close_report_posts = array_unique($close_report_posts); indvdum@0: $close_report_topics = array_unique($close_report_topics); indvdum@0: indvdum@0: if (!$pm && sizeof($close_report_posts)) indvdum@0: { indvdum@0: // Get a list of topics that still contain reported posts indvdum@0: $sql = 'SELECT DISTINCT topic_id indvdum@0: FROM ' . POSTS_TABLE . ' indvdum@0: WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' indvdum@0: AND post_reported = 1 indvdum@0: AND ' . $db->sql_in_set('post_id', $close_report_posts, true); indvdum@0: $result = $db->sql_query($sql); indvdum@0: indvdum@0: $keep_report_topics = array(); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $keep_report_topics[] = $row['topic_id']; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: indvdum@0: $close_report_topics = array_diff($close_report_topics, $keep_report_topics); indvdum@0: unset($keep_report_topics); indvdum@0: } indvdum@0: indvdum@0: $db->sql_transaction('begin'); indvdum@0: indvdum@0: if ($action == 'close') indvdum@0: { indvdum@0: $sql = 'UPDATE ' . REPORTS_TABLE . ' indvdum@0: SET report_closed = 1 indvdum@0: WHERE ' . $db->sql_in_set('report_id', $report_id_list); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $sql = 'DELETE FROM ' . REPORTS_TABLE . ' indvdum@0: WHERE ' . $db->sql_in_set('report_id', $report_id_list); indvdum@0: } indvdum@0: $db->sql_query($sql); indvdum@0: indvdum@0: indvdum@0: if (sizeof($close_report_posts)) indvdum@0: { indvdum@0: if ($pm) indvdum@0: { indvdum@0: $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' indvdum@0: SET message_reported = 0 indvdum@0: WHERE ' . $db->sql_in_set('msg_id', $close_report_posts); indvdum@0: $db->sql_query($sql); indvdum@0: indvdum@0: if ($action == 'delete') indvdum@0: { indvdum@0: delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX); indvdum@0: } indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $sql = 'UPDATE ' . POSTS_TABLE . ' indvdum@0: SET post_reported = 0 indvdum@0: WHERE ' . $db->sql_in_set('post_id', $close_report_posts); indvdum@0: $db->sql_query($sql); indvdum@0: indvdum@0: if (sizeof($close_report_topics)) indvdum@0: { indvdum@0: $sql = 'UPDATE ' . TOPICS_TABLE . ' indvdum@0: SET topic_reported = 0 indvdum@0: WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' indvdum@0: OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); indvdum@0: $db->sql_query($sql); indvdum@0: } indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: $db->sql_transaction('commit'); indvdum@0: } indvdum@0: unset($close_report_posts, $close_report_topics); indvdum@0: indvdum@0: foreach ($reports as $report) indvdum@0: { indvdum@0: if ($pm) indvdum@0: { indvdum@0: add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: 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']); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: $messenger = new messenger(); indvdum@0: indvdum@0: // Notify reporters indvdum@0: if (sizeof($notify_reporters)) indvdum@0: { indvdum@0: foreach ($notify_reporters as $report_id => $reporter) indvdum@0: { indvdum@0: if ($reporter['user_id'] == ANONYMOUS) indvdum@0: { indvdum@0: continue; indvdum@0: } indvdum@0: indvdum@0: $post_id = $reporter[$id_column]; indvdum@0: indvdum@0: $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); indvdum@0: indvdum@0: $messenger->to($reporter['user_email'], $reporter['username']); indvdum@0: $messenger->im($reporter['user_jabber'], $reporter['username']); indvdum@0: indvdum@0: if ($pm) indvdum@0: { indvdum@0: $messenger->assign_vars(array( indvdum@0: 'USERNAME' => htmlspecialchars_decode($reporter['username']), indvdum@0: 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), indvdum@0: 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), indvdum@0: )); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $messenger->assign_vars(array( indvdum@0: 'USERNAME' => htmlspecialchars_decode($reporter['username']), indvdum@0: 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), indvdum@0: 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), indvdum@0: 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) indvdum@0: ); indvdum@0: } indvdum@0: indvdum@0: $messenger->send($reporter['user_notify_type']); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if (!$pm) indvdum@0: { indvdum@0: foreach ($post_info as $post) indvdum@0: { indvdum@0: $forum_ids[$post['forum_id']] = $post['forum_id']; indvdum@0: $topic_ids[$post['topic_id']] = $post['topic_id']; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: unset($notify_reporters, $post_info, $reports); indvdum@0: indvdum@0: $messenger->save_queue(); indvdum@0: indvdum@0: $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); indvdum@0: } indvdum@0: indvdum@0: $redirect = request_var('redirect', "index.$phpEx"); indvdum@0: $redirect = reapply_sid($redirect); indvdum@0: indvdum@0: if (!$success_msg) indvdum@0: { indvdum@0: redirect($redirect); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: meta_refresh(3, $redirect); indvdum@0: indvdum@0: $return_forum = ''; indvdum@0: $return_topic = ''; indvdum@0: indvdum@0: if (!$pm) indvdum@0: { indvdum@0: if (sizeof($forum_ids) === 1) indvdum@0: { indvdum@0: $return_forum = sprintf($user->lang['RETURN_FORUM'], '', '') . '

'; indvdum@0: } indvdum@0: indvdum@0: if (sizeof($topic_ids) === 1) indvdum@0: { indvdum@0: $return_topic = sprintf($user->lang['RETURN_TOPIC'], '', '') . '

'; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: trigger_error($user->lang[$success_msg] . '

' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "", '')); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: ?>