Improved http status code in error case.

This commit is contained in:
Christian P. MOMON 2022-01-31 16:08:43 +01:00 committed by root
parent 0e81a5fec7
commit 9357f90aae

View file

@ -41,33 +41,50 @@ if (
if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096) if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096)
$params['txt'] = $_POST['txt']; $params['txt'] = $_POST['txt'];
else else
{
http_response_code(400);
exit("Wrong value for txt"); exit("Wrong value for txt");
}
if ($_POST['redondancy'] === "L" OR $_POST['redondancy'] === "M" OR $_POST['redondancy'] === "Q" OR $_POST['redondancy'] === "H") if ($_POST['redondancy'] === "L" OR $_POST['redondancy'] === "M" OR $_POST['redondancy'] === "Q" OR $_POST['redondancy'] === "H")
$params['redondancy'] = $_POST['redondancy']; $params['redondancy'] = $_POST['redondancy'];
else else
{
http_response_code(400);
exit("Wrong value for redondancy"); exit("Wrong value for redondancy");
}
if (is_numeric($_POST['margin']) AND $_POST['margin'] >= 0 AND $_POST['margin'] <= 128) if (is_numeric($_POST['margin']) AND $_POST['margin'] >= 0 AND $_POST['margin'] <= 128)
$params['margin'] = $_POST['margin']; $params['margin'] = $_POST['margin'];
else else
{
http_response_code(400);
exit("Wrong value for margin"); exit("Wrong value for margin");
}
if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 128) if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 128)
$params['size'] = $_POST['size']; $params['size'] = $_POST['size'];
else else
{
http_response_code(400);
exit("Wrong value for size"); exit("Wrong value for size");
}
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['bgColor'])) if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['bgColor']))
$params['bgColor'] = $_POST['bgColor']; $params['bgColor'] = $_POST['bgColor'];
else else
{
http_response_code(400);
exit("Wrong value for bgColor"); exit("Wrong value for bgColor");
}
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['mainColor'])) if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['mainColor']))
$params['mainColor'] = $_POST['mainColor']; $params['mainColor'] = $_POST['mainColor'];
else else
{
http_response_code(400);
exit("Wrong value for mainColor"); exit("Wrong value for mainColor");
}
} }
?> ?>