checking file size

This commit is contained in:
Václav Šmejkal 2024-05-24 18:22:33 +02:00
parent 21afe37ed4
commit eea55797aa
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -5,7 +5,7 @@ session_start();
if (!isset($_SESSION["username"])) goto fail;
$out = $database -> query("SELECT username, admin FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\" AND admin=\"1\"");
$out = $database -> query("SELECT username, admin, id FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\"");
if ($out -> num_rows != 1)
{
@ -36,6 +36,17 @@ if (!in_array(strtolower(pathinfo($_FILES["file_upload"]["name"], PATHINFO_EXTEN
goto send;
}
$res = $out -> fetch_assoc();
if (!$res["admin"])
{
if ($_FILES["file_upload"]["size"] > 5 * 1024 * 1024)
{
$status = 4;
goto send;
}
}
send:
header('Content-type: application/json');
echo json_encode(["status" => $status]);