Client API: add error on unknown action

This commit is contained in:
Bartek Fabiszewski 2017-08-24 11:05:36 +02:00
parent 1513ff53a3
commit 18fa942259

View File

@ -65,7 +65,7 @@ switch ($action) {
case "addtrack": case "addtrack":
$trackName = isset($_REQUEST['track']) ? $_REQUEST['track'] : NULL; $trackName = isset($_REQUEST['track']) ? $_REQUEST['track'] : NULL;
if (empty($trackName)) { if (empty($trackName)) {
setError($response, "missing required parameter"); setError($response, "Missing required parameter");
break; break;
} }
require_once(ROOT_DIR . "/helpers/track.php"); require_once(ROOT_DIR . "/helpers/track.php");
@ -93,7 +93,7 @@ switch ($action) {
$trackId = isset($_REQUEST["trackid"]) ? $_REQUEST["trackid"] : NULL; $trackId = isset($_REQUEST["trackid"]) ? $_REQUEST["trackid"] : NULL;
if (is_null($lat) || is_null($lon) || is_null($timestamp) || is_null($trackId)) { if (is_null($lat) || is_null($lon) || is_null($timestamp) || is_null($trackId)) {
setError($response, "missing required parameter"); setError($response, "Missing required parameter");
break; break;
} }
@ -105,7 +105,11 @@ switch ($action) {
setError($response, "Server error"); setError($response, "Server error");
} }
break; break;
}
default:
setError($response, "Unknown command");
break;
}
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($response); echo json_encode($response);