This commit is contained in:
Bruno Rybársky 2024-04-26 10:52:11 +02:00
parent 496d381ace
commit dbfea88177
2 changed files with 6 additions and 6 deletions

@ -71,10 +71,10 @@ function deleteMeme(int $memeId): array
global $mysqli;
$out = ["Status" => "Fail"];
if (isLoggedIn()) {
$query = !isAdmin() ? 'DELETE FROM Memes WHERE ID = ? AND AuthorID = ?' : 'DELETE FROM Memes WHERE ID = ?';
$query = !isModerator() ? 'DELETE FROM Memes WHERE ID = ? AND AuthorID = ?' : 'DELETE FROM Memes WHERE ID = ?';
$stmtDelete = $mysqli->prepare($query);
if (!isAdmin()) {
$stmtDelete->bind_param('ii', $memeId, $_SESSION['id']);
if (!isModerator()) {
$stmtDelete->bind_param('ii', $memeId, $_SESSION['ID']);
} else {
$stmtDelete->bind_param('i', $memeId);
}

@ -210,12 +210,12 @@ function addToGroup(int $groupId, int $fileId): array
}
global $mysqli;
$stmtcheck = $mysqli->prepare('SELECT ID FROM FileGroups WHERE CreatorID != ? AND ID = ?');
$stmtcheck->bind_param('ii', $_SESSION['id'], $groupId);
$stmtcheck->bind_param('ii', $_SESSION['ID'], $groupId);
$stmtcheck->execute();
if ($stmtcheck->affected_rows == 0) {
if (fileExists($fileId, false)) {
$stmtadd = $mysqli->prepare('INSERT INTO FileGroups (FileID, CreatorID, ID) VALUES (?, ?, ?)');
$stmtadd->bind_param('iii', $fileId, $_SESSION['id'], $groupId);
$stmtadd->bind_param('iii', $fileId, $_SESSION['ID'], $groupId);
$stmtadd->execute();
if ($stmtadd->affected_rows > 0) {
$output["Status"] = "Success";
@ -247,7 +247,7 @@ function deleteFile(int $fileID): string
$query = !isAdmin() ? 'DELETE FROM Files WHERE ID = ? AND UploadedBy = ?' : 'DELETE FROM Files WHERE ID = ?';
$stmtDelete = $mysqli->prepare($query);
if (!isAdmin()) {
$stmtDelete->bind_param('ii', $fileID, $_SESSION['id']);
$stmtDelete->bind_param('ii', $fileID, $_SESSION['ID']);
} else {
$stmtDelete->bind_param('i', $fileID);
}