72 lines
1.8 KiB
PHP
72 lines
1.8 KiB
PHP
<?php
|
|
|
|
include "config.php";
|
|
include "helper.php";
|
|
|
|
$user = is_logged_in();
|
|
|
|
if (!$user || !in_array($user["username"], $admin_users, true)) {
|
|
http_response_code(404);
|
|
exit();
|
|
} else if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
$intent = $_POST["intent"];
|
|
|
|
if ($intent === "generate-invite") {
|
|
pg_insert(
|
|
$db, "invites",
|
|
array("id" => generate_id())
|
|
);
|
|
} else {
|
|
$err = $lang["errors"]["intent"];
|
|
}
|
|
} else if ($_GET["del"]) {
|
|
$del_type = explode("-", $_GET["del"])[0];
|
|
$del_id = explode("-", $_GET["del"])[1];
|
|
|
|
if (strlen($del_id) === 64 && preg_match("/^[a-f0-9]{64}$/", $del_id) && $del_type === "invite") {
|
|
pg_delete(
|
|
$db, "invites",
|
|
array(
|
|
"id" => $del_id
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
$title = $lang["admin"]["title"];
|
|
include "boilerplate/head.php";
|
|
|
|
?>
|
|
|
|
<div id="container">
|
|
<h3><?php echo $lang["admin"]["invite"]["title"]; ?></h3>
|
|
<?php
|
|
if ($signups !== "invite") {
|
|
echo "<span class=\"yellow\">{$lang['admin']['invite']['disabled']}</span>";
|
|
}
|
|
?>
|
|
<ul>
|
|
<?php
|
|
$invites = pg_fetch_all(pg_query($db, "SELECT * FROM invites;"));
|
|
if (count($invites) === 0) {
|
|
echo "<li><i>{$lang['admin']['invite']['none']}</i></li>";
|
|
} else {
|
|
foreach ($invites as $invite) {
|
|
echo "<li>
|
|
<code>{$invite['id']}</code> -
|
|
<a class=\"plain\" href=\"admin.php?del=invite-{$invite['id']}\">
|
|
<button tabindex=\"-1\">{$lang['admin']['invite']['delete']}</button>
|
|
</a>
|
|
</li>";
|
|
}
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
<form method="POST">
|
|
<input type="hidden" name="intent" value="generate-invite">
|
|
<input type="submit" value="<?php echo $lang["admin"]["invite"]["new"]; ?>">
|
|
</form>
|
|
</div>
|
|
|
|
<?php include "boilerplate/foot.php"; ?>
|