2024-01-02 03:55:23 +01:00
|
|
|
<?php session_start();
|
|
|
|
|
|
|
|
include "core.php";
|
|
|
|
include "config.php";
|
|
|
|
|
2024-01-03 11:59:01 +01:00
|
|
|
$retid = -1;
|
2024-01-02 03:55:23 +01:00
|
|
|
$id = -1;
|
|
|
|
|
|
|
|
$Redirect = "";
|
|
|
|
$AuthorizedCreation = 0;
|
|
|
|
|
|
|
|
if (isset($_REQUEST['redir'])) {
|
|
|
|
$Redirect = htmlspecialchars($_REQUEST['redir']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_REQUEST['id'])) {
|
2024-01-03 11:59:01 +01:00
|
|
|
$id = htmlspecialchars($_REQUEST['id']);
|
2024-01-02 03:55:23 +01:00
|
|
|
} else {
|
|
|
|
if ($Redirect == "admin") {
|
|
|
|
header("Location: admin.php?e=endpoint&action=comments");
|
|
|
|
} else if ($Redirect == "edit") {
|
|
|
|
header("Location: edit.php?e=endpoint&action=comments");
|
|
|
|
} else {
|
|
|
|
header("Location: /");
|
|
|
|
}
|
|
|
|
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2024-01-03 11:59:01 +01:00
|
|
|
if (isset($_REQUEST['retid'])) {
|
|
|
|
$retid = htmlspecialchars($_REQUEST['retid']);
|
|
|
|
} else {
|
|
|
|
$retid = -1;
|
|
|
|
}
|
|
|
|
|
2024-01-02 03:55:23 +01:00
|
|
|
$Database = createTables($sqlDB);
|
|
|
|
$DatabaseQuery = $Database->query('SELECT * FROM users');
|
|
|
|
|
|
|
|
if (!isset($_SESSION['username']) || !isset($_SESSION['password']) || !isset($_SESSION['type'])) {
|
|
|
|
header('Location: login.php?redir=admin');
|
|
|
|
die();
|
|
|
|
} else if ($_SESSION['type'] != 2) { // not allowed
|
2024-01-03 11:59:01 +01:00
|
|
|
header("Location: /?id=$retid");
|
2024-01-02 03:55:23 +01:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
$DatabaseQuery = $Database->query('SELECT * FROM users');
|
|
|
|
while ($line = $DatabaseQuery->fetchArray()) {
|
|
|
|
if ($line['username'] == $_SESSION['username'] && $_SESSION['username'] != "" && $line['password'] == $_SESSION['password'] && $line['usertype'] == 2) {
|
|
|
|
$AuthorizedCreation = 1;
|
|
|
|
break;
|
|
|
|
} else if ($line['username'] == $_SESSION['username'] && $_SESSION['username'] != "" && $line['password'] == $_SESSION['password']) {
|
|
|
|
$CommentDatabaseQuery = $Database->query('SELECT * FROM comments');
|
|
|
|
|
|
|
|
while ($cline = $CommentDatabaseQuery->fetchArray()) {
|
|
|
|
if ($line['id'] == $id && $line['username'] == $_SESSION['username']) {
|
|
|
|
$AuthorizedCreation = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$Username = $_SESSION['username'];
|
|
|
|
|
|
|
|
// not authorized
|
|
|
|
if ($AuthorizedCreation != 1) {
|
2024-01-03 11:59:01 +01:00
|
|
|
header("Location: /?id=$retid");
|
2024-01-02 03:55:23 +01:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
$Database->exec("DELETE FROM comments WHERE id='$id'");
|
|
|
|
|
|
|
|
if ($Redirect == "admin") {
|
|
|
|
header("Location: admin.php?action=comments");
|
|
|
|
} else if ($Redirect == "edit") {
|
|
|
|
header("Location: edit.php?action=comments");
|
|
|
|
} else {
|
2024-01-03 11:59:01 +01:00
|
|
|
header("Location: /?id=$retid");
|
2024-01-02 03:55:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
die();
|
|
|
|
|
|
|
|
?>
|