-
Notifications
You must be signed in to change notification settings - Fork 1
/
check.php
executable file
·379 lines (360 loc) · 17.9 KB
/
check.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<?php
require_once './include/page.php';
$page = new Page("check");
$search = (isset($_GET["search"]) ? $_GET["search"] : null);
$uuid = (isset($_GET["uuid"]) ? $_GET["uuid"] : null);
$name = (isset($_GET["name"]) ? $_GET["name"] : null);
if($search != null AND ($name == null AND $uuid == null)){ // if search
if(preg_match("/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i", $search)) { // search with UUID
$uuid = $search;
$name = $page->get_name($uuid);
} else if(preg_match("/^[0-9A-F]{8}[0-9A-F]{4}[0-9A-F]{3}[89AB][0-9A-F]{3}[0-9A-F]{12}$/i", $search)) { // search with UUID that don't have '-'
$search = "";
$i = 1;
foreach (str_split($search) as $char) {
$search .= $char;
if($i == 8 || $i == 12 || $i == 16 || $i == 20)
$search .= "-";
$i++;
}
$name = $page->get_name($uuid);
} else { // give name
$name = $search;
$uuid = $page->get_uuid($name);
if($uuid == null) { // failed to find UUID
$name = null;
}
}
} else { // directly give a value
if($uuid == null && $name != null)
$uuid = $page->get_uuid($name);
if($uuid != null && $name == null){
$uuid = $page->parse_uuid($uuid);
$name = $page->get_name($uuid);
}
}
if($page->hasPermission("accounts", "EDIT")) {
if(isset($_POST['uuid']) && isset($_POST['action'])) {
$action = $_POST['action'];
$uuid = $_POST['uuid'];
if($action == "alerts") {
$st = $page->conn->prepare("UPDATE negativity_accounts SET violations_by_cheat = '' WHERE id = ?");
$st->execute(array($uuid));
$st->closeCursor();
} else if($action == "minerate") {
$st = $page->conn->prepare("UPDATE negativity_accounts SET minerate = '', minerate_full_mined = 0 WHERE id = ?");
$st->execute(array($uuid));
$st->closeCursor();
} else if($action == "proofs") {
if($page->hasPermission("proofs", "MANAGE")) {
$st = $page->conn->prepare("DELETE FROM negativity_proofs WHERE uuid = ?");
$st->execute(array($uuid));
$st->closeCursor();
}
} else if($action == "verifications") {
if($page->hasPermission("proofs", "MANAGE")) {
$st = $page->conn->prepare("DELETE FROM negativity_verifications WHERE uuid = ?");
$st->execute(array($uuid));
$st->closeCursor();
}
} else if($action == "delete") {
if($page->hasPermission("accounts", "MANAGE")) {
$unban = $page->conn->prepare("DELETE FROM negativity_accounts WHERE id = ?;");
$unban->execute(array($uuid));
$unban->closeCursor();
header("Location: ./accounts.php");
exit();
}
} else if($action == "ban") {
if($page->hasPermission("bans", "EDIT") && isset($_POST["reason"])) {
$st = $page->conn->prepare("SELECT * FROM negativity_bans_active WHERE id = ?");
$st->execute(array($uuid));
$rows = $st->fetchAll(PDO::FETCH_ASSOC);
if(count($rows) == 0) { // if not already banned
$unban = $page->conn->prepare("INSERT INTO negativity_bans_active (id, reason, banned_by, expiration_time, execution_time) VALUES(?,?,?,?,CURRENT_TIMESTAMP);");
$unban->execute(array($uuid, $_POST['reason'], "Console", -1));
$unban->closeCursor();
}
$st->closeCursor();
}
} else if($action == "unban") {
if($page->hasPermission("bans", "EDIT")) {
$st = $page->conn->prepare("SELECT * FROM negativity_bans_active WHERE id = ?");
$st->execute(array($uuid));
$rows = $st->fetchAll(PDO::FETCH_ASSOC);
if(count($rows) == 1) { // found line to log
$row = $rows[0];
$logBan = $page->conn->prepare("INSERT INTO negativity_bans_log (id, reason, banned_by, expiration_time, cheat_name, revoked, execution_time, revocation_time, ip) VALUES (?,?,?,?,?,?,?,CURRENT_TIMESTAMP,?);");
$logBan->execute(array($uuid, $row["reason"], $row["banned_by"], $row["expiration_time"], $row["cheat_name"], 1, $row["execution_time"], $row["ip"]));
$logBan->closeCursor();
// now delete from actual db
$unban = $page->conn->prepare("DELETE FROM negativity_bans_active WHERE id = ?");
$unban->execute(array($uuid));
$unban->closeCursor();
}
$st->closeCursor();
}
}
}
}
function showContent($info, $clearButton = false) {
global $page, $uuid, $name;
$st = $page->conn->prepare("SELECT * FROM " . $info->getTableName() . " WHERE " . $info->getColumnID() . " = ?;");
$st->execute(array($uuid));
$allRows = $st->fetchAll(PDO::FETCH_ASSOC);
$st->closeCursor();
$nb = count($allRows);
if($nb > 0){
echo '<h2>' . str_replace("%nb%", $nb, str_replace("%name%", $name, $page->msg("check." . $info->getLink()))) . '</h2>';
if($clearButton) {
if($page->hasPermission($info->getLink(), "MANAGE")) {
?>
<form action="./check.php?uuid=<?php echo $uuid . '&name=' . $name; ?>" method="POST" style="display: contents;">
<input type="hidden" name="uuid" value="<?php echo $uuid; ?>">
<button class="btn-outline" name="action" value="<?php echo $info->getLink() ?>"><?php echo $page->msg("generic.clear"); ?></button>
</form>
<?php
}
}
echo '<br>';
echo '<div class="container"><table>';
foreach ($allRows as $row) {
$page->print_row($row, $info);
}
echo '</table></div>';
}
unset($page->isFirstRow);
}
$minerateAvailable = array("diamond_ore","gold_ore","iron_ore","coal_ore","ancient_debris");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Positivity - <?php echo ($name == null ? "Not found" : $name); ?></title>
<?php $page->print_common_head(); ?>
</head>
<body>
<?php
$page->show_topbar();
?>
<div class="page-wrapper">
<?php
$page->show_header();
if($uuid == null || $name == null){
?>
<div class="content-wrapper">
<div class="content">
<div class="container">
<br>
<?php
echo '<h1>' . $page->msg("error.not_found.player") . '</h1>';
echo '<h3>' . $page->msg("check.propositions") . '</h3>';
?>
<br>
</div>
<?php
// now let's trying to find possible players
if($search != null) { // but only if it's search
$st = $page->conn->prepare("SELECT * FROM negativity_accounts WHERE UPPER(playername) LIKE UPPER(?);");
$st->execute(array('%' . $search . '%'));
$allRowSearch = $st->fetchAll(PDO::FETCH_ASSOC);
$st->closeCursor();
$nbSearch = count($allRowSearch);
if($nbSearch > 0) {
echo '<div class="container"><table>';
foreach ($allRowSearch as $rowSearch) {
$page->print_row($rowSearch);
}
echo '</table></div>';
}
}
$page->show_footer();
?>
</div>
</div>
<?php
} else {
$stAccount = $page->conn->prepare("SELECT * FROM negativity_accounts WHERE id = ?;");
$stAccount->execute(array($uuid));
$rowAcc = $stAccount->fetch();
$stAccount->closeCursor();
$minerateArray = array();
foreach (explode(";", $rowAcc["minerate"]) as $allMinerate) {
$tab = explode("=", $allMinerate, 2);
foreach ($tab as $minerate) {
if(is_numeric($minerate) || count($tab) <= 1) continue;
$minerateArray = array_merge($minerateArray, array($minerate => $tab[1]));
}
}
?>
<div class="content-wrapper">
<div class="content">
<div class="container">
<table class="table table-striped table-bordered table-condensed text-white">
<thead>
<tr>
<th><?php echo $page->msg("column.name"); ?></th>
<th><?php echo $page->msg("column.lang"); ?></th>
<th><?php echo $page->msg("column.creation_time"); ?></th>
<th><?php echo $page->msg("column.id"); ?></th>
<th><?php echo $page->msg("column.options"); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $name; ?></td>
<td><?php echo $rowAcc["language"]; ?></td>
<td><?php echo $rowAcc["creation_time"]; ?></td>
<td><?php echo $uuid; ?></td>
<td>
<?php
if($page->has_bans && $page->hasPermission("bans", "EDIT")) {
$banned = $page->is_banned($uuid);
?>
<form action="./check.php?uuid=<?php echo $uuid . '&name=' . $name; ?>" method="POST" style="display: contents;">
<input type="hidden" name="uuid" value="<?php echo $uuid; ?>">
<?php
if($banned) {
echo '<button class="btn-outline" name="action" value="unban">' . $page->msg("generic.unban") . '</button>';
} else {
echo '<input type="text" name="reason" required style="width: auto;" placeholder="' . $page->msg("ask.ban.reason") . '">';
echo '<button class="btn-outline" name="action" value="ban" style="margin-left: 10px;">' . $page->msg("generic.ban") . '</button>';
}
echo '</form>';
}
if($page->hasPermission("accounts", "MANAGE")) {
?>
<form action="./check.php?uuid=<?php echo $uuid . '&name=' . $name; ?>" method="POST" style="display: contents;">
<input type="hidden" name="uuid" value="<?php echo $uuid; ?>">
<button class="btn-outline" name="action" value="delete"><?php echo $page->msg("generic.delete"); ?></button>
</form>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<?php
echo '<h2>' . str_replace("%name%", $name, $page->msg("check.violations")) . '</h2>';
if($page->hasPermission("accounts", "EDIT")) {
?>
<form action="./check.php?uuid=<?php echo $uuid . '&name=' . $name; ?>" method="POST" style="display: contents;">
<input type="hidden" name="uuid" value="<?php echo $uuid; ?>">
<button class="btn-outline" name="action" value="alerts"><?php echo $page->msg("generic.clear"); ?></button>
</form>
<?php
}
?>
</div>
<div class="container">
<table class="table table-striped table-bordered table-condensed text-white">
<?php
$allViolationsSplitted = explode(";", $rowAcc["violations_by_cheat"]);
$nbAllViolations = $page->countAllViolation($rowAcc["violations_by_cheat"]);
?>
<thead>
<tr>
<?php
if($nbAllViolations == 0){
?>
<th style="width: 50%;"><?php echo $page->msg("generic.cheat"); ?></th>
<th style="width: 50%;"><?php echo $page->msg("generic.amount"); ?></th>
<?php
} else {
?>
<th style="width: 24%;"><?php echo $page->msg("generic.cheat"); ?></th>
<th style="width: 24%;"><?php echo $page->msg("generic.amount"); ?></th>
<th style="width: 4%;"></th>
<th style="width: 24%;"><?php echo $page->msg("generic.cheat"); ?></th>
<th style="width: 24%;"><?php echo $page->msg("generic.amount"); ?></th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
$tempNb = 0;
echo "<tr>";
$allViolationsSplitted = explode(";", $rowAcc["violations_by_cheat"]);
if($nbAllViolations == 0){
?>
<td>-</td>
<td>0</td>
<?php
} else {
foreach ($allViolationsSplitted as $allCheat) {
$tab = explode("=", $allCheat, 2);
foreach ($tab as $cheat) {
if(isset($tab[1]) && !is_numeric($cheat)) {
echo "<td>" . $page->getCheatName($cheat) . "</td>";
echo "<td>$tab[1]</td>";
$tempNb++;
if($tempNb == 2){
$tempNb = 0;
echo "</tr>";
if(end($allViolationsSplitted) != $allCheat)
echo "<tr>";
} else
echo "<td></td>";
}
}
}
}
echo "</tr>";
?>
</tbody>
</table>
</div>
<div>
<?php
echo '<h2>' . str_replace("%name%", $name, $page->msg("check.minerate")) . '</h2>';
if($page->hasPermission("accounts", "EDIT")) {
?>
<form action="./check.php?uuid=<?php echo $uuid . '&name=' . $name; ?>" method="POST" style="display: contents;">
<input type="hidden" name="uuid" value="<?php echo $uuid; ?>">
<button class="btn-outline" name="action" value="minerate"><?php echo $page->msg("generic.clear"); ?></button>
</form>
<?php
}
?>
</div>
<div class="container">
<table>
<thead>
<tr>
<th><?php echo $page->msg("minerate.name"); ?></th>
<th><?php echo $page->msg("generic.amount"); ?></th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($minerateAvailable as $mineKey) {
echo "<td>" . $page->msg("minerate." . strtolower($mineKey)) . "</td>";
echo "<td>" . (isset($minerateArray[$mineKey]) ? $minerateArray[$mineKey] : 0) . "</td>";
echo "</tr><tr>";
}
echo "<td>" . $page->msg("minerate.all") . "</td>";
echo "<td>" . $rowAcc["minerate_full_mined"] . "</td>";
?>
</tr>
</tbody>
</table>
</div>
<?php
showContent(new BanInfo($page));
showContent(new BanLogsInfo($page));
showContent(new VerificationInfo($page), true);
showContent(new ProofsInfo($page), true);
}
$page->show_footer();
?>
</div>
</div>
</div>
</body>
</html>