query("SELECT username, admin, id FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\""); if ($out -> num_rows != 1) { fail: echo "nope"; header("Location: ../../../index.php"); return; } $status = 0; $supported_formats = array("jpg", "jpeg", "png", "webp"); if (!isset($_FILES["file_upload"])) { $status = 1; goto send; } if (!isset($_POST["name"])) { $status = 2; goto send; } if (!in_array(strtolower(pathinfo($_FILES["file_upload"]["name"], PATHINFO_EXTENSION)), $supported_formats)) { $status = 3; 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]);