From 6b7bbaf8c93d3ebb4185b104df51e1c52642445d Mon Sep 17 00:00:00 2001 From: bruno Date: Fri, 26 Apr 2024 10:39:00 +0200 Subject: [PATCH] Fix --- lib/upload.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/upload.php b/lib/upload.php index 40afcb1..9a20ee8 100644 --- a/lib/upload.php +++ b/lib/upload.php @@ -183,7 +183,7 @@ function fileExists(int $fileId, bool $onlyMine = true): bool|string if (!$onlyMine && !isModerator()) { $onlyMine = true; } - $query = $onlyMine ? 'SELECT ID, Path FROM Files WHERE ID = ? AND UploadedBy = ?' : 'SELECT ID, Path FROM Files WHERE ID = ?'; + $query = 'SELECT ID, Path FROM Files WHERE ID = ?' . ($onlyMine ? ' AND UploadedBy = ?' : ''); $stmtfileexists = $mysqli->prepare($query); if ($onlyMine) { $stmtfileexists->bind_param('ii', $fileId, $_SESSION['id']); @@ -191,11 +191,11 @@ function fileExists(int $fileId, bool $onlyMine = true): bool|string $stmtfileexists->bind_param('i', $fileId); } $filePath = ""; - $id = -1; + $id = null; $stmtfileexists->bind_result($id, $filePath); $stmtfileexists->execute(); $stmtfileexists->fetch(); - if ($id != -1) { + if ($stmtfileexists->num_rows > 0) { return $filePath; } else { return false;