blob: 1bc81d2b53625f285718d758c0e4f801aa605c67 (
plain)
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
|
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/admin/session.php"; global $_USER; ?>
<?php
if (isset($_GET['submit'])) {
$admins = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/data/admins.json"), true);
if (isset($_GET["delete-user"])) {
$newlist = [];
foreach ($admins as $admin) {
if ($admin !== $_GET["delete-user"]) {
$newlist[] = $admin;
}
}
file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/data/admins.json", json_encode($newlist, JSON_PRETTY_PRINT));
header("Location: /admin/users");
die();
}
if (isset($_GET["add-user"])) {
$admins[] = $_GET["add-user"];
file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/data/admins.json", json_encode($admins, JSON_PRETTY_PRINT));
header("Location: /admin/users");
die();
}
}
?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/admin/header.php"; ?>
<br>
<div class="container">
<h1>Administrators Management</h1>
<p>Administrators added to this list are able to login to this admin panel using their GitHub account. Make sure you trust the person before giving them administrative permissions.</p>
<ul class="list-group">
<?php foreach (json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/data/admins.json"), true) as $user): ?>
<li class="list-group-item">
<form>
<span style="vertical-align: middle;padding-top:10px;">
<a href="https://github.com/<?= $user ?>" target="_blank"><?= $user ?></a>
<?php if ($user === $_USER): ?>
<span class="badge bg-warning rounded-pill">You!</span>
<?php endif; ?>
<?php if ($user === "Minteck"): ?>
<span class="badge bg-danger rounded-pill">Immutable</span>
<?php endif; ?>
</span>
<input name="delete-user" type="hidden" value="<?= $user ?>">
<input name="submit" type="hidden">
<button type="submit" class="btn btn-danger" style="float:right;vertical-align: middle;"
<?php if ($user === $_USER || $user === "Minteck"): ?> disabled<?php endif; ?>
>Remove</button>
</form>
</li>
<?php endforeach; ?>
</ul>
<br>
<button type="button" id="admin-add-s0" class="btn btn-outline-primary" onclick="document.getElementById('admin-add-s0').style.display='none';document.getElementById('admin-add-s1').style.display='';document.getElementById('admin-add-s2').focus();">Add another administrator</button>
<div class="card" style="max-width:550px;display:none;" id="admin-add-s1">
<form class="card-body">
<h4 class="card-title">Add administrator</h4>
<p>This will give this user full control over this website, including permission to add or remove other administrators. <b>Make sure you trust this user.</b></p>
<p>
<input id="admin-add-s2" name="add-user" type="text" class="form-control" placeholder="GitHub user name">
</p>
<input name="submit" type="hidden">
<button type="submit" class="btn btn-success">Add</button> <button onclick="document.getElementById('admin-add-s1').style.display='none';document.getElementById('admin-add-s0').style.display='';" type="button" class="btn btn-outline-danger">Cancel</button>
</form>
</div>
</div>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/admin/footer.php"; ?>
|