PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/admin_reports.php

https://github.com/Dratone/EveBB
PHP | 184 lines | 143 code | 32 blank | 9 comment | 19 complexity | ff5a80d791749acd3c205e0cfe663960 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright (C) 2008-2010 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. // Tell header.php to use the admin template
  8. define('PUN_ADMIN_CONSOLE', 1);
  9. define('PUN_ROOT', dirname(__FILE__).'/');
  10. require PUN_ROOT.'include/common.php';
  11. require PUN_ROOT.'include/common_admin.php';
  12. if (!$pun_user['is_admmod'])
  13. message($lang_common['No permission']);
  14. // Load the admin_reports.php language file
  15. require PUN_ROOT.'lang/'.$admin_language.'/admin_reports.php';
  16. // Zap a report
  17. if (isset($_POST['zap_id']))
  18. {
  19. confirm_referrer('admin_reports.php');
  20. $zap_id = intval(key($_POST['zap_id']));
  21. $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE id='.$zap_id) or error('Unable to fetch report info', __FILE__, __LINE__, $db->error());
  22. $zapped = $db->result($result);
  23. if ($zapped == '')
  24. $db->query('UPDATE '.$db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $db->error());
  25. // Delete old reports (which cannot be viewed anyway)
  26. $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10,1') or error('Unable to fetch read reports to delete', __FILE__, __LINE__, $db->error());
  27. if ($db->num_rows($result) > 0)
  28. {
  29. $zapped_threshold = $db->result($result);
  30. $db->query('DELETE FROM '.$db->prefix.'reports WHERE zapped <= '.$zapped_threshold) or error('Unable to delete old read reports', __FILE__, __LINE__, $db->error());
  31. }
  32. redirect('admin_reports.php', $lang_admin_reports['Report zapped redirect']);
  33. }
  34. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Reports']);
  35. define('PUN_ACTIVE_PAGE', 'admin');
  36. require PUN_ROOT.'header.php';
  37. generate_admin_menu('reports');
  38. ?>
  39. <div class="blockform">
  40. <h2><span><?php echo $lang_admin_reports['New reports head'] ?></span></h2>
  41. <div class="box">
  42. <form method="post" action="admin_reports.php?action=zap">
  43. <?php
  44. $result = $db->query('SELECT r.id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, p.id AS pid, t.subject, f.forum_name, u.username AS reporter FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'posts AS p ON r.post_id=p.id LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id WHERE r.zapped IS NULL ORDER BY created DESC') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error());
  45. if ($db->num_rows($result))
  46. {
  47. while ($cur_report = $db->fetch_assoc($result))
  48. {
  49. $reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user'];
  50. $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';
  51. $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
  52. $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));
  53. $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
  54. $report_location = array($forum, $topic, $post_id);
  55. ?>
  56. <div class="inform">
  57. <fieldset>
  58. <legend><?php printf($lang_admin_reports['Report subhead'], format_time($cur_report['created'])) ?></legend>
  59. <div class="infldset">
  60. <table class="aligntop" cellspacing="0">
  61. <tr>
  62. <th scope="row"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></th>
  63. <td class="location"><?php echo implode(' ', $report_location) ?></td>
  64. </tr>
  65. <tr>
  66. <th scope="row"><?php echo $lang_admin_reports['Reason'] ?><div><input type="submit" name="zap_id[<?php echo $cur_report['id'] ?>]" value="<?php echo $lang_admin_reports['Zap'] ?>" /></div></th>
  67. <td><?php echo $post ?></td>
  68. </tr>
  69. </table>
  70. </div>
  71. </fieldset>
  72. </div>
  73. <?php
  74. }
  75. }
  76. else
  77. {
  78. ?>
  79. <div class="inform">
  80. <fieldset>
  81. <legend><?php echo $lang_admin_common['None'] ?></legend>
  82. <div class="infldset">
  83. <p><?php echo $lang_admin_reports['No new reports'] ?></p>
  84. </div>
  85. </fieldset>
  86. </div>
  87. <?php
  88. }
  89. ?>
  90. </form>
  91. </div>
  92. </div>
  93. <div class="blockform block2">
  94. <h2><span><?php echo $lang_admin_reports['Last 10 head'] ?></span></h2>
  95. <div class="box">
  96. <div class="fakeform">
  97. <?php
  98. $result = $db->query('SELECT r.id, r.topic_id, r.forum_id, r.reported_by, r.message, r.zapped, r.zapped_by AS zapped_by_id, p.id AS pid, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'posts AS p ON r.post_id=p.id LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id LEFT JOIN '.$db->prefix.'users AS u2 ON r.zapped_by=u2.id WHERE r.zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error());
  99. if ($db->num_rows($result))
  100. {
  101. while ($cur_report = $db->fetch_assoc($result))
  102. {
  103. $reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user'];
  104. $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>';
  105. $topic = ($cur_report['subject'] != '') ? '<span>»&#160;<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
  106. $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message']));
  107. $post_id = ($cur_report['pid'] != '') ? '<span>»&#160;<a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>»&#160;'.$lang_admin_reports['Deleted'].'</span>';
  108. $zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="profile.php?id='.$cur_report['zapped_by_id'].'">'.pun_htmlspecialchars($cur_report['zapped_by']).'</a>' : $lang_admin_reports['NA'];
  109. $zapped_by = ($cur_report['zapped_by'] != '') ? '<strong>'.pun_htmlspecialchars($cur_report['zapped_by']).'</strong>' : $lang_admin_reports['NA'];
  110. $report_location = array($forum, $topic, $post_id);
  111. ?>
  112. <div class="inform">
  113. <fieldset>
  114. <legend><?php printf($lang_admin_reports['Zapped subhead'], format_time($cur_report['zapped']), $zapped_by) ?></legend>
  115. <div class="infldset">
  116. <table class="aligntop" cellspacing="0">
  117. <tr>
  118. <th scope="row"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></th>
  119. <td class="location"><?php echo implode(' ', $report_location) ?></td>
  120. </tr>
  121. <tr>
  122. <th scope="row"><?php echo $lang_admin_reports['Reason'] ?></th>
  123. <td><?php echo $post ?></td>
  124. </tr>
  125. </table>
  126. </div>
  127. </fieldset>
  128. </div>
  129. <?php
  130. }
  131. }
  132. else
  133. {
  134. ?>
  135. <div class="inform">
  136. <fieldset>
  137. <legend><?php echo $lang_admin_common['None'] ?></legend>
  138. <div class="infldset">
  139. <p><?php echo $lang_admin_reports['No zapped reports'] ?></p>
  140. </div>
  141. </fieldset>
  142. </div>
  143. <?php
  144. }
  145. ?>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="clearer"></div>
  150. </div>
  151. <?php
  152. require PUN_ROOT.'footer.php';