-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreports.php
63 lines (48 loc) · 1.31 KB
/
reports.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
$pagetitle = 'Report Control';
require 'common.php';
if (!$logged)
{
$tpl->message = 'You must be logged in to view this page.';
$tpl->Execute(null);
exit;
}
if (!$GUIDE)
{
$tpl->message = 'You must be a Light Guide to view this page.';
$tpl->Execute(null);
exit;
}
$count = webcp_db_fetchall('SELECT COUNT(1) as count FROM reports');
$count = $count[0]['count'];
if ($count == 0)
{
$tpl->message = 'No reports have been made yet.';
$tpl->Execute(null);
return;
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pages = ceil($count / $perpage);
if ($page < 1 || $page > $pages)
{
$page = max(min($page, $pages), 1);
}
$start = ($page-1) * $perpage;
$reports = webcp_db_fetchall("SELECT reporter, reported, reason, time FROM reports ORDER BY time DESC LIMIT ?,?", $start, $perpage);
foreach ($reports as &$report)
{
$report['reporter'] = ucfirst($report['reporter']);
$report['reported'] = ucfirst($report['reported']);
$report['time_ago'] = timeago_full($report['time'], time());
}
$pagination = generate_pagination($pages, $page);
$tpl->page = $page;
$tpl->pages = $pages;
$tpl->pagination = $pagination;
$tpl->perpage = $perpage;
$tpl->showing = count($reports);
$tpl->start = $start+1;
$tpl->end = min($start+$perpage, $count);
$tpl->count = $count;
$tpl->reports = $reports;
$tpl->Execute('reports');