Improved http status code in error case.
This commit is contained in:
parent
0e81a5fec7
commit
9357f90aae
1 changed files with 18 additions and 1 deletions
19
index.php
19
index.php
|
@ -41,33 +41,50 @@ if (
|
|||
if (strlen($_POST['txt']) >= 1 AND strlen($_POST['txt']) <= 4096)
|
||||
$params['txt'] = $_POST['txt'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for txt");
|
||||
}
|
||||
|
||||
if ($_POST['redondancy'] === "L" OR $_POST['redondancy'] === "M" OR $_POST['redondancy'] === "Q" OR $_POST['redondancy'] === "H")
|
||||
$params['redondancy'] = $_POST['redondancy'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for redondancy");
|
||||
}
|
||||
|
||||
if (is_numeric($_POST['margin']) AND $_POST['margin'] >= 0 AND $_POST['margin'] <= 128)
|
||||
$params['margin'] = $_POST['margin'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for margin");
|
||||
}
|
||||
|
||||
if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 128)
|
||||
$params['size'] = $_POST['size'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for size");
|
||||
}
|
||||
|
||||
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['bgColor']))
|
||||
$params['bgColor'] = $_POST['bgColor'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for bgColor");
|
||||
}
|
||||
|
||||
if (preg_match("/^#[abcdefABCDEF0-9]{6}$/", $_POST['mainColor']))
|
||||
$params['mainColor'] = $_POST['mainColor'];
|
||||
else
|
||||
{
|
||||
http_response_code(400);
|
||||
exit("Wrong value for mainColor");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue