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

/forum/report.php

https://code.google.com/p/torrentpier/
PHP | 819 lines | 714 code | 42 blank | 63 comment | 46 complexity | babb7f8f551a9de5e07b1319232f9bf7 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. This file is part of TorrentPier
  4. TorrentPier is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. TorrentPier is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. A copy of the GPL 2.0 should have been included with the program.
  13. If not, see http://www.gnu.org/licenses/
  14. Official SVN repository and contact information can be found at
  15. http://code.google.com/p/torrentpier/
  16. */
  17. define('IN_PHPBB', true);
  18. define('BB_SCRIPT', 'report');
  19. define('BB_ROOT', './');
  20. require(BB_ROOT ."common.php");
  21. require(INC_DIR ."functions_report.php");
  22. // Init userdata
  23. $user->session_start();
  24. if (!$userdata['session_logged_in'])
  25. {
  26. redirect(append_sid("index.php", true));
  27. }
  28. $return_links = array(
  29. 'index' => '<br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'], '<a href="' . append_sid("index.php") . '">', '</a>'),
  30. 'list' => '<br /><br />' . sprintf($lang['CLICK_RETURN_REPORT_LIST'], '<a href="' . append_sid("report.php") . '">', '</a>')
  31. );
  32. if (isset($_POST['mode']) || isset($_GET['mode']))
  33. {
  34. $mode = (isset($_POST['mode'])) ? $_POST['mode'] : $_GET['mode'];
  35. }
  36. else
  37. {
  38. $mode = '';
  39. }
  40. $report_modules = report_modules();
  41. //
  42. // Check for matching report module
  43. //
  44. if (!empty($mode))
  45. {
  46. foreach (array_keys($report_modules) as $report_module_id)
  47. {
  48. $report_module =& $report_modules[$report_module_id];
  49. if (!empty($report_module->mode) && $mode == $report_module->mode)
  50. {
  51. break;
  52. }
  53. unset($report_module);
  54. }
  55. }
  56. //
  57. // Report module matched, show report form
  58. //
  59. if (isset($report_module))
  60. {
  61. $errors = array();
  62. if (isset($_POST['id']) || isset($_GET['id']))
  63. {
  64. $report_subject_id = (isset($_POST['id'])) ? (int) $_POST['id'] : (int) $_GET['id'];
  65. }
  66. else
  67. {
  68. $report_subject_id = 0;
  69. }
  70. //
  71. // Check authorisation, check for duplicate reports
  72. //
  73. if (!$report_module->auth_check('auth_write'))
  74. {
  75. message_die(GENERAL_MESSAGE, $report_module->lang['AUTH_WRITE_ERROR'] . $report_module->return_link($report_subject_id) . $return_links['index']);
  76. }
  77. else if (!$report_module->duplicates && report_duplicate_check($report_module->id, $report_subject_id))
  78. {
  79. message_die(GENERAL_MESSAGE, $report_module->lang['DUPLICATE_ERROR'] . $report_module->return_link($report_subject_id) . $return_links['index']);
  80. }
  81. if (isset($_POST['submit']))
  82. {
  83. $report_reason = (isset($_POST['reason'])) ? (int) $_POST['reason'] : 0;
  84. $report_desc = (isset($_POST['message'])) ? htmlspecialchars($_POST['message']) : '';
  85. //
  86. // Obtain report title if necessary
  87. //
  88. if (method_exists($report_module, 'subject_obtain'))
  89. {
  90. $report_title = addslashes($report_module->subject_obtain($report_subject_id));
  91. }
  92. else
  93. {
  94. $report_title = (isset($_POST['title'])) ? htmlspecialchars($_POST['title']) : '';
  95. $report_subject_id = 0;
  96. }
  97. //
  98. // Validate values
  99. //
  100. if (empty($report_title))
  101. {
  102. $errors[] = $lang['REPORT_TITLE_EMPTY'];
  103. }
  104. if (empty($report_desc))
  105. {
  106. $errors[] = $lang['REPORT_DESC_EMPTY'];
  107. }
  108. //
  109. // Insert report
  110. //
  111. if (empty($errors))
  112. {
  113. $report_desc = str_replace("\'", "'", $report_desc);
  114. $report_title = str_replace("\'", "'", $report_title);
  115. report_insert($report_module->id, $report_subject_id, $report_reason, $report_title, $report_desc, false);
  116. message_die(GENERAL_MESSAGE, $lang['REPORT_INSERTED'] . $report_module->return_link($report_subject_id) . $return_links['index']);
  117. }
  118. }
  119. else if (isset($_POST['cancel']))
  120. {
  121. $redirect_url = (method_exists($report_module, 'subject_url')) ? $report_module->subject_url($report_subject_id, true) : append_sid("index.php", true);
  122. redirect($redirect_url);
  123. }
  124. $page_title = $report_module->lang['WRITE_REPORT'];
  125. include(PAGE_HEADER);
  126. $template->set_filenames(array(
  127. 'body' => 'report_form_body.tpl')
  128. );
  129. //
  130. // Show validation errors
  131. //
  132. if (!empty($errors))
  133. {
  134. $template->assign_block_vars('switch_report_errors', array());
  135. foreach ($errors as $error)
  136. {
  137. $template->assign_block_vars('switch_report_errors.report_errors', array(
  138. 'MESSAGE' => $error)
  139. );
  140. }
  141. }
  142. //
  143. // Generate report reasons select
  144. //
  145. if ($report_reasons = $report_module->reasons_obtain())
  146. {
  147. $template->assign_block_vars('switch_report_reasons', array());
  148. foreach ($report_reasons as $reason_id => $reason_desc)
  149. {
  150. $template->assign_block_vars('switch_report_reasons.report_reasons', array(
  151. 'ID' => $reason_id,
  152. 'DESC' => $reason_desc,
  153. 'CHECKED' => (isset($report_reason) && $report_reason == $reason_id) ? ' selected="selected"' : '')
  154. );
  155. }
  156. }
  157. //
  158. // Show report subject, check for correct subject
  159. //
  160. if (method_exists($report_module, 'subject_obtain'))
  161. {
  162. if ($report_subject = $report_module->subject_obtain($report_subject_id))
  163. {
  164. $template->assign_block_vars('switch_report_subject', array());
  165. $template->assign_var('REPORT_SUBJECT', $report_subject);
  166. if (method_exists($report_module, 'subject_url'))
  167. {
  168. $template->assign_block_vars('switch_report_subject.switch_url', array());
  169. $template->assign_var('U_REPORT_SUBJECT', $report_module->subject_url($report_subject_id));
  170. }
  171. }
  172. else
  173. {
  174. message_die(GENERAL_MESSAGE, $report_module->lang['WRITE_REPORT_ERROR'] . $return_links['index']);
  175. }
  176. }
  177. //
  178. // Show report title input
  179. //
  180. else
  181. {
  182. $template->assign_block_vars('switch_report_title', array());
  183. }
  184. $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="id" value="' . $report_subject_id . '" />';
  185. $template->assign_vars(array(
  186. 'S_REPORT_ACTION' => append_sid("report.php"),
  187. 'S_HIDDEN_FIELDS' => $hidden_fields,
  188. 'L_WRITE_REPORT' => $report_module->lang['WRITE_REPORT'],
  189. 'L_WRITE_REPORT_EXPLAIN' => $report_module->lang['WRITE_REPORT_EXPLAIN'],
  190. 'REPORT_TITLE' => (!method_exists($report_module, 'subject_obtain') && isset($report_title)) ? stripslashes($report_title) : '',
  191. 'REPORT_DESC' => (isset($report_desc)) ? stripslashes($report_desc) : '',
  192. 'L_TITLE' => $lang['POST_SUBJECT'],
  193. 'L_SUBJECT' => $lang['REPORT_SUBJECT'])
  194. );
  195. $template->pparse('body');
  196. include(PAGE_FOOTER);
  197. }
  198. else
  199. {
  200. if ($userdata['user_level'] != ADMIN && ($bb_cfg['report_list_admin'] || $userdata['user_level'] != MOD))
  201. {
  202. redirect(append_sid("index.php", true));
  203. }
  204. $params = array('open', 'process', 'clear', 'delete');
  205. foreach ($params as $param)
  206. {
  207. if (isset($_POST[$param]))
  208. {
  209. $mode = $param;
  210. }
  211. }
  212. // Report status css classes
  213. $report_status_classes = array(
  214. REPORT_NEW => 'report_new',
  215. REPORT_OPEN => 'report_open',
  216. REPORT_IN_PROCESS => 'report_process',
  217. REPORT_CLEARED => 'report_cleared',
  218. REPORT_DELETE => 'report_delete'
  219. );
  220. switch ($mode)
  221. {
  222. case 'open':
  223. case 'process':
  224. case 'clear':
  225. case 'delete':
  226. //
  227. // Validate report ids
  228. //
  229. if (isset($_POST[POST_REPORT_URL]) || isset($_GET[POST_REPORT_URL]))
  230. {
  231. $report_id = (isset($_POST[POST_REPORT_URL])) ? $_POST[POST_REPORT_URL] : $_GET[POST_REPORT_URL];
  232. $reports = array((int) $report_id);
  233. $single_report = true;
  234. }
  235. else if (isset($_POST['reports']))
  236. {
  237. $reports = array();
  238. foreach ($_POST['reports'] as $report_id)
  239. {
  240. $reports[] = (int) $report_id;
  241. }
  242. $single_report = false;
  243. }
  244. if (empty($reports))
  245. {
  246. $template->assign_var('META', '<meta http-equiv="refresh" content="3;url=' . append_sid("report.php") . '">');
  247. message_die(GENERAL_MESSAGE, $lang['NO_REPORTS_SELECTED'] . $return_links['list'] . $return_links['index']);
  248. }
  249. //
  250. // Cancel action
  251. //
  252. if (isset($_POST['cancel']))
  253. {
  254. $redirect_url = ($single_report) ? "report.php?" . POST_REPORT_URL . '=' . $reports[0] : "report.php";
  255. redirect(append_sid($redirect_url, true));
  256. }
  257. //
  258. // Hidden fields
  259. //
  260. $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" />';
  261. if ($single_report)
  262. {
  263. $hidden_fields .= '<input type="hidden" name="' . POST_REPORT_URL . '" value="' . $reports[0] . '" />';
  264. }
  265. else
  266. {
  267. foreach ($reports as $report_id)
  268. {
  269. $hidden_fields .= '<input type="hidden" name="reports[]" value="' . $report_id . '" />';
  270. }
  271. }
  272. $template->assign_vars(array(
  273. 'S_CONFIRM_ACTION' => append_sid("report.php"),
  274. 'S_HIDDEN_FIELDS' => $hidden_fields)
  275. );
  276. //
  277. // Change reports status
  278. //
  279. if ($mode != 'delete')
  280. {
  281. if (isset($_POST['confirm']))
  282. {
  283. $comment = (isset($_POST['comment'])) ? htmlspecialchars(str_replace("\'", "'", $_POST['comment'])) : '';
  284. switch ($mode)
  285. {
  286. case 'open':
  287. $status = REPORT_OPEN;
  288. break;
  289. case 'process':
  290. $status = REPORT_IN_PROCESS;
  291. break;
  292. case 'clear':
  293. $status = REPORT_CLEARED;
  294. break;
  295. }
  296. reports_update_status($reports, $status, $comment);
  297. $meta_url = ($single_report) ? "report.php?" . POST_REPORT_URL . '=' . $reports[0] : "report.php";
  298. $template->assign_var('META', '<meta http-equiv="refresh" content="3;url=' . append_sid($meta_url) . '">');
  299. $return_link = ($single_report) ? '<br /><br />' . sprintf($lang['CLICK_RETURN_REPORT'], '<a href="' . append_sid("report.php?" . POST_REPORT_URL . '=' . $reports[0]) . '">', '</a>') : '';
  300. $message = ($single_report) ? 'REPORT_CHANGED' : 'REPORTS_CHANGED';
  301. message_die(GENERAL_MESSAGE, $lang[$message] . $return_link . $return_links['list'] . $return_links['index']);
  302. }
  303. $page_title = ($single_report) ? $lang['CHANGE_REPORT'] : $lang['CHANGE_REPORTS'];
  304. include(PAGE_HEADER);
  305. $template->set_filenames(array(
  306. 'body' => 'report_change_body.tpl')
  307. );
  308. $template->assign_vars(array(
  309. 'MESSAGE_TITLE' => $page_title,
  310. 'MESSAGE_TEXT' => ($single_report) ? $lang['CHANGE_REPORT_EXPLAIN'] : $lang['CHANGE_REPORTS_EXPLAIN'])
  311. );
  312. $template->pparse('body');
  313. include(PAGE_FOOTER);
  314. }
  315. //
  316. // Delete reports
  317. //
  318. else
  319. {
  320. if (isset($_POST['confirm']))
  321. {
  322. reports_delete($reports);
  323. $template->assign_var('META', '<meta http-equiv="refresh" content="3;url=' . append_sid("report.php") . '">');
  324. $message = ($single_report) ? 'REPORT_DELETED' : 'REPORTS_DELETED';
  325. message_die(GENERAL_MESSAGE, $lang[$message] . $return_links['list'] . $return_links['index']);
  326. }
  327. $page_title = ($single_report) ? $lang['DELETE_REPORT'] : $lang['DELETE_REPORTS'];
  328. include(PAGE_HEADER);
  329. $template->set_filenames(array(
  330. 'confirm' => 'confirm_body.tpl')
  331. );
  332. $template->assign_vars(array(
  333. 'MESSAGE_TITLE' => $page_title,
  334. 'MESSAGE_TEXT' => ($single_report) ? $lang['DELETE_REPORT_EXPLAIN'] : $lang['DELETE_REPORTS_EXPLAIN'])
  335. );
  336. $template->pparse('confirm');
  337. include(PAGE_FOOTER);
  338. }
  339. break;
  340. case 'reported':
  341. $cat = (isset($_GET[POST_CAT_URL])) ? (int) $_GET[POST_CAT_URL] : 0;
  342. $report_subject_id = (isset($_GET['id'])) ? (int) $_GET['id'] : 0;
  343. if (empty($cat) || empty($report_subject_id) || !isset($report_modules[$cat]))
  344. {
  345. message_die(GENERAL_MESSAGE, $lang['REPORT_NOT_SUPPORTED'] . $return_links['index']);
  346. }
  347. $report_module =& $report_modules[$cat];
  348. $reports = reports_open_obtain($cat, $report_subject_id);
  349. //
  350. // No open reports for the subject, sync report module
  351. //
  352. if (empty($reports))
  353. {
  354. if (method_exists($report_module, 'sync'))
  355. {
  356. $report_module->sync();
  357. }
  358. message_die(GENERAL_MESSAGE, $lang['NO_REPORTS_FOUND'] . $report_module->return_link($report_subject_id) . $return_links['index']);
  359. }
  360. //
  361. // Redirect to the open report
  362. //
  363. else if (count($reports) == 1)
  364. {
  365. $redirect_url = append_sid("report.php?" . POST_REPORT_URL . '=' . $reports[0]['report_id'], true);
  366. redirect($redirect_url);
  367. }
  368. $page_title = $lang['OPEN_REPORTS'];
  369. include(PAGE_HEADER);
  370. $template->set_filenames(array(
  371. 'body' => 'report_open_body.tpl')
  372. );
  373. $template->assign_vars(array(
  374. 'S_REPORT_ACTION', append_sid("report.php"),
  375. 'L_BY' => $lang['REPORT_BY'],
  376. 'L_MARK' => $lang['REPORT_MARK'],
  377. 'L_STATUS_CLEARED' => $lang['REPORT_STATUS'][REPORT_CLEARED],
  378. 'L_STATUS_IN_PROCESS' => $lang['REPORT_STATUS'][REPORT_IN_PROCESS],
  379. 'L_STATUS_OPEN' => $lang['REPORT_STATUS'][REPORT_OPEN],
  380. 'L_SELECT_ALL' => $lang['MARK_ALL'])
  381. );
  382. //
  383. // Show list with open reports
  384. //
  385. foreach ($reports as $report)
  386. {
  387. $template->assign_block_vars('open_reports', array(
  388. 'U_SHOW' => append_sid("report.php?" . POST_REPORT_URL . '=' . $report['report_id']),
  389. 'U_AUTHOR' => append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $report['user_id']),
  390. 'ID' => $report['report_id'],
  391. 'TITLE' => $report['report_title'],
  392. 'AUTHOR' => $report['username'],
  393. 'TIME' => create_date($bb_cfg['default_dateformat'], $report['report_time'], $bb_cfg['board_timezone']))
  394. );
  395. }
  396. $template->pparse('body');
  397. include(PAGE_FOOTER);
  398. break;
  399. case '':
  400. $page_title = $lang['REPORTS'];
  401. include(PAGE_HEADER);
  402. $template->set_filenames(array(
  403. 'body' => 'report_list_body.tpl')
  404. );
  405. $template->assign_vars(array(
  406. 'S_REPORT_ACTION' => append_sid("report.php"),
  407. 'U_REPORT_INDEX' => append_sid("report.php"),
  408. 'L_BY' => $lang['REPORT_BY'],
  409. 'L_MARK' => $lang['REPORT_MARK'],
  410. 'L_STATUS_CLEARED' => $lang['REPORT_STATUS'][REPORT_CLEARED],
  411. 'L_STATUS_IN_PROCESS' => $lang['REPORT_STATUS'][REPORT_IN_PROCESS],
  412. 'L_STATUS_OPEN' => $lang['REPORT_STATUS'][REPORT_OPEN],
  413. 'L_SELECT_ALL' => $lang['MARK_ALL'])
  414. );
  415. $cat = (isset($_GET[POST_CAT_URL])) ? (int) $_GET[POST_CAT_URL] : null;
  416. $cat_url = (!empty($cat)) ? '&amp;' . POST_CAT_URL . "=$cat" : '';
  417. $show_delete_option = false;
  418. //
  419. // Show report list
  420. //
  421. $reports = reports_obtain($cat);
  422. foreach (array_keys($report_modules) as $report_module_id)
  423. {
  424. $report_module =& $report_modules[$report_module_id];
  425. //
  426. // Check module authorisation
  427. //
  428. if (!$report_module->auth_check('auth_view'))
  429. {
  430. continue;
  431. }
  432. $template->assign_block_vars('report_modules', array(
  433. 'U_SHOW' => append_sid("report.php?" . POST_CAT_URL . '=' . $report_module->id),
  434. 'TITLE' => $report_module->lang['REPORT_LIST_TITLE'])
  435. );
  436. //
  437. // No reports in this category, display no reports message
  438. //
  439. if (!isset($reports[$report_module->id]))
  440. {
  441. if (empty($cat) || $cat == $report_module->id)
  442. {
  443. $template->assign_block_vars('report_modules.no_reports', array());
  444. }
  445. continue;
  446. }
  447. //
  448. // Check if deletions are allowed
  449. //
  450. if ($report_module->auth_check('auth_delete_view'))
  451. {
  452. $show_delete_option = true;
  453. }
  454. //
  455. // Show reports
  456. //
  457. foreach ($reports[$report_module->id] as $report)
  458. {
  459. $template->assign_block_vars('report_modules.reports', array(
  460. 'U_SHOW' => append_sid("report.php?" . POST_REPORT_URL . '=' . $report['report_id'] . $cat_url),
  461. 'U_AUTHOR' => append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $report['user_id']),
  462. 'ROW_CLASS' => $report_status_classes[$report['report_status']],
  463. 'ID' => $report['report_id'],
  464. 'TITLE' => (strlen($report['report_title'] > 53)) ? substr($report['report_title'], 0, 50) . '...' : $report['report_title'],
  465. 'AUTHOR' => $report['username'],
  466. 'TIME' => create_date($bb_cfg['default_dateformat'], $report['report_time'], $bb_cfg['board_timezone']),
  467. 'STATUS' => $lang['REPORT_STATUS'][$report['report_status']])
  468. );
  469. if (isset($_GET[POST_REPORT_URL]) && $_GET[POST_REPORT_URL] == $report['report_id'])
  470. {
  471. $template->assign_block_vars('report_modules.reports.switch_current', array());
  472. }
  473. }
  474. }
  475. if ($show_delete_option)
  476. {
  477. $template->assign_block_vars('switch_global_delete_option', array());
  478. }
  479. //
  480. // Show information for one report
  481. //
  482. if (isset($_GET[POST_REPORT_URL]))
  483. {
  484. $template->set_filenames(array(
  485. 'report_view' => 'report_view_body.tpl')
  486. );
  487. if (!$report = report_obtain((int) $_GET[POST_REPORT_URL]))
  488. {
  489. message_die(GENERAL_MESSAGE, $lang['REPORT_NOT_EXISTS'] . $return_links['list'] . $return_links['index']);
  490. }
  491. if ($report['report_status'] == REPORT_NEW)
  492. {
  493. reports_update_status($report['report_id'], REPORT_OPEN, '', false, true, false);
  494. $report['report_status'] = REPORT_OPEN;
  495. }
  496. //
  497. // Show report subject (with or without details, depending on the report module)
  498. //
  499. $report_module =& $report_modules[$report['report_module_id']];
  500. if (method_exists($report_module, 'subject_details_obtain'))
  501. {
  502. if ($report_subject = $report_module->subject_details_obtain($report['report_subject']))
  503. {
  504. if (isset($report_subject['subject']) || isset($report_subject['details']))
  505. {
  506. $template->assign_block_vars('report_subject', array());
  507. }
  508. //
  509. // Assign report subject
  510. //
  511. if (isset($report_subject['subject']))
  512. {
  513. $template->assign_block_vars('report_subject.switch_subject', array());
  514. $template->assign_var('REPORT_SUBJECT', $report_subject['subject']);
  515. if (method_exists($report_module, 'subject_url'))
  516. {
  517. $template->assign_block_vars('report_subject.switch_subject.switch_url', array());
  518. $template->assign_vars(array(
  519. 'S_REPORT_SUBJECT_TARGET' => ($bb_cfg['report_new_window']) ? ' target="_blank"' : '',
  520. 'U_REPORT_SUBJECT' => $report_module->subject_url($report['report_subject']))
  521. );
  522. }
  523. }
  524. //
  525. // Assign report subject details
  526. //
  527. if (isset($report_subject['details']))
  528. {
  529. foreach ($report_subject['details'] as $detail_title => $detail_value)
  530. {
  531. $template->assign_block_vars('report_subject.details', array(
  532. 'TITLE' => $report_module->lang[$detail_title],
  533. 'VALUE' => $detail_value)
  534. );
  535. }
  536. }
  537. }
  538. else
  539. {
  540. $template->assign_block_vars('switch_report_subject_deleted', array());
  541. $template->assign_var('L_REPORT_SUBJECT_DELETED', $report_module->lang['DELETED_ERROR']);
  542. }
  543. }
  544. else if (method_exists($report_module, 'subject_obtain'))
  545. {
  546. if ($report_subject = $report_module->subject_obtain($report['report_subject']))
  547. {
  548. //
  549. // Assign report subject
  550. //
  551. $template->assign_block_vars('report_subject', array());
  552. $template->assign_block_vars('report_subject.switch_subject', array());
  553. $template->assign_var('REPORT_SUBJECT', $report_subject);
  554. if (method_exists($report_module, 'subject_url'))
  555. {
  556. $template->assign_block_vars('report_subject.switch_subject.switch_url', array());
  557. $template->assign_vars(array(
  558. 'S_REPORT_SUBJECT_TARGET' => ($bb_cfg['report_new_window']) ? ' target="_blank"' : '',
  559. 'U_REPORT_SUBJECT' => $report_module->subject_url($report['report_subject']))
  560. );
  561. }
  562. }
  563. else
  564. {
  565. $template->assign_block_vars('switch_report_subject_deleted', array());
  566. $template->assign_var('L_REPORT_SUBJECT_DELETED', $report_module->lang['DELETED_ERROR']);
  567. }
  568. }
  569. //
  570. // Assign report reason
  571. //
  572. if (!empty($report['report_reason_desc']))
  573. {
  574. $template->assign_block_vars('switch_report_reason', array());
  575. $template->assign_var('REPORT_REASON', $report['report_reason_desc']);
  576. }
  577. //
  578. // Show report changes
  579. //
  580. if ($report_changes = report_changes_obtain($report['report_id']))
  581. {
  582. $template->assign_block_vars('switch_report_changes', array());
  583. foreach ($report_changes as $report_change)
  584. {
  585. $u_report_change_user = append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $report_change['user_id']);
  586. $report_change_user = '<a href="' . $u_report_change_user . '">' . $report_change['username'] . '</a>';
  587. $report_change_status = $lang['REPORT_STATUS'][$report_change['report_status']];
  588. $report_change_time = create_date($bb_cfg['default_dateformat'], $report_change['report_change_time'], $bb_cfg['board_timezone']);
  589. //
  590. // Text that contains all information
  591. //
  592. if ($report_change['report_status'] == REPORT_DELETE)
  593. {
  594. $report_change_text = sprintf($lang['REPORT_CHANGE_DELETE_TEXT'], $report_change_user, $report_change_time);
  595. }
  596. else if ($report_change['report_change_comment'] != '')
  597. {
  598. $report_change_text = sprintf($lang['REPORT_CHANGE_TEXT_COMMENT'], $report_change_status, $report_change_user, $report_change_time, $report_change['report_change_comment']);
  599. }
  600. else
  601. {
  602. $report_change_text = sprintf($lang['REPORT_CHANGE_TEXT'], $report_change_status, $report_change_user, $report_change_time);
  603. }
  604. $template->assign_block_vars('switch_report_changes.report_changes', array(
  605. 'U_USER' => $u_report_change_user,
  606. 'ROW_CLASS' => $report_status_classes[$report_change['report_status']],
  607. 'STATUS' => $report_change_status,
  608. 'USER' => $report_change['username'],
  609. 'TIME' => $report_change_time,
  610. 'TEXT' => $report_change_text)
  611. );
  612. }
  613. //
  614. // Assign last change information
  615. //
  616. $template->assign_vars(array(
  617. 'U_REPORT_LAST_CHANGE_USER' => $u_report_change_user,
  618. 'REPORT_LAST_CHANGE_TIME' => $report_change_time,
  619. 'REPORT_LAST_CHANGE_USER' => $report_change['username'])
  620. );
  621. }
  622. //
  623. // Check if deletions are allowed
  624. //
  625. if ($report_module->auth_check('auth_delete_view'))
  626. {
  627. $template->assign_block_vars('switch_delete_option', array());
  628. }
  629. $template->assign_vars(array(
  630. 'S_HIDDEN_FIELDS' => '<input type="hidden" name="' . POST_REPORT_URL . '" value="' . $report['report_id'] . '" />',
  631. 'U_REPORT_AUTHOR' => append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $report['user_id']),
  632. 'U_REPORT_AUTHOR_PRIVMSG' => append_sid("privmsg.php?mode=post&amp;" . POST_USERS_URL . '=' . $report['user_id']),
  633. 'REPORT_TYPE' => $report_module->lang['REPORT_TYPE'],
  634. 'REPORT_TITLE' => $report['report_title'],
  635. 'REPORT_AUTHOR' => $report['username'],
  636. 'REPORT_TIME' => create_date($bb_cfg['default_dateformat'], $report['report_time'], $bb_cfg['board_timezone']),
  637. 'REPORT_DESC' => str_replace("\n", '<br />', $report['report_desc']),
  638. 'REPORT_STATUS' => $lang['REPORT_STATUS'][$report['report_status']],
  639. 'REPORT_STATUS_CLASS' => $report_status_classes[$report['report_status']],
  640. 'L_SUBJECT' => $lang['REPORT_SUBJECT'],
  641. 'L_SEND_PRIVMSG' => $lang['SEND_PRIVATE_MESSAGE'])
  642. );
  643. }
  644. //
  645. // Show report index page
  646. //
  647. else
  648. {
  649. $template->set_filenames(array(
  650. 'report_view' => 'report_index_body.tpl')
  651. );
  652. $statistics = array(
  653. 'Report_count' => 'report_count',
  654. 'Report_modules_count' => 'modules_count',
  655. 'Report_hack_count' => 'report_hack_count');
  656. foreach ($statistics as $stat_lang => $stat_mode)
  657. {
  658. $template->assign_block_vars('report_statistics', array(
  659. 'STATISTIC' => $lang[strtoupper($stat_lang)],
  660. 'VALUE' => report_statistics($stat_mode))
  661. );
  662. }
  663. /*
  664. if ($userdata['user_level'] == ADMIN)
  665. {
  666. */
  667. $deleted_reports = reports_deleted_obtain();
  668. if (!empty($deleted_reports))
  669. {
  670. $template->assign_block_vars('switch_deleted_reports', array());
  671. foreach ($deleted_reports as $report)
  672. {
  673. $report_module =& $report_modules[$report['report_module_id']];
  674. $template->assign_block_vars('switch_deleted_reports.deleted_reports', array(
  675. 'U_SHOW' => append_sid("report.php?" . POST_REPORT_URL . '=' . $report['report_id'] . $cat_url),
  676. 'U_AUTHOR' => append_sid("profile.php?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $report['user_id']),
  677. 'ID' => $report['report_id'],
  678. 'TITLE' => $report['report_title'],
  679. 'TYPE' => $report_module->lang['REPORT_TYPE'],
  680. 'AUTHOR' => $report['username'],
  681. 'TIME' => create_date($bb_cfg['default_dateformat'], $report['report_time'], $bb_cfg['board_timezone']),
  682. 'STATUS' => $lang['REPORT_STATUS'][REPORT_DELETE])
  683. );
  684. }
  685. }
  686. /*
  687. }
  688. */
  689. }
  690. $template->assign_var_from_handle('REPORT_VIEW', 'report_view');
  691. $template->pparse('body');
  692. include(PAGE_FOOTER);
  693. break;
  694. default:
  695. message_die(GENERAL_MESSAGE, $lang['REPORT_NOT_SUPPORTED'] . $return_links['index']);
  696. break;
  697. }
  698. }