punbb/admin_reports.php
author Dan
Wed, 11 Jul 2007 21:01:48 -0400
changeset 0 f9ffdbd96607
child 2 a8a21e1c7afa
permissions -rw-r--r--
Initial population
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// Tell header.php to use the admin template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
define('PUN_ADMIN_CONSOLE', 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
define('PUN_ROOT', './');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
require PUN_ROOT.'include/common.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
if ($pun_user['g_id'] > PUN_MOD)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
// Zap a report
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
if (isset($_POST['zap_id']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
	confirm_referrer('admin_reports.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
	$zap_id = intval(key($_POST['zap_id']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
	$result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE id='.$zap_id) or error('Unable to fetch report info', __FILE__, __LINE__, $db->error());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	$zapped = $db->result($result);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
	if ($zapped == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
		$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());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
	redirect('admin_reports.php', 'Report zapped. Redirecting &hellip;');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Reports';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
generate_admin_menu('reports');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
		<h2><span>New reports</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
			<form method="post" action="admin_reports.php?action=zap">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
$result = $db->query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, t.subject, f.forum_name, u.username AS reporter FROM '.$db->prefix.'reports AS r 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());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
if ($db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
	while ($cur_report = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
		$reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : 'Deleted user';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
		$forum = ($cur_report['forum_name'] != '') ? '<a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
		$topic = ($cur_report['subject'] != '') ? '<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
		$post = ($cur_report['post_id'] != '') ? str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message'])) : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
		$postid = ($cur_report['post_id'] != '') ? '<a href="viewtopic.php?pid='.$cur_report['post_id'].'#p'.$cur_report['post_id'].'">Post #'.$cur_report['post_id'].'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
						<legend>Reported <?php echo format_time($cur_report['created']) ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
							<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    85
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
									<th scope="row">Forum&nbsp;&raquo;&nbsp;Topic&nbsp;&raquo;&nbsp;Post</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
									<td><?php echo $forum ?>&nbsp;&raquo;&nbsp;<?php echo $topic ?>&nbsp;&raquo;&nbsp;<?php echo $postid ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    90
									<th scope="row">Report by <?php echo $reporter ?><div><input type="submit" name="zap_id[<?php echo $cur_report['id'] ?>]" value=" Zap " /></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
									<td><?php echo $post ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    96
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
	echo "\t\t\t\t".'<p>There are no new reports.</p>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
	<div class="blockform block2">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
		<h2><span>10 last zapped reports</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
			<div class="fakeform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
$result = $db->query('SELECT r.id, r.post_id, r.topic_id, r.forum_id, r.reported_by, r.message, r.zapped, r.zapped_by AS zapped_by_id, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by FROM '.$db->prefix.'reports AS r 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());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
if ($db->num_rows($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
	while ($cur_report = $db->fetch_assoc($result))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
		$reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : 'Deleted user';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
		$forum = ($cur_report['forum_name'] != '') ? '<a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
		$topic = ($cur_report['subject'] != '') ? '<a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
		$post = ($cur_report['post_id'] != '') ? str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message'])) : 'Post deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
		$post_id = ($cur_report['post_id'] != '') ? '<a href="viewtopic.php?pid='.$cur_report['post_id'].'#p'.$cur_report['post_id'].'">Post #'.$cur_report['post_id'].'</a>' : 'Deleted';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
		$zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="profile.php?id='.$cur_report['zapped_by_id'].'">'.pun_htmlspecialchars($cur_report['zapped_by']).'</a>' : 'N/A';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
						<legend>Zapped <?php echo format_time($cur_report['zapped']) ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
							<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
									<th scope="row">Forum&nbsp;&raquo;&nbsp;Topic&nbsp;&raquo;&nbsp;Post</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
									<td><?php echo $forum ?>&nbsp;&raquo;&nbsp;<?php echo $topic ?>&nbsp;&raquo;&nbsp;<?php echo $post_id ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
									<th scope="row">Reported by <?php echo $reporter ?><div class="topspace">Zapped by <?php echo $zapped_by ?></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
									<td><?php echo $post ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
	echo "\t\t\t\t".'<p>There are no zapped reports.</p>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
require PUN_ROOT.'footer.php';