Add delete page for admins

This commit is contained in:
abbie 2024-10-22 13:40:57 +01:00
parent a9da01afc8
commit 4d8b24eb8c
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
2 changed files with 21 additions and 0 deletions

18
delete.php Normal file
View file

@ -0,0 +1,18 @@
<?php
include 'include/db.php';
include 'include/templates.php';
if (!isset($_GET['id'])) {
die("<meta http-equiv=\"refresh\" content=\"0; url=/\">");
}
if (isAdmin(tokenToUuid($_COOKIE["meowboardSession"])) == 1) {
global $db;
$statement = $db->prepare("DELETE FROM images WHERE id = ?");
$statement->bindParam(1, $_GET['id'], SQLITE3_INTEGER);
$result = $statement->execute();
die("<meta http-equiv=\"refresh\" content=\"0; url=/\">");
}
?>

View file

@ -19,5 +19,8 @@ echo '<br/><strong>Tags:</strong>';
for($x = 0; $x < count($tags); $x++) {
printTag($tags[$x], true);
}
if (isAdmin(tokenToUuid($_COOKIE["meowboardSession"])) == 1) {
echo '<form action="delete.php?id=' . $_GET['id'] . '" method="get"><input type="text" id="id" name="id"><br/><button>Delete</button>';
}
echo $footer;
?>