-
Notifications
You must be signed in to change notification settings - Fork 1
/
bans.php
154 lines (130 loc) · 7.62 KB
/
bans.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<html>
<head>
<?php
require('htmlhead.php');
echo '<title>' . $config['global']['PAGE_TITLE_BOT_NAME'] . ' - Ban List</title>';
if (!isset($_GET['page'])) {
header('Location: bans.php?page=1');
die('Error: Bad Page Number.');
}
$query = "SELECT * FROM `bans` ORDER BY banID;";
$result = mysqli_query($dbcon, $query) or die('error gathering data.');
$num_rows = mysqli_num_rows($result);
$num_pages = ceil($num_rows/$config['bans']['BAN_RESULTS_PER_PAGE']);
$page = $_GET['page'];
$this_page_first_result = ($page-1)*$config['bans']['BAN_RESULTS_PER_PAGE'];
$query = 'SELECT * FROM `bans` ORDER BY banID DESC LIMIT ' . $this_page_first_result . ',' . $config['bans']['BAN_RESULTS_PER_PAGE'];
$result = mysqli_query($dbcon, $query) or die('error gathering data.');
?>
</head>
<body style="background-color:#f1f3f4;">
<?php require('header.php'); ?>
<div class="container" align="center">
<div class="card mb-3" style="width:90%;">
<table class="table table-hover" style="width:100%; margin-bottom: 0rem;">
<thead>
<tr>
<th scope="col" colspan="6" style="text-align: center;">Ban List</th>
</tr>
<tr>
<th scope="col" style="width: 20%">Banned User</th>
<th scope="col" style="width: 25%">Guild Name</th>
<th scope="col" style="width: 20%">Issued By</th>
<th scope="col" style="width: 25%">Reason</th>
<th scope="col" style="width: 10%">Date Issued</th>
</tr>
</thead>
<tbody>
<?php
if($num_rows == 0) {
echo '<tr><td colspan="6" style="text-align:center; vertical-align:middle;">No Recorded Bans</td></tr>';
}
else
{
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr>";
echo "<td style='vertical-align: middle;'>";
$userQuery = "SELECT * FROM `users` WHERE id=" . $row['issuedTo'] . ";";
$userResults = mysqli_query($dbcon, $userQuery) or die('error gathering data.');
$num_userRows = mysqli_num_rows($userResults);
if($num_userRows == 1) {
while($userRow = mysqli_fetch_array($userResults, MYSQLI_ASSOC)) {
echo "<a href=\"profile.php?id=" . $row['issuedTo'] . " \"><img src=\"" . $userRow['avatarUrl'] . "\" height=\"32\" width=\"32\" style=\"border-radius: 50%;\" /> " . "@" . $userRow['username'] . "</a>";
}
}
else {
echo $row['issuedTo'];
}
echo "</td><td style='vertical-align: middle;'>";
$guildQuery = "SELECT * FROM `guilds` WHERE guildID=" . $row['inGuild'] . ";";
$guildResults = mysqli_query($dbcon, $guildQuery) or die('error gathering data.');
$num_guildRows = mysqli_num_rows($guildResults);
if($num_guildRows == 1) {
while($guildRow = mysqli_fetch_array($guildResults, MYSQLI_ASSOC)) {
echo $guildRow['guildName'];
}
}
else {
echo $row['issuedTo'];
}
echo "</td><td style='vertical-align: middle;'>";
$userQuery = "SELECT * FROM `users` WHERE id=" . $row['issuedBy'] . ";";
$userResults = mysqli_query($dbcon, $userQuery) or die('error gathering data.');
$num_userRows = mysqli_num_rows($userResults);
if($num_userRows == 1) {
while($userRow = mysqli_fetch_array($userResults, MYSQLI_ASSOC)) {
echo "<a href=\"profile.php?id=" . $row['issuedBy'] . " \"><img src=\"" . $userRow['avatarUrl'] . "\" height=\"32\" width=\"32\" style=\"border-radius: 50%;\" /> " . "@" . $userRow['username'] . "</a>";
}
}
else {
echo $row['issuedBy'];
}
echo "</td><td style='vertical-align: middle;'>";
if($row['banDescription'] == null) {
echo 'No reason provided.';
}
else {
echo $row['banDescription'];
}
echo "</td><td style='vertical-align: middle;'>";
echo date('d/M/Y', strtotime($row['dateIssued']));
echo "</td></tr>";
}
}
?>
</tbody>
</table>
</div>
<div>
<?php
$onPage = 1;
if (isset($_GET['page'])) {
$onPage = $_GET['page'];
}
if($onPage != 1 && $num_pages > 1) {
echo '<a href="bans.php?page=1"><button type="button" class="btn btn-light"><<</button></a>';
echo '<a href="bans.php?page=' . ($onPage - 1) . '"><button type="button" class="btn btn-light"><</button></a>';
}
$startOnPage = $onPage - $config['bans']['PAGES_PER_SIDE'];
$endOnPage = $onPage + $config['bans']['PAGES_PER_SIDE'];
if($startOnPage < 1) { $startOnPage = 1; }
if($endOnPage > $num_pages) { $endOnPage = $num_pages; }
if($num_pages > 1) { // Must be more than 1 page before displaying page numbers
for (($page = $startOnPage); ($page <= $endOnPage); $page++) { //for ($page=1; $page<=$num_pages; $page++)
if($page == $onPage) {
echo '<button type="button" class="btn btn-primary">' . $page . '</button>';
} else {
echo '<a href="bans.php?page=' . $page . '"><button type="button" class="btn btn-light">' . $page . '</button></a>';
}
}
}
if($onPage != $num_pages && $num_pages > 1) {
echo '<a href="bans.php?page=' . ($onPage + 1) . '"><button type="button" class="btn btn-light">></button></a>';
echo '<a href="bans.php?page=' . $num_pages . '"><button type="button" class="btn btn-light">>></button></a>';
}
?>
</div>
</div>
<?php require('footer.php'); ?>
</body>
</html>