PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/sources/controllers/Emailuser.controller.php

https://github.com/Arantor/Elkarte
PHP | 607 lines | 402 code | 91 blank | 114 comment | 100 complexity | 15dccd66ad12c91d40da63e9e0343227 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /**
  3. * @name ElkArte Forum
  4. * @copyright ElkArte Forum contributors
  5. * @license BSD http://opensource.org/licenses/BSD-3-Clause
  6. *
  7. * This software is a derived product, based on:
  8. *
  9. * Simple Machines Forum (SMF)
  10. * copyright: 2011 Simple Machines (http://www.simplemachines.org)
  11. * license: BSD, See included LICENSE.TXT for terms and conditions.
  12. *
  13. * @version 1.0 Alpha
  14. *
  15. * The functions in this file deal with sending topics to a friend or moderator,
  16. * and email to a user.
  17. *
  18. */
  19. if (!defined('ELKARTE'))
  20. die('No access...');
  21. /**
  22. * This function initializes or sets up the necessary, for the other actions
  23. */
  24. function pre_emailuser()
  25. {
  26. global $context;
  27. // Don't index anything here.
  28. $context['robot_no_index'] = true;
  29. // Load the template.
  30. loadTemplate('Emailuser');
  31. }
  32. /**
  33. * Default action handler (when no ;sa is specified)
  34. */
  35. function action_emailuser()
  36. {
  37. // default action: action_sendtopic()
  38. action_sendtopic();
  39. }
  40. /**
  41. * Send a topic to a friend.
  42. * Uses the Emailuser template, with the main sub template.
  43. * Requires the send_topic permission.
  44. * Redirects back to the first page of the topic when done.
  45. * Is accessed via ?action=emailuser;sa=sendtopic.
  46. */
  47. function action_sendtopic()
  48. {
  49. global $topic, $txt, $context, $scripturl, $smcFunc, $modSettings;
  50. // Check permissions...
  51. isAllowedTo('send_topic');
  52. // We need at least a topic... go away if you don't have one.
  53. if (empty($topic))
  54. fatal_lang_error('not_a_topic', false);
  55. // Get the topic's subject.
  56. $request = $smcFunc['db_query']('', '
  57. SELECT m.subject, t.approved
  58. FROM {db_prefix}topics AS t
  59. INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
  60. WHERE t.id_topic = {int:current_topic}
  61. LIMIT 1',
  62. array(
  63. 'current_topic' => $topic,
  64. )
  65. );
  66. if ($smcFunc['db_num_rows']($request) == 0)
  67. fatal_lang_error('not_a_topic', false);
  68. $row = $smcFunc['db_fetch_assoc']($request);
  69. $smcFunc['db_free_result']($request);
  70. // Can't send topic if its unapproved and using post moderation.
  71. if ($modSettings['postmod_active'] && !$row['approved'])
  72. fatal_lang_error('not_approved_topic', false);
  73. // Censor the subject....
  74. censorText($row['subject']);
  75. // Sending yet, or just getting prepped?
  76. if (empty($_POST['send']))
  77. {
  78. $context['page_title'] = sprintf($txt['sendtopic_title'], $row['subject']);
  79. $context['start'] = $_REQUEST['start'];
  80. return;
  81. }
  82. // Actually send the message...
  83. checkSession();
  84. spamProtection('sendtopic');
  85. // This is needed for sendmail().
  86. require_once(SUBSDIR . '/Mail.subs.php');
  87. // Trim the names..
  88. $_POST['y_name'] = trim($_POST['y_name']);
  89. $_POST['r_name'] = trim($_POST['r_name']);
  90. // Make sure they aren't playing "let's use a fake email".
  91. if ($_POST['y_name'] == '_' || !isset($_POST['y_name']) || $_POST['y_name'] == '')
  92. fatal_lang_error('no_name', false);
  93. if (!isset($_POST['y_email']) || $_POST['y_email'] == '')
  94. fatal_lang_error('no_email', false);
  95. if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['y_email']) == 0)
  96. fatal_lang_error('email_invalid_character', false);
  97. // The receiver should be valid to.
  98. if ($_POST['r_name'] == '_' || !isset($_POST['r_name']) || $_POST['r_name'] == '')
  99. fatal_lang_error('no_name', false);
  100. if (!isset($_POST['r_email']) || $_POST['r_email'] == '')
  101. fatal_lang_error('no_email', false);
  102. if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['r_email']) == 0)
  103. fatal_lang_error('email_invalid_character', false);
  104. // Emails don't like entities...
  105. $row['subject'] = un_htmlspecialchars($row['subject']);
  106. $replacements = array(
  107. 'TOPICSUBJECT' => $row['subject'],
  108. 'SENDERNAME' => $_POST['y_name'],
  109. 'RECPNAME' => $_POST['r_name'],
  110. 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.0',
  111. );
  112. $emailtemplate = 'send_topic';
  113. if (!empty($_POST['comment']))
  114. {
  115. $emailtemplate .= '_comment';
  116. $replacements['COMMENT'] = $_POST['comment'];
  117. }
  118. $emaildata = loadEmailTemplate($emailtemplate, $replacements);
  119. // And off we go!
  120. sendmail($_POST['r_email'], $emaildata['subject'], $emaildata['body'], $_POST['y_email']);
  121. // Back to the topic!
  122. redirectexit('topic=' . $topic . '.0');
  123. }
  124. /**
  125. * Allow a user to send an email.
  126. * Send an email to the user - allow the sender to write the message.
  127. * Can either be passed a user ID as uid or a message id as msg.
  128. * Does not check permissions for a message ID as there is no information disclosed.
  129. * ?action=emailuser;sa=email
  130. */
  131. function action_email()
  132. {
  133. global $context, $modSettings, $user_info, $smcFunc, $txt, $scripturl;
  134. // Can the user even see this information?
  135. if ($user_info['is_guest'] && !empty($modSettings['guest_hideContacts']))
  136. fatal_lang_error('no_access', false);
  137. isAllowedTo('send_email_to_members');
  138. // Are we sending to a user?
  139. $context['form_hidden_vars'] = array();
  140. if (isset($_REQUEST['uid']))
  141. {
  142. $request = $smcFunc['db_query']('', '
  143. SELECT email_address AS email, real_name AS name, id_member, hide_email
  144. FROM {db_prefix}members
  145. WHERE id_member = {int:id_member}',
  146. array(
  147. 'id_member' => (int) $_REQUEST['uid'],
  148. )
  149. );
  150. $context['form_hidden_vars']['uid'] = (int) $_REQUEST['uid'];
  151. }
  152. elseif (isset($_REQUEST['msg']))
  153. {
  154. $request = $smcFunc['db_query']('', '
  155. 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
  156. FROM {db_prefix}messages AS m
  157. LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
  158. WHERE m.id_msg = {int:id_msg}',
  159. array(
  160. 'id_msg' => (int) $_REQUEST['msg'],
  161. )
  162. );
  163. $context['form_hidden_vars']['msg'] = (int) $_REQUEST['msg'];
  164. }
  165. if (empty($request) || $smcFunc['db_num_rows']($request) == 0)
  166. fatal_lang_error('cant_find_user_email');
  167. $row = $smcFunc['db_fetch_assoc']($request);
  168. $smcFunc['db_free_result']($request);
  169. // Are you sure you got the address?
  170. if (empty($row['email']))
  171. fatal_lang_error('cant_find_user_email');
  172. // Can they actually do this?
  173. $context['show_email_address'] = showEmailAddress(!empty($row['hide_email']), $row['id_member']);
  174. if ($context['show_email_address'] === 'no')
  175. fatal_lang_error('no_access', false);
  176. // Setup the context!
  177. $context['recipient'] = array(
  178. 'id' => $row['id_member'],
  179. 'name' => $row['name'],
  180. 'email' => $row['email'],
  181. 'email_link' => ($context['show_email_address'] == 'yes_permission_override' ? '<em>' : '') . '<a href="mailto:' . $row['email'] . '">' . $row['email'] . '</a>' . ($context['show_email_address'] == 'yes_permission_override' ? '</em>' : ''),
  182. 'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['name'] . '</a>' : $row['name'],
  183. );
  184. // Can we see this person's email address?
  185. $context['can_view_receipient_email'] = $context['show_email_address'] == 'yes' || $context['show_email_address'] == 'yes_permission_override';
  186. // Are we actually sending it?
  187. if (isset($_POST['send']) && isset($_POST['email_body']))
  188. {
  189. require_once(SUBSDIR . '/Mail.subs.php');
  190. checkSession();
  191. // If it's a guest sort out their names.
  192. if ($user_info['is_guest'])
  193. {
  194. if (empty($_POST['y_name']) || $_POST['y_name'] == '_' || trim($_POST['y_name']) == '')
  195. fatal_lang_error('no_name', false);
  196. if (empty($_POST['y_email']))
  197. fatal_lang_error('no_email', false);
  198. if (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['y_email']) == 0)
  199. fatal_lang_error('email_invalid_character', false);
  200. $from_name = trim($_POST['y_name']);
  201. $from_email = trim($_POST['y_email']);
  202. }
  203. else
  204. {
  205. $from_name = $user_info['name'];
  206. $from_email = $user_info['email'];
  207. }
  208. // Check we have a body (etc).
  209. if (trim($_POST['email_body']) == '' || trim($_POST['email_subject']) == '')
  210. fatal_lang_error('email_missing_data');
  211. // We use a template in case they want to customise!
  212. $replacements = array(
  213. 'EMAILSUBJECT' => $_POST['email_subject'],
  214. 'EMAILBODY' => $_POST['email_body'],
  215. 'SENDERNAME' => $from_name,
  216. 'RECPNAME' => $context['recipient']['name'],
  217. );
  218. // Don't let them send too many!
  219. spamProtection('sendmail');
  220. // Get the template and get out!
  221. $emaildata = loadEmailTemplate('send_email', $replacements);
  222. sendmail($context['recipient']['email'], $emaildata['subject'], $emaildata['body'], $from_email, null, false, 1, null, true);
  223. // Now work out where to go!
  224. if (isset($_REQUEST['uid']))
  225. redirectexit('action=profile;u=' . (int) $_REQUEST['uid']);
  226. elseif (isset($_REQUEST['msg']))
  227. redirectexit('msg=' . (int) $_REQUEST['msg']);
  228. else
  229. redirectexit();
  230. }
  231. $context['sub_template'] = 'custom_email';
  232. $context['page_title'] = $txt['send_email'];
  233. }
  234. /**
  235. * Report a post to the moderator... ask for a comment.
  236. * Gathers data from the user to report abuse to the moderator(s).
  237. * Uses the ReportToModerator template, main sub template.
  238. * Requires the report_any permission.
  239. * Uses action_reporttm2() if post data was sent.
  240. * Accessed through ?action=reporttm.
  241. */
  242. function action_reporttm()
  243. {
  244. global $txt, $topic, $modSettings, $user_info, $context, $smcFunc;
  245. $context['robot_no_index'] = true;
  246. // You can't use this if it's off or you are not allowed to do it.
  247. isAllowedTo('report_any');
  248. // No errors, yet.
  249. $report_errors = error_context::context('report', 1);
  250. // ...or maybe some.
  251. $context['report_error'] = array(
  252. 'errors' => $report_errors->prepareErrors(),
  253. 'type' => $report_errors->getErrorType() == 0 ? 'minor' : 'serious',
  254. );
  255. // If they're posting, it should be processed by action_reporttm2.
  256. if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && !$report_errors->hasErrors())
  257. action_reporttm2();
  258. // We need a message ID to check!
  259. if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']))
  260. fatal_lang_error('no_access', false);
  261. // For compatibility, accept mid, but we should be using msg. (not the flavor kind!)
  262. $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg'];
  263. // Check the message's ID - don't want anyone reporting a post they can't even see!
  264. $result = $smcFunc['db_query']('', '
  265. SELECT m.id_msg, m.id_member, t.id_member_started
  266. FROM {db_prefix}messages AS m
  267. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic})
  268. WHERE m.id_msg = {int:id_msg}
  269. AND m.id_topic = {int:current_topic}
  270. LIMIT 1',
  271. array(
  272. 'current_topic' => $topic,
  273. 'id_msg' => $_REQUEST['msg'],
  274. )
  275. );
  276. if ($smcFunc['db_num_rows']($result) == 0)
  277. fatal_lang_error('no_board', false);
  278. list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result);
  279. $smcFunc['db_free_result']($result);
  280. // Do we need to show the visual verification image?
  281. $context['require_verification'] = $user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha']);
  282. if ($context['require_verification'])
  283. {
  284. require_once(SUBSDIR . '/Editor.subs.php');
  285. $verificationOptions = array(
  286. 'id' => 'report',
  287. );
  288. $context['require_verification'] = create_control_verification($verificationOptions);
  289. $context['visual_verification_id'] = $verificationOptions['id'];
  290. }
  291. // Show the inputs for the comment, etc.
  292. loadLanguage('Post');
  293. loadLanguage('Errors');
  294. loadTemplate('Emailuser');
  295. addInlineJavascript('
  296. error_txts[\'post_too_long\'] = ' . JavaScriptEscape($txt['error_post_too_long']) . ';
  297. var report_errors = new errorbox_handler({
  298. self: \'report_errors\',
  299. error_box_id: \'report_error\',
  300. error_checks: [{
  301. code: \'post_too_long\',
  302. function: function(box_value) {
  303. if (box_value.length > 254)
  304. return true;
  305. else
  306. return false;
  307. }
  308. }],
  309. check_id: "report_comment"
  310. });', true);
  311. $context['comment_body'] = !isset($_POST['comment']) ? '' : trim($_POST['comment']);
  312. $context['email_address'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
  313. // This is here so that the user could, in theory, be redirected back to the topic.
  314. $context['start'] = $_REQUEST['start'];
  315. $context['message_id'] = $_REQUEST['msg'];
  316. $context['page_title'] = $txt['report_to_mod'];
  317. $context['sub_template'] = 'report';
  318. }
  319. /**
  320. * Send the emails.
  321. * Sends off emails to all the moderators.
  322. * Sends to administrators and global moderators. (1 and 2)
  323. * Called by action_reporttm(), and thus has the same permission and setting requirements as it does.
  324. * Accessed through ?action=reporttm when posting.
  325. */
  326. function action_reporttm2()
  327. {
  328. global $txt, $scripturl, $topic, $board, $user_info, $modSettings, $language, $context, $smcFunc;
  329. // You must have the proper permissions!
  330. isAllowedTo('report_any');
  331. // Make sure they aren't spamming.
  332. spamProtection('reporttm');
  333. require_once(SUBSDIR . '/Mail.subs.php');
  334. // No errors, yet.
  335. $report_errors = error_context::context('report', 1);
  336. // Check their session.
  337. if (checkSession('post', '', false) != '')
  338. $report_errors->addError('session_timeout');
  339. // Make sure we have a comment and it's clean.
  340. if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '')
  341. $report_errors->addError('no_comment');
  342. $poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => ''));
  343. if ($smcFunc['strlen']($poster_comment) > 254)
  344. $report_errors->addError('post_too_long');
  345. // Guests need to provide their address!
  346. if ($user_info['is_guest'])
  347. {
  348. $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
  349. if ($_POST['email'] === '')
  350. $report_errors->addError('no_email');
  351. elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0)
  352. $report_errors->addError('bad_email');
  353. isBannedEmail($_POST['email'], 'cannot_post', sprintf($txt['you_are_post_banned'], $txt['guest_title']));
  354. $user_info['email'] = htmlspecialchars($_POST['email']);
  355. }
  356. // Could they get the right verification code?
  357. if ($user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha']))
  358. {
  359. require_once(SUBSDIR . '/Editor.subs.php');
  360. $verificationOptions = array(
  361. 'id' => 'report',
  362. );
  363. $context['require_verification'] = create_control_verification($verificationOptions, true);
  364. }
  365. // Any errors?
  366. if ($report_errors->hasErrors())
  367. return action_reporttm();
  368. // Get the basic topic information, and make sure they can see it.
  369. $_POST['msg'] = (int) $_POST['msg'];
  370. $request = $smcFunc['db_query']('', '
  371. SELECT m.id_topic, m.id_board, m.subject, m.body, m.id_member AS id_poster, m.poster_name, mem.real_name
  372. FROM {db_prefix}messages AS m
  373. LEFT JOIN {db_prefix}members AS mem ON (m.id_member = mem.id_member)
  374. WHERE m.id_msg = {int:id_msg}
  375. AND m.id_topic = {int:current_topic}
  376. LIMIT 1',
  377. array(
  378. 'current_topic' => $topic,
  379. 'id_msg' => $_POST['msg'],
  380. )
  381. );
  382. if ($smcFunc['db_num_rows']($request) == 0)
  383. fatal_lang_error('no_board', false);
  384. $message = $smcFunc['db_fetch_assoc']($request);
  385. $smcFunc['db_free_result']($request);
  386. $poster_name = un_htmlspecialchars($message['real_name']) . ($message['real_name'] != $message['poster_name'] ? ' (' . $message['poster_name'] . ')' : '');
  387. $reporterName = un_htmlspecialchars($user_info['name']) . ($user_info['name'] != $user_info['username'] && $user_info['username'] != '' ? ' (' . $user_info['username'] . ')' : '');
  388. $subject = un_htmlspecialchars($message['subject']);
  389. // Get a list of members with the moderate_board permission.
  390. require_once(SUBSDIR . '/Members.subs.php');
  391. $moderators = membersAllowedTo('moderate_board', $board);
  392. $request = $smcFunc['db_query']('', '
  393. SELECT id_member, email_address, lngfile, mod_prefs
  394. FROM {db_prefix}members
  395. WHERE id_member IN ({array_int:moderator_list})
  396. AND notify_types != {int:notify_types}
  397. ORDER BY lngfile',
  398. array(
  399. 'moderator_list' => $moderators,
  400. 'notify_types' => 4,
  401. )
  402. );
  403. // Check that moderators do exist!
  404. if ($smcFunc['db_num_rows']($request) == 0)
  405. fatal_lang_error('no_mods', false);
  406. // If we get here, I believe we should make a record of this, for historical significance, yabber.
  407. if (empty($modSettings['disable_log_report']))
  408. {
  409. $request2 = $smcFunc['db_query']('', '
  410. SELECT id_report, ignore_all
  411. FROM {db_prefix}log_reported
  412. WHERE id_msg = {int:id_msg}
  413. AND (closed = {int:not_closed} OR ignore_all = {int:ignored})
  414. ORDER BY ignore_all DESC',
  415. array(
  416. 'id_msg' => $_POST['msg'],
  417. 'not_closed' => 0,
  418. 'ignored' => 1,
  419. )
  420. );
  421. if ($smcFunc['db_num_rows']($request2) != 0)
  422. list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request2);
  423. $smcFunc['db_free_result']($request2);
  424. // If we're just going to ignore these, then who gives a monkeys...
  425. if (!empty($ignore))
  426. redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
  427. // Already reported? My god, we could be dealing with a real rogue here...
  428. if (!empty($id_report))
  429. $smcFunc['db_query']('', '
  430. UPDATE {db_prefix}log_reported
  431. SET num_reports = num_reports + 1, time_updated = {int:current_time}
  432. WHERE id_report = {int:id_report}',
  433. array(
  434. 'current_time' => time(),
  435. 'id_report' => $id_report,
  436. )
  437. );
  438. // Otherwise, we shall make one!
  439. else
  440. {
  441. if (empty($message['real_name']))
  442. $message['real_name'] = $message['poster_name'];
  443. $smcFunc['db_insert']('',
  444. '{db_prefix}log_reported',
  445. array(
  446. 'id_msg' => 'int', 'id_topic' => 'int', 'id_board' => 'int', 'id_member' => 'int', 'membername' => 'string',
  447. 'subject' => 'string', 'body' => 'string', 'time_started' => 'int', 'time_updated' => 'int',
  448. 'num_reports' => 'int', 'closed' => 'int',
  449. ),
  450. array(
  451. $_POST['msg'], $message['id_topic'], $message['id_board'], $message['id_poster'], $message['real_name'],
  452. $message['subject'], $message['body'] , time(), time(), 1, 0,
  453. ),
  454. array('id_report')
  455. );
  456. $id_report = $smcFunc['db_insert_id']('{db_prefix}log_reported', 'id_report');
  457. }
  458. // Now just add our report...
  459. if ($id_report)
  460. {
  461. $smcFunc['db_insert']('',
  462. '{db_prefix}log_reported_comments',
  463. array(
  464. 'id_report' => 'int', 'id_member' => 'int', 'membername' => 'string', 'email_address' => 'string',
  465. 'member_ip' => 'string', 'comment' => 'string', 'time_sent' => 'int',
  466. ),
  467. array(
  468. $id_report, $user_info['id'], $user_info['name'], $user_info['email'],
  469. $user_info['ip'], $poster_comment, time(),
  470. ),
  471. array('id_comment')
  472. );
  473. }
  474. }
  475. // Find out who the real moderators are - for mod preferences.
  476. $request2 = $smcFunc['db_query']('', '
  477. SELECT id_member
  478. FROM {db_prefix}moderators
  479. WHERE id_board = {int:current_board}',
  480. array(
  481. 'current_board' => $board,
  482. )
  483. );
  484. $real_mods = array();
  485. while ($row = $smcFunc['db_fetch_assoc']($request2))
  486. $real_mods[] = $row['id_member'];
  487. $smcFunc['db_free_result']($request2);
  488. // Send every moderator an email.
  489. while ($row = $smcFunc['db_fetch_assoc']($request))
  490. {
  491. // Maybe they don't want to know?!
  492. if (!empty($row['mod_prefs']))
  493. {
  494. list(,, $pref_binary) = explode('|', $row['mod_prefs']);
  495. if (!($pref_binary & 1) && (!($pref_binary & 2) || !in_array($row['id_member'], $real_mods)))
  496. continue;
  497. }
  498. $replacements = array(
  499. 'TOPICSUBJECT' => $subject,
  500. 'POSTERNAME' => $poster_name,
  501. 'REPORTERNAME' => $reporterName,
  502. 'TOPICLINK' => $scripturl . '?topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg'],
  503. 'REPORTLINK' => !empty($id_report) ? $scripturl . '?action=moderate;area=reports;report=' . $id_report : '',
  504. 'COMMENT' => $_POST['comment'],
  505. );
  506. $emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
  507. // Send it to the moderator.
  508. sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], $user_info['email'], null, false, 2);
  509. }
  510. $smcFunc['db_free_result']($request);
  511. // Keep track of when the mod reports get updated, that way we know when we need to look again.
  512. updateSettings(array('last_mod_report_action' => time()));
  513. // Back to the post we reported!
  514. redirectexit('reportsent;topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
  515. }