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