Fix
This commit is contained in:
@@ -78,8 +78,11 @@ function listFiles($onlyMine = true): array
|
||||
{
|
||||
$output = ["Status" => "Fail"];
|
||||
require_once "lib/account.php";
|
||||
if (($onlyMine && isLoggedIn()) || (!$onlyMine && isModerator())) {
|
||||
if (isLoggedIn()) {
|
||||
global $mysqli;
|
||||
if (!$onlyMine && !isModerator()) {
|
||||
$onlyMine = true;
|
||||
}
|
||||
$query = "SELECT ID, Path, Type, UploadedAt, UploadedBy FROM Files";
|
||||
|
||||
if ($onlyMine) {
|
||||
@@ -173,7 +176,7 @@ function getUploadPath($type = "unknown", $filename = "hehe"): string
|
||||
|
||||
function fileExists(int $fileId, bool $onlyMine = true): bool|string
|
||||
{
|
||||
if(!$fileId) {
|
||||
if (!$fileId) {
|
||||
return false;
|
||||
}
|
||||
global $mysqli;
|
||||
@@ -192,10 +195,9 @@ function fileExists(int $fileId, bool $onlyMine = true): bool|string
|
||||
$stmtfileexists->bind_result($id, $filePath);
|
||||
$stmtfileexists->execute();
|
||||
$stmtfileexists->fetch();
|
||||
if ($id != -1){
|
||||
if ($id != -1) {
|
||||
return $filePath;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +225,7 @@ function addToGroup(int $groupId, int $fileId): array
|
||||
return $output;
|
||||
}
|
||||
|
||||
function getImageURL(int $imageFileID) :string
|
||||
function getImageURL(int $imageFileID): string
|
||||
{
|
||||
global $mysqli;
|
||||
$path = "";
|
||||
@@ -236,11 +238,11 @@ function getImageURL(int $imageFileID) :string
|
||||
|
||||
}
|
||||
|
||||
function deleteFile(int $fileID) :string
|
||||
function deleteFile(int $fileID): string
|
||||
{
|
||||
global $mysqli;
|
||||
$out = ["Status" => "Fail"];
|
||||
if(isLoggedIn()) {
|
||||
if (isLoggedIn()) {
|
||||
$file_location = fileExists($fileID, !isAdmin());
|
||||
$query = !isAdmin() ? 'DELETE FROM Files WHERE ID = ? AND UploadedBy = ?' : 'DELETE FROM Files WHERE ID = ?';
|
||||
$stmtDelete = $mysqli->prepare($query);
|
||||
|
Reference in New Issue
Block a user