Chris@76: 'CustomEmail',
Chris@76: 'sendtopic' => 'SendTopic',
Chris@76: );
Chris@76:
Chris@76: if (!isset($_GET['sa']) || !isset($sub_actions[$_GET['sa']]))
Chris@76: $_GET['sa'] = 'sendtopic';
Chris@76:
Chris@76: $sub_actions[$_GET['sa']]();
Chris@76: }
Chris@76:
Chris@76: // Send a topic to a friend.
Chris@76: function SendTopic()
Chris@76: {
Chris@76: global $topic, $txt, $context, $scripturl, $sourcedir, $smcFunc, $modSettings;
Chris@76:
Chris@76: // Check permissions...
Chris@76: isAllowedTo('send_topic');
Chris@76:
Chris@76: // We need at least a topic... go away if you don't have one.
Chris@76: if (empty($topic))
Chris@76: fatal_lang_error('not_a_topic', false);
Chris@76:
Chris@76: // Get the topic's subject.
Chris@76: $request = $smcFunc['db_query']('', '
Chris@76: SELECT m.subject, t.approved
Chris@76: FROM {db_prefix}topics AS t
Chris@76: INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
Chris@76: WHERE t.id_topic = {int:current_topic}
Chris@76: LIMIT 1',
Chris@76: array(
Chris@76: 'current_topic' => $topic,
Chris@76: )
Chris@76: );
Chris@76: if ($smcFunc['db_num_rows']($request) == 0)
Chris@76: fatal_lang_error('not_a_topic', false);
Chris@76: $row = $smcFunc['db_fetch_assoc']($request);
Chris@76: $smcFunc['db_free_result']($request);
Chris@76:
Chris@76: // Can't send topic if its unapproved and using post moderation.
Chris@76: if ($modSettings['postmod_active'] && !$row['approved'])
Chris@76: fatal_lang_error('not_approved_topic', false);
Chris@76:
Chris@76: // Censor the subject....
Chris@76: censorText($row['subject']);
Chris@76:
Chris@76: // Sending yet, or just getting prepped?
Chris@76: if (empty($_POST['send']))
Chris@76: {
Chris@76: $context['page_title'] = sprintf($txt['sendtopic_title'], $row['subject']);
Chris@76: $context['start'] = $_REQUEST['start'];
Chris@76:
Chris@76: return;
Chris@76: }
Chris@76:
Chris@76: // Actually send the message...
Chris@76: checkSession();
Chris@76: spamProtection('sendtopc');
Chris@76:
Chris@76: // This is needed for sendmail().
Chris@76: require_once($sourcedir . '/Subs-Post.php');
Chris@76:
Chris@76: // Trim the names..
Chris@76: $_POST['y_name'] = trim($_POST['y_name']);
Chris@76: $_POST['r_name'] = trim($_POST['r_name']);
Chris@76:
Chris@76: // Make sure they aren't playing "let's use a fake email".
Chris@76: if ($_POST['y_name'] == '_' || !isset($_POST['y_name']) || $_POST['y_name'] == '')
Chris@76: fatal_lang_error('no_name', false);
Chris@76: if (!isset($_POST['y_email']) || $_POST['y_email'] == '')
Chris@76: fatal_lang_error('no_email', false);
Chris@76: if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['y_email']) == 0)
Chris@76: fatal_lang_error('email_invalid_character', false);
Chris@76:
Chris@76: // The receiver should be valid to.
Chris@76: if ($_POST['r_name'] == '_' || !isset($_POST['r_name']) || $_POST['r_name'] == '')
Chris@76: fatal_lang_error('no_name', false);
Chris@76: if (!isset($_POST['r_email']) || $_POST['r_email'] == '')
Chris@76: fatal_lang_error('no_email', false);
Chris@76: if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['r_email']) == 0)
Chris@76: fatal_lang_error('email_invalid_character', false);
Chris@76:
Chris@76: // Emails don't like entities...
Chris@76: $row['subject'] = un_htmlspecialchars($row['subject']);
Chris@76:
Chris@76: $replacements = array(
Chris@76: 'TOPICSUBJECT' => $row['subject'],
Chris@76: 'SENDERNAME' => $_POST['y_name'],
Chris@76: 'RECPNAME' => $_POST['r_name'],
Chris@76: 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.0',
Chris@76: );
Chris@76:
Chris@76: $emailtemplate = 'send_topic';
Chris@76:
Chris@76: if (!empty($_POST['comment']))
Chris@76: {
Chris@76: $emailtemplate .= '_comment';
Chris@76: $replacements['COMMENT'] = $_POST['comment'];
Chris@76: }
Chris@76:
Chris@76: $emaildata = loadEmailTemplate($emailtemplate, $replacements);
Chris@76: // And off we go!
Chris@76: sendmail($_POST['r_email'], $emaildata['subject'], $emaildata['body'], $_POST['y_email']);
Chris@76:
Chris@76: // Back to the topic!
Chris@76: redirectexit('topic=' . $topic . '.0');
Chris@76: }
Chris@76:
Chris@76: // Allow a user to send an email.
Chris@76: function CustomEmail()
Chris@76: {
Chris@76: global $context, $modSettings, $user_info, $smcFunc, $txt, $scripturl, $sourcedir;
Chris@76:
Chris@76: // Can the user even see this information?
Chris@76: if ($user_info['is_guest'] && !empty($modSettings['guest_hideContacts']))
Chris@76: fatal_lang_error('no_access', false);
Chris@76:
Chris@76: // Are we sending to a user?
Chris@76: $context['form_hidden_vars'] = array();
Chris@76: if (isset($_REQUEST['uid']))
Chris@76: {
Chris@76: $request = $smcFunc['db_query']('', '
Chris@76: SELECT email_address AS email, real_name AS name, id_member, hide_email
Chris@76: FROM {db_prefix}members
Chris@76: WHERE id_member = {int:id_member}',
Chris@76: array(
Chris@76: 'id_member' => (int) $_REQUEST['uid'],
Chris@76: )
Chris@76: );
Chris@76:
Chris@76: $context['form_hidden_vars']['uid'] = (int) $_REQUEST['uid'];
Chris@76: }
Chris@76: elseif (isset($_REQUEST['msg']))
Chris@76: {
Chris@76: $request = $smcFunc['db_query']('', '
Chris@76: SELECT IFNULL(mem.email_address, m.poster_email) AS email, IFNULL(mem.real_name, m.poster_name) AS name, IFNULL(mem.id_member, 0) AS id_member, hide_email
Chris@76: FROM {db_prefix}messages AS m
Chris@76: LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
Chris@76: WHERE m.id_msg = {int:id_msg}',
Chris@76: array(
Chris@76: 'id_msg' => (int) $_REQUEST['msg'],
Chris@76: )
Chris@76: );
Chris@76:
Chris@76: $context['form_hidden_vars']['msg'] = (int) $_REQUEST['msg'];
Chris@76: }
Chris@76:
Chris@76: if (empty($request) || $smcFunc['db_num_rows']($request) == 0)
Chris@76: fatal_lang_error('cant_find_user_email');
Chris@76:
Chris@76: $row = $smcFunc['db_fetch_assoc']($request);
Chris@76: $smcFunc['db_free_result']($request);
Chris@76:
Chris@76: // Are you sure you got the address?
Chris@76: if (empty($row['email']))
Chris@76: fatal_lang_error('cant_find_user_email');
Chris@76:
Chris@76: // Can they actually do this?
Chris@76: $context['show_email_address'] = showEmailAddress(!empty($row['hide_email']), $row['id_member']);
Chris@76: if ($context['show_email_address'] === 'no')
Chris@76: fatal_lang_error('no_access', false);
Chris@76:
Chris@76: // Setup the context!
Chris@76: $context['recipient'] = array(
Chris@76: 'id' => $row['id_member'],
Chris@76: 'name' => $row['name'],
Chris@76: 'email' => $row['email'],
Chris@76: 'email_link' => ($context['show_email_address'] == 'yes_permission_override' ? '' : '') . '' . $row['email'] . '' . ($context['show_email_address'] == 'yes_permission_override' ? '' : ''),
Chris@76: 'link' => $row['id_member'] ? '' . $row['name'] . '' : $row['name'],
Chris@76: );
Chris@76:
Chris@76: // Can we see this person's email address?
Chris@76: $context['can_view_receipient_email'] = $context['show_email_address'] == 'yes' || $context['show_email_address'] == 'yes_permission_override';
Chris@76:
Chris@76: // Are we actually sending it?
Chris@76: if (isset($_POST['send']) && isset($_POST['email_body']))
Chris@76: {
Chris@76: require_once($sourcedir . '/Subs-Post.php');
Chris@76:
Chris@76: checkSession();
Chris@76:
Chris@76: // If it's a guest sort out their names.
Chris@76: if ($user_info['is_guest'])
Chris@76: {
Chris@76: if (empty($_POST['y_name']) || $_POST['y_name'] == '_' || trim($_POST['y_name']) == '')
Chris@76: fatal_lang_error('no_name', false);
Chris@76: if (empty($_POST['y_email']))
Chris@76: fatal_lang_error('no_email', false);
Chris@76: if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['y_email']) == 0)
Chris@76: fatal_lang_error('email_invalid_character', false);
Chris@76:
Chris@76: $from_name = trim($_POST['y_name']);
Chris@76: $from_email = trim($_POST['y_email']);
Chris@76: }
Chris@76: else
Chris@76: {
Chris@76: $from_name = $user_info['name'];
Chris@76: $from_email = $user_info['email'];
Chris@76: }
Chris@76:
Chris@76: // Check we have a body (etc).
Chris@76: if (trim($_POST['email_body']) == '' || trim($_POST['email_subject']) == '')
Chris@76: fatal_lang_error('email_missing_data');
Chris@76:
Chris@76: // We use a template in case they want to customise!
Chris@76: $replacements = array(
Chris@76: 'EMAILSUBJECT' => $_POST['email_subject'],
Chris@76: 'EMAILBODY' => $_POST['email_body'],
Chris@76: 'SENDERNAME' => $from_name,
Chris@76: 'RECPNAME' => $context['recipient']['name'],
Chris@76: );
Chris@76:
Chris@76: // Don't let them send too many!
Chris@76: spamProtection('sendmail');
Chris@76:
Chris@76: // Get the template and get out!
Chris@76: $emaildata = loadEmailTemplate('send_email', $replacements);
Chris@76: sendmail($context['recipient']['email'], $emaildata['subject'], $emaildata['body'], $from_email, null, false, 1, null, true);
Chris@76:
Chris@76: // Now work out where to go!
Chris@76: if (isset($_REQUEST['uid']))
Chris@76: redirectexit('action=profile;u=' . (int) $_REQUEST['uid']);
Chris@76: elseif (isset($_REQUEST['msg']))
Chris@76: redirectexit('msg=' . (int) $_REQUEST['msg']);
Chris@76: else
Chris@76: redirectexit();
Chris@76: }
Chris@76:
Chris@76: $context['sub_template'] = 'custom_email';
Chris@76: $context['page_title'] = $txt['send_email'];
Chris@76: }
Chris@76:
Chris@76: // Report a post to the moderator... ask for a comment.
Chris@76: function ReportToModerator()
Chris@76: {
Chris@76: global $txt, $topic, $sourcedir, $modSettings, $user_info, $context, $smcFunc;
Chris@76:
Chris@76: $context['robot_no_index'] = true;
Chris@76:
Chris@76: // You can't use this if it's off or you are not allowed to do it.
Chris@76: isAllowedTo('report_any');
Chris@76:
Chris@76: // If they're posting, it should be processed by ReportToModerator2.
Chris@76: if ((isset($_POST[$context['session_var']]) || isset($_POST['submit'])) && empty($context['post_errors']))
Chris@76: ReportToModerator2();
Chris@76:
Chris@76: // We need a message ID to check!
Chris@76: if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']))
Chris@76: fatal_lang_error('no_access', false);
Chris@76:
Chris@76: // For compatibility, accept mid, but we should be using msg. (not the flavor kind!)
Chris@76: $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg'];
Chris@76:
Chris@76: // Check the message's ID - don't want anyone reporting a post they can't even see!
Chris@76: $result = $smcFunc['db_query']('', '
Chris@76: SELECT m.id_msg, m.id_member, t.id_member_started
Chris@76: FROM {db_prefix}messages AS m
Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
Chris@76: WHERE m.id_msg = {int:id_msg}
Chris@76: AND m.id_topic = {int:current_topic}
Chris@76: LIMIT 1',
Chris@76: array(
Chris@76: 'current_topic' => $topic,
Chris@76: 'id_msg' => $_REQUEST['msg'],
Chris@76: )
Chris@76: );
Chris@76: if ($smcFunc['db_num_rows']($result) == 0)
Chris@76: fatal_lang_error('no_board', false);
Chris@76: list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result);
Chris@76: $smcFunc['db_free_result']($result);
Chris@76:
Chris@76: // Do we need to show the visual verification image?
Chris@76: $context['require_verification'] = $user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha']);
Chris@76: if ($context['require_verification'])
Chris@76: {
Chris@76: require_once($sourcedir . '/Subs-Editor.php');
Chris@76: $verificationOptions = array(
Chris@76: 'id' => 'report',
Chris@76: );
Chris@76: $context['require_verification'] = create_control_verification($verificationOptions);
Chris@76: $context['visual_verification_id'] = $verificationOptions['id'];
Chris@76: }
Chris@76:
Chris@76: // Show the inputs for the comment, etc.
Chris@76: loadLanguage('Post');
Chris@76: loadTemplate('SendTopic');
Chris@76:
Chris@76: $context['comment_body'] = !isset($_POST['comment']) ? '' : trim($_POST['comment']);
Chris@76: $context['email_address'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
Chris@76:
Chris@76: // This is here so that the user could, in theory, be redirected back to the topic.
Chris@76: $context['start'] = $_REQUEST['start'];
Chris@76: $context['message_id'] = $_REQUEST['msg'];
Chris@76:
Chris@76: $context['page_title'] = $txt['report_to_mod'];
Chris@76: $context['sub_template'] = 'report';
Chris@76: }
Chris@76:
Chris@76: // Send the emails.
Chris@76: function ReportToModerator2()
Chris@76: {
Chris@76: global $txt, $scripturl, $topic, $board, $user_info, $modSettings, $sourcedir, $language, $context, $smcFunc;
Chris@76:
Chris@76: // You must have the proper permissions!
Chris@76: isAllowedTo('report_any');
Chris@76:
Chris@76: // Make sure they aren't spamming.
Chris@76: spamProtection('reporttm');
Chris@76:
Chris@76: require_once($sourcedir . '/Subs-Post.php');
Chris@76:
Chris@76: // No errors, yet.
Chris@76: $post_errors = array();
Chris@76:
Chris@76: // Check their session.
Chris@76: if (checkSession('post', '', false) != '')
Chris@76: $post_errors[] = 'session_timeout';
Chris@76:
Chris@76: // Make sure we have a comment and it's clean.
Chris@76: if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '')
Chris@76: $post_errors[] = 'no_comment';
Chris@76: $poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\n" => '', "\t" => ''));
Chris@76:
Chris@76: // Guests need to provide their address!
Chris@76: if ($user_info['is_guest'])
Chris@76: {
Chris@76: $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
Chris@76: if ($_POST['email'] === '')
Chris@76: $post_errors[] = 'no_email';
Chris@76: elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
Chris@76: $post_errors[] = 'bad_email';
Chris@76:
Chris@76: isBannedEmail($_POST['email'], 'cannot_post', sprintf($txt['you_are_post_banned'], $txt['guest_title']));
Chris@76:
Chris@76: $user_info['email'] = htmlspecialchars($_POST['email']);
Chris@76: }
Chris@76:
Chris@76: // Could they get the right verification code?
Chris@76: if ($user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha']))
Chris@76: {
Chris@76: require_once($sourcedir . '/Subs-Editor.php');
Chris@76: $verificationOptions = array(
Chris@76: 'id' => 'report',
Chris@76: );
Chris@76: $context['require_verification'] = create_control_verification($verificationOptions, true);
Chris@76: if (is_array($context['require_verification']))
Chris@76: $post_errors = array_merge($post_errors, $context['require_verification']);
Chris@76: }
Chris@76:
Chris@76: // Any errors?
Chris@76: if (!empty($post_errors))
Chris@76: {
Chris@76: loadLanguage('Errors');
Chris@76:
Chris@76: $context['post_errors'] = array();
Chris@76: foreach ($post_errors as $post_error)
Chris@76: $context['post_errors'][] = $txt['error_' . $post_error];
Chris@76:
Chris@76: return ReportToModerator();
Chris@76: }
Chris@76:
Chris@76: // Get the basic topic information, and make sure they can see it.
Chris@76: $_POST['msg'] = (int) $_POST['msg'];
Chris@76:
Chris@76: $request = $smcFunc['db_query']('', '
Chris@76: SELECT m.id_topic, m.id_board, m.subject, m.body, m.id_member AS id_poster, m.poster_name, mem.real_name
Chris@76: FROM {db_prefix}messages AS m
Chris@76: LEFT JOIN {db_prefix}members AS mem ON (m.id_member = mem.id_member)
Chris@76: WHERE m.id_msg = {int:id_msg}
Chris@76: AND m.id_topic = {int:current_topic}
Chris@76: LIMIT 1',
Chris@76: array(
Chris@76: 'current_topic' => $topic,
Chris@76: 'id_msg' => $_POST['msg'],
Chris@76: )
Chris@76: );
Chris@76: if ($smcFunc['db_num_rows']($request) == 0)
Chris@76: fatal_lang_error('no_board', false);
Chris@76: $message = $smcFunc['db_fetch_assoc']($request);
Chris@76: $smcFunc['db_free_result']($request);
Chris@76:
Chris@76: $poster_name = un_htmlspecialchars($message['real_name']) . ($message['real_name'] != $message['poster_name'] ? ' (' . $message['poster_name'] . ')' : '');
Chris@76: $reporterName = un_htmlspecialchars($user_info['name']) . ($user_info['name'] != $user_info['username'] && $user_info['username'] != '' ? ' (' . $user_info['username'] . ')' : '');
Chris@76: $subject = un_htmlspecialchars($message['subject']);
Chris@76:
Chris@76: // Get a list of members with the moderate_board permission.
Chris@76: require_once($sourcedir . '/Subs-Members.php');
Chris@76: $moderators = membersAllowedTo('moderate_board', $board);
Chris@76:
Chris@76: $request = $smcFunc['db_query']('', '
Chris@76: SELECT id_member, email_address, lngfile, mod_prefs
Chris@76: FROM {db_prefix}members
Chris@76: WHERE id_member IN ({array_int:moderator_list})
Chris@76: AND notify_types != {int:notify_types}
Chris@76: ORDER BY lngfile',
Chris@76: array(
Chris@76: 'moderator_list' => $moderators,
Chris@76: 'notify_types' => 4,
Chris@76: )
Chris@76: );
Chris@76:
Chris@76: // Check that moderators do exist!
Chris@76: if ($smcFunc['db_num_rows']($request) == 0)
Chris@76: fatal_lang_error('no_mods', false);
Chris@76:
Chris@76: // If we get here, I believe we should make a record of this, for historical significance, yabber.
Chris@76: if (empty($modSettings['disable_log_report']))
Chris@76: {
Chris@76: $request2 = $smcFunc['db_query']('', '
Chris@76: SELECT id_report, ignore_all
Chris@76: FROM {db_prefix}log_reported
Chris@76: WHERE id_msg = {int:id_msg}
Chris@76: AND (closed = {int:not_closed} OR ignore_all = {int:ignored})
Chris@76: ORDER BY ignore_all DESC',
Chris@76: array(
Chris@76: 'id_msg' => $_POST['msg'],
Chris@76: 'not_closed' => 0,
Chris@76: 'ignored' => 1,
Chris@76: )
Chris@76: );
Chris@76: if ($smcFunc['db_num_rows']($request2) != 0)
Chris@76: list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request2);
Chris@76: $smcFunc['db_free_result']($request2);
Chris@76:
Chris@76: // If we're just going to ignore these, then who gives a monkeys...
Chris@76: if (!empty($ignore))
Chris@76: redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
Chris@76:
Chris@76: // Already reported? My god, we could be dealing with a real rogue here...
Chris@76: if (!empty($id_report))
Chris@76: $smcFunc['db_query']('', '
Chris@76: UPDATE {db_prefix}log_reported
Chris@76: SET num_reports = num_reports + 1, time_updated = {int:current_time}
Chris@76: WHERE id_report = {int:id_report}',
Chris@76: array(
Chris@76: 'current_time' => time(),
Chris@76: 'id_report' => $id_report,
Chris@76: )
Chris@76: );
Chris@76: // Otherwise, we shall make one!
Chris@76: else
Chris@76: {
Chris@76: if (empty($message['real_name']))
Chris@76: $message['real_name'] = $message['poster_name'];
Chris@76:
Chris@76: $smcFunc['db_insert']('',
Chris@76: '{db_prefix}log_reported',
Chris@76: array(
Chris@76: 'id_msg' => 'int', 'id_topic' => 'int', 'id_board' => 'int', 'id_member' => 'int', 'membername' => 'string',
Chris@76: 'subject' => 'string', 'body' => 'string', 'time_started' => 'int', 'time_updated' => 'int',
Chris@76: 'num_reports' => 'int', 'closed' => 'int',
Chris@76: ),
Chris@76: array(
Chris@76: $_POST['msg'], $message['id_topic'], $message['id_board'], $message['id_poster'], $message['real_name'],
Chris@76: $message['subject'], $message['body'] , time(), time(), 1, 0,
Chris@76: ),
Chris@76: array('id_report')
Chris@76: );
Chris@76: $id_report = $smcFunc['db_insert_id']('{db_prefix}log_reported', 'id_report');
Chris@76: }
Chris@76:
Chris@76: // Now just add our report...
Chris@76: if ($id_report)
Chris@76: {
Chris@76: $smcFunc['db_insert']('',
Chris@76: '{db_prefix}log_reported_comments',
Chris@76: array(
Chris@76: 'id_report' => 'int', 'id_member' => 'int', 'membername' => 'string', 'email_address' => 'string',
Chris@76: 'member_ip' => 'string', 'comment' => 'string', 'time_sent' => 'int',
Chris@76: ),
Chris@76: array(
Chris@76: $id_report, $user_info['id'], $user_info['name'], $user_info['email'],
Chris@76: $user_info['ip'], $poster_comment, time(),
Chris@76: ),
Chris@76: array('id_comment')
Chris@76: );
Chris@76: }
Chris@76: }
Chris@76:
Chris@76: // Find out who the real moderators are - for mod preferences.
Chris@76: $request2 = $smcFunc['db_query']('', '
Chris@76: SELECT id_member
Chris@76: FROM {db_prefix}moderators
Chris@76: WHERE id_board = {int:current_board}',
Chris@76: array(
Chris@76: 'current_board' => $board,
Chris@76: )
Chris@76: );
Chris@76: $real_mods = array();
Chris@76: while ($row = $smcFunc['db_fetch_assoc']($request2))
Chris@76: $real_mods[] = $row['id_member'];
Chris@76: $smcFunc['db_free_result']($request2);
Chris@76:
Chris@76: // Send every moderator an email.
Chris@76: while ($row = $smcFunc['db_fetch_assoc']($request))
Chris@76: {
Chris@76: // Maybe they don't want to know?!
Chris@76: if (!empty($row['mod_prefs']))
Chris@76: {
Chris@76: list(,, $pref_binary) = explode('|', $row['mod_prefs']);
Chris@76: if (!($pref_binary & 1) && (!($pref_binary & 2) || !in_array($row['id_member'], $real_mods)))
Chris@76: continue;
Chris@76: }
Chris@76:
Chris@76: $replacements = array(
Chris@76: 'TOPICSUBJECT' => $subject,
Chris@76: 'POSTERNAME' => $poster_name,
Chris@76: 'REPORTERNAME' => $reporterName,
Chris@76: 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg'],
Chris@76: 'REPORTLINK' => !empty($id_report) ? $scripturl . '?action=moderate;area=reports;report=' . $id_report : '',
Chris@76: 'COMMENT' => $_POST['comment'],
Chris@76: );
Chris@76:
Chris@76: $emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
Chris@76:
Chris@76: // Send it to the moderator.
Chris@76: sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], $user_info['email'], null, false, 2);
Chris@76: }
Chris@76: $smcFunc['db_free_result']($request);
Chris@76:
Chris@76: // Keep track of when the mod reports get updated, that way we know when we need to look again.
Chris@76: updateSettings(array('last_mod_report_action' => time()));
Chris@76:
Chris@76: // Back to the post we reported!
Chris@76: redirectexit('reportsent;topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
Chris@76: }
Chris@76:
Chris@76: ?>