123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- <?php
- if (!defined('SMF'))
- die('No direct access...');
- function ReportedContent()
- {
- global $txt, $context, $scripturl, $user_info, $smcFunc;
- global $sourcedir;
-
-
- $context['report_type'] = substr($_GET['area'], 8);
- loadLanguage('ModerationCenter');
- loadTemplate('ReportedContent');
-
- require_once($sourcedir . '/Subs-ReportedContent.php');
-
- $context['report_post_action'] = !empty($_SESSION['rc_confirmation']) ? $_SESSION['rc_confirmation'] : array();
- unset($_SESSION['rc_confirmation']);
-
- $context['page_title'] = $txt['mc_reported_' . $context['report_type']];
-
- $context[$context['moderation_menu_name']]['tab_data'] = array(
- 'title' => $txt['mc_reported_' . $context['report_type']],
- 'help' => '',
- 'description' => $txt['mc_reported_' . $context['report_type'] . '_desc'],
- );
-
- if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1')
- isAllowedTo('moderate_forum');
- $sub_actions = array(
- 'show' => 'ShowReports',
- 'closed' => 'ShowClosedReports',
- 'handle' => 'HandleReport',
- 'details' => 'ReportDetails',
- 'handlecomment' => 'HandleComment',
- 'editcomment' => 'EditComment',
- );
-
- call_integration_hook('integrate_reported_' . $context['report_type'], array(&$sub_actions));
-
- if (isset($_REQUEST['sa']) && isset($sub_actions[$_REQUEST['sa']]))
- $context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
- else
- $context['sub_action'] = 'show';
-
- $sub_actions[$context['sub_action']]();
- }
- function ShowReports()
- {
- global $context, $txt, $scripturl;
-
- $context['view_closed'] = 0;
-
- $context['sub_template'] = 'reported_' . $context['report_type'];
- $context['start'] = (int) isset($_GET['start']) ? $_GET['start'] : 0;
-
- $context['total_reports'] = countReports($context['view_closed']);
-
- $context['reports_how_many'] = 10;
-
- $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=show', $context['start'], $context['total_reports'], $context['reports_how_many']);
-
- $context['reports'] = getReports($context['view_closed']);
-
- if (isset($_POST['close']) && isset($_POST['close_selected']))
- {
- checkSession('post');
- validateToken('mod-report-close-all');
-
- $toClose = array();
- foreach ($_POST['close'] as $rid)
- $toClose[] = (int) $rid;
- if (!empty($toClose))
- updateReport('closed', 1, $toClose);
-
- $_SESSION['rc_confirmation'] = 'close_all';
-
- redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type']);
- }
-
- if (!$context['view_closed'])
- addInlineJavascript('
- $(\'.delete_message\').on(\'click\', function(){
- return confirm('. JavaScriptEscape($txt['mc_reportedp_delete_confirm']) .');
- });
- $(\'.report_ignore\').on(\'click\', function(){
- // Need to make sure to only show this when ignoring.
- if ($(this).data(\'ignore\') == \'1\'){
- return confirm('. JavaScriptEscape($txt['mc_reportedp_ignore_confirm']) .');
- }
- });', true);
- createToken('mod-report-close-all');
- createToken('mod-report-ignore', 'get');
- createToken('mod-report-closed', 'get');
- }
- function ShowClosedReports()
- {
- global $context, $txt, $scripturl;
-
- $context['view_closed'] = 1;
-
- $context['sub_template'] = 'reported_' . $context['report_type'];
- $context['start'] = (int) isset($_GET['start']) ? $_GET['start'] : 0;
-
- $context['total_reports'] = countReports($context['view_closed']);
-
- $context['reports_how_many'] = 10;
-
- $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=closed', $context['start'], $context['total_reports'], $context['reports_how_many']);
-
- $context['reports'] = getReports($context['view_closed']);
-
- addInlineJavascript('
- $(\'.delete_message\').on(\'click\', function(){
- return confirm('. JavaScriptEscape($txt['mc_reportedp_delete_confirm']) .');
- });
- $(\'.report_ignore\').on(\'click\', function(){
- // Need to make sure to only show this when ignoring.
- if ($(this).data(\'ignore\') == \'1\'){
- return confirm('. JavaScriptEscape($txt['mc_reportedp_ignore_confirm']) .');
- }
- });', true);
- createToken('mod-report-ignore', 'get');
- createToken('mod-report-closed', 'get');
- }
- function ReportDetails()
- {
- global $user_info, $context, $sourcedir, $scripturl, $txt;
- global $smcFunc;
- $report = array();
- $reportComments = array();
-
- if (empty($_REQUEST['rid']))
- fatal_lang_error('mc_reportedp_none_found');
-
- $report_id = (int) $_REQUEST['rid'];
-
- $report = getReportDetails($report_id);
- if(!$report)
- fatal_lang_error('mc_no_modreport_found');
-
- $context['report'] = array(
- 'id' => $report['id_report'],
- 'report_href' => $scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';rid=' . $report['id_report'],
- 'comments' => array(),
- 'mod_comments' => array(),
- 'time_started' => timeformat($report['time_started']),
- 'last_updated' => timeformat($report['time_updated']),
- 'num_reports' => $report['num_reports'],
- 'closed' => $report['closed'],
- 'ignore' => $report['ignore_all']
- );
-
- if ($context['report_type'] == 'members')
- {
- $extraDetails = array(
- 'user' => array(
- 'id' => $report['id_user'],
- 'name' => $report['user_name'],
- 'link' => $report['id_user'] ? '<a href="' . $scripturl . '?action=profile;u=' . $report['id_user'] . '">' . $report['user_name'] . '</a>' : $report['user_name'],
- 'href' => $scripturl . '?action=profile;u=' . $report['id_user'],
- ),
- );
- }
- else
- {
- $extraDetails = array(
- 'topic_id' => $report['id_topic'],
- 'board_id' => $report['id_board'],
- 'message_id' => $report['id_msg'],
- 'message_href' => $scripturl . '?msg=' . $report['id_msg'],
- 'message_link' => '<a href="' . $scripturl . '?msg=' . $report['id_msg'] . '">' . $report['subject'] . '</a>',
- 'author' => array(
- 'id' => $report['id_author'],
- 'name' => $report['author_name'],
- 'link' => $report['id_author'] ? '<a href="' . $scripturl . '?action=profile;u=' . $report['id_author'] . '">' . $report['author_name'] . '</a>' : $report['author_name'],
- 'href' => $scripturl . '?action=profile;u=' . $report['id_author'],
- ),
- 'subject' => $report['subject'],
- 'body' => parse_bbc($report['body']),
- );
- }
- $context['report'] = array_merge($context['report'], $extraDetails);
- $reportComments = getReportComments($report_id);
- if (!empty($reportComments))
- $context['report'] = array_merge($context['report'], $reportComments);
-
- require_once($sourcedir . '/Modlog.php');
- require_once($sourcedir . '/Subs-List.php');
- loadLanguage('Modlog');
-
- if ($context['report_type'] == 'members')
- {
-
- $user_id_length = strlen((string)$context['report']['user']['id']);
- $member = 's:6:"member";s:' . $user_id_length . ':"' . $context['report']['user']['id'] . '";}';
- $params = array(
- 'lm.extra LIKE {raw:member}
- AND lm.action LIKE {raw:report}',
- array('member' => '\'%' . $member . '\'', 'report' => '\'%_user_report\''),
- 1,
- true,
- );
- }
- else
- {
- $params = array(
- 'lm.id_topic = {int:id_topic}
- AND lm.id_board != {int:not_a_reported_post}',
- array('id_topic' => $context['report']['topic_id'], 'not_a_reported_post' => 0),
- 1,
- );
- }
-
- $listOptions = array(
- 'id' => 'moderation_actions_list',
- 'title' => $txt['mc_modreport_modactions'],
- 'items_per_page' => 15,
- 'no_items_label' => $txt['modlog_no_entries_found'],
- 'base_href' => $scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $context['report']['id'],
- 'default_sort_col' => 'time',
- 'get_items' => array(
- 'function' => 'list_getModLogEntries',
- 'params' => $params,
- ),
- 'get_count' => array(
- 'function' => 'list_getModLogEntryCount',
- 'params' => $params,
- ),
-
- 'columns' => array(
- 'action' => array(
- 'header' => array(
- 'value' => $txt['modlog_action'],
- ),
- 'data' => array(
- 'db' => 'action_text',
- 'class' => 'smalltext',
- ),
- 'sort' => array(
- 'default' => 'lm.action',
- 'reverse' => 'lm.action DESC',
- ),
- ),
- 'time' => array(
- 'header' => array(
- 'value' => $txt['modlog_date'],
- ),
- 'data' => array(
- 'db' => 'time',
- 'class' => 'smalltext',
- ),
- 'sort' => array(
- 'default' => 'lm.log_time',
- 'reverse' => 'lm.log_time DESC',
- ),
- ),
- 'moderator' => array(
- 'header' => array(
- 'value' => $txt['modlog_member'],
- ),
- 'data' => array(
- 'db' => 'moderator_link',
- 'class' => 'smalltext',
- ),
- 'sort' => array(
- 'default' => 'mem.real_name',
- 'reverse' => 'mem.real_name DESC',
- ),
- ),
- 'position' => array(
- 'header' => array(
- 'value' => $txt['modlog_position'],
- ),
- 'data' => array(
- 'db' => 'position',
- 'class' => 'smalltext',
- ),
- 'sort' => array(
- 'default' => 'mg.group_name',
- 'reverse' => 'mg.group_name DESC',
- ),
- ),
- 'ip' => array(
- 'header' => array(
- 'value' => $txt['modlog_ip'],
- ),
- 'data' => array(
- 'db' => 'ip',
- 'class' => 'smalltext',
- ),
- 'sort' => array(
- 'default' => 'lm.ip',
- 'reverse' => 'lm.ip DESC',
- ),
- ),
- ),
- );
-
- createList($listOptions);
-
- if ($context['report']['closed'])
- $context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
- addInlineJavascript('
- $(\'.deleteModComment\').on(\'click\', function() {
- return confirm('. (JavaScriptEscape($txt['mc_reportedp_delete_confirm'])) .');
- });', true);
-
- if ($context['report_type'] == 'members')
- {
- $context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']);
- $context['sub_template'] = 'viewmemberreport';
- }
- else
- {
- $context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']);
- $context['sub_template'] = 'viewmodreport';
- }
-
- addInlineJavascript('
- $(\'.report_ignore\').on(\'click\', function(){
- // Need to make sure to only show this when ignoring.
- if ($(this).data(\'ignore\') == \'1\'){
- return confirm('. JavaScriptEscape($txt['mc_reportedp_ignore_confirm']) .');
- }
- });', true);
- createToken('mod-reportC-add');
- createToken('mod-reportC-delete', 'get');
-
- createToken('mod-report-ignore', 'get');
- createToken('mod-report-closed', 'get');
- }
- function HandleComment()
- {
- global $smcFunc, $scripturl, $user_info;
- $comment = array();
-
- if (empty($_REQUEST['rid']))
- fatal_lang_error('mc_reportedp_none_found');
-
- $report_id = (int) $_REQUEST['rid'];
-
- if (isset($_POST['add_comment']) && !empty($_POST['mod_comment']))
- {
- checkSession();
- validateToken('mod-reportC-add');
- $new_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
- saveModComment($report_id, array($report_id, $new_comment, time()));
-
- $_SESSION['rc_confirmation'] = 'message_saved';
- }
-
- if (isset($_REQUEST['delete']) && isset($_REQUEST['mid']))
- {
- checkSession('get');
- validateToken('mod-reportC-delete', 'get');
- if (empty($_REQUEST['mid']))
- fatal_lang_error('mc_reportedp_comment_none_found');
- $comment_id = (int) $_REQUEST['mid'];
-
- $comment = getCommentModDetails($comment_id);
-
- if (empty($comment))
- fatal_lang_error('report_action_message_delete_issue');
-
- $comment_owner = $user_info['id'] == $context['comment']['id_member'];
-
- if (!allowedTo('admin_forum') || !$comment_owner)
- fatal_lang_error('report_action_message_delete_cannot');
-
- deleteModComment($comment_id);
-
- $_SESSION['rc_confirmation'] = 'message_deleted';
- }
-
- redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $report_id);
- }
- function EditComment()
- {
- global $smcFunc, $context, $txt, $scripturl, $user_info;
- $comment = array();
- checkSession(isset($_REQUEST['save']) ? 'post' : 'get');
-
- if (empty($_REQUEST['rid']))
- fatal_lang_error('mc_reportedp_none_found');
- if (empty($_REQUEST['mid']))
- fatal_lang_error('mc_reportedp_comment_none_found');
-
- $context['report_id'] = (int) $_REQUEST['rid'];
- $context['comment_id'] = (int) $_REQUEST['mid'];
- $context['comment'] = getCommentModDetails($context['comment_id']);
- if (empty($context['comment']))
- fatal_lang_error('mc_reportedp_comment_none_found');
-
- $context['page_title'] = $txt['mc_reported_posts'];
- $context['sub_template'] = 'edit_comment';
- if (isset($_REQUEST['save']) && isset($_POST['edit_comment']) && !empty($_POST['mod_comment']))
- {
- validateToken('mod-reportC-edit');
-
- if (empty($context['comment']))
- fatal_lang_error('report_action_message_edit_issue');
-
- $comment_owner = $user_info['id'] == $context['comment']['id_member'];
-
- if (!allowedTo('admin_forum') || !$comment_owner)
- fatal_lang_error('report_action_message_edit_cannot');
-
- $edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
- editModComment($context['comment_id'], $edited_comment);
- $_SESSION['rc_confirmation'] = 'message_edited';
- redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $context['report_id']);
- }
- createToken('mod-reportC-edit');
- }
- function HandleReport()
- {
- global $scripturl, $context;
- checkSession('get');
-
- if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed'])))
- fatal_lang_error('mc_reportedp_none_found');
-
- $action = isset($_GET['ignore']) ? 'ignore' : 'closed';
- validateToken('mod-report-'. $action, 'get');
-
- $value = (int) $_GET[$action];
-
- $message = $action == 'ignore' ? ($value ? 'ignore' : 'unignore') : ($value ? 'close' : 'open');
-
- $report_id = (int) $_REQUEST['rid'];
-
- updateReport($action, $value, $report_id);
-
- $_SESSION['rc_confirmation'] = $message;
-
- redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type']);
- }
- ?>
|