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()) {
$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;