diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-12-10 20:20:21 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-12-10 20:20:21 +0100 |
commit | eb2e78a12505b8d41e0ef62cb1b321cdc540e5fd (patch) | |
tree | cd2ac4c7625d210ab36593b95f2bd1dc0b3e9a90 /functions.http.inc.php | |
parent | 075f05aaf9dfccc4a8a1e5741462ec4ee42ae743 (diff) |
additional checks if a parameter is set; function to create paths added
Diffstat (limited to 'functions.http.inc.php')
-rw-r--r-- | functions.http.inc.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/functions.http.inc.php b/functions.http.inc.php index 19f3e9e..f718179 100644 --- a/functions.http.inc.php +++ b/functions.http.inc.php @@ -103,7 +103,13 @@ function getMandatoryFileParameter($parameterName, $message = '', $json = false) } function getPostParameter($parameterName) { - return $_POST[$parameterName]; + if (array_key_exists($parameterName, $_POST) + && isset($_POST[$parameterName]) + && !empty($_POST[$parameterName])) { + return $_POST[$parameterName]; + } else { + return NULL; + } } function getOptionalPostParameter($parameterName, $default = NULL) { @@ -123,7 +129,7 @@ function getGetParameter($parameterName) { } function getOptionalGetParameter($parameterName, $default = NULL) { - $parameter = getPostParameter($parameterName); + $parameter = getGetParameter($parameterName); return handleOptionalParameter($parameter, $default); } @@ -143,7 +149,7 @@ function handleOptionalParameter($parameter, $default) { function handleMandatoryParameter($parameterName, $parameter, $message, $json) { if (!isset($parameter) || is_null($parameter) || empty($parameter)) { - if (empty($message)) { + if (empty($message) || is_null($message)) { if ($json) { $message = ['msg' => 'Missing parameter.', 'parameters' => ['missing_parameter' => $parameterName]]; } else { |