This commit is contained in:
Bruno Rybársky 2024-04-26 10:39:00 +02:00
parent 0da696d733
commit 6b7bbaf8c9

@ -183,7 +183,7 @@ function fileExists(int $fileId, bool $onlyMine = true): bool|string
if (!$onlyMine && !isModerator()) { if (!$onlyMine && !isModerator()) {
$onlyMine = true; $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); $stmtfileexists = $mysqli->prepare($query);
if ($onlyMine) { if ($onlyMine) {
$stmtfileexists->bind_param('ii', $fileId, $_SESSION['id']); $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); $stmtfileexists->bind_param('i', $fileId);
} }
$filePath = ""; $filePath = "";
$id = -1; $id = null;
$stmtfileexists->bind_result($id, $filePath); $stmtfileexists->bind_result($id, $filePath);
$stmtfileexists->execute(); $stmtfileexists->execute();
$stmtfileexists->fetch(); $stmtfileexists->fetch();
if ($id != -1) { if ($stmtfileexists->num_rows > 0) {
return $filePath; return $filePath;
} else { } else {
return false; return false;