checking for possible issues on upload_picture api
This commit is contained in:
parent
3e0818db1c
commit
282a0443ae
@ -1,6 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$status = 0;
|
include("../../global.php");
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_SESSION["username"])) goto fail;
|
||||||
|
|
||||||
|
$out = $database -> query("SELECT username, admin FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\" AND admin=\"1\"");
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
send:
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
echo json_encode(["status" => $status]);
|
echo json_encode(["status" => $status]);
|
Loading…
x
Reference in New Issue
Block a user