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 = "";
|
2024-02-05 20:32:40 +01:00
|
|
|
$Authorized = 0;
|
2024-01-02 03:55:23 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
$DatabaseQuery = $Database->query('SELECT * FROM users');
|
|
|
|
while ($line = $DatabaseQuery->fetchArray()) {
|
2024-02-05 21:46:50 +01:00
|
|
|
if ($line['username'] == htmlspecialchars($_SESSION['username']) && htmlspecialchars($_SESSION['username']) != "" && $line['password'] == htmlspecialchars($_SESSION['password'])) {
|
2024-02-05 20:32:40 +01:00
|
|
|
if ($line['usertype'] == 2) {
|
|
|
|
$Authorized = 1;
|
|
|
|
} else {
|
|
|
|
$CommentDatabaseQuery = $Database->query('SELECT * FROM comments');
|
|
|
|
|
|
|
|
while ($cline = $CommentDatabaseQuery->fetchArray()) {
|
2024-02-05 21:46:50 +01:00
|
|
|
if ($cline['id'] == $id && $cline['username'] == htmlspecialchars($_SESSION['username'])) {
|
2024-02-05 20:32:40 +01:00
|
|
|
$Authorized = 1;
|
|
|
|
}
|
2024-01-02 03:55:23 +01:00
|
|
|
}
|
|
|
|
|
2024-02-05 20:32:40 +01:00
|
|
|
break;
|
|
|
|
}
|
2024-01-02 03:55:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 21:46:50 +01:00
|
|
|
$Username = htmlspecialchars($_SESSION['username']);
|
2024-01-02 03:55:23 +01:00
|
|
|
|
|
|
|
// not authorized
|
2024-02-05 20:32:40 +01:00
|
|
|
if ($Authorized != 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();
|
|
|
|
|
|
|
|
?>
|