SendTopic.php 19 KB

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