forked from Adleraci/adlerka.top
Am I dumb?
This commit is contained in:
parent
64ccb94755
commit
9ac85a1afd
@ -183,22 +183,21 @@ function fileExists(int $fileId, bool $onlyMine = true): bool|string
|
|||||||
if (!$onlyMine && !isModerator()) {
|
if (!$onlyMine && !isModerator()) {
|
||||||
$onlyMine = true;
|
$onlyMine = true;
|
||||||
}
|
}
|
||||||
|
$query = 'SELECT ID, Path FROM Files WHERE ID = ?' . ($onlyMine ? ' AND UploadedBy = ?' : '');
|
||||||
|
$stmtfileexists = $mysqli->prepare($query);
|
||||||
if ($onlyMine) {
|
if ($onlyMine) {
|
||||||
$stmtfileexists = $mysqli->prepare('SELECT ID, Path FROM Files WHERE ID = ? AND UploadedBy = ?');
|
$stmtfileexists->bind_param('ii', $fileId, $_SESSION['ID']);
|
||||||
$stmtfileexists->bind_param('ii', $fileId, $_SESSION['id']);
|
|
||||||
} else {
|
} else {
|
||||||
$stmtfileexists = $mysqli->prepare('SELECT ID, Path FROM Files WHERE ID = ?');
|
|
||||||
$stmtfileexists->bind_param('i', $fileId);
|
$stmtfileexists->bind_param('i', $fileId);
|
||||||
}
|
}
|
||||||
$filePath = "";
|
$filePath = "";
|
||||||
$id = null;
|
$id = null;
|
||||||
$stmtfileexists->execute();
|
|
||||||
$stmtfileexists->bind_result($id, $filePath);
|
$stmtfileexists->bind_result($id, $filePath);
|
||||||
|
$stmtfileexists->execute();
|
||||||
$stmtfileexists->fetch();
|
$stmtfileexists->fetch();
|
||||||
if ($stmtfileexists->num_rows > 0) {
|
if ($id != null) {
|
||||||
return $filePath;
|
return $filePath;
|
||||||
} else {
|
} else {
|
||||||
echo "id: $id a path: $filePath";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user