[server/device-data] Add start/end datetime checking

This commit is contained in:
Starbeamrainbowlabs 2019-01-20 18:12:00 +00:00
parent a34efe5c25
commit b34ba0dc0b
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -51,6 +51,15 @@ class DeviceData implements IAction {
$this->validator->is_datetime("end");
$this->validator->run();
if(new \DateTime($_GET["start"]) > new \DateTime($_GET["end"])) {
$this->sender->send_error_plain(
400, "Error: The start date must be earlier than the end date.", [
[ "x-time-taken", PerfFormatter::format_perf_data($start_time, $start_handle, null) ]
]
);
return false;
}
if(!empty($_GET["average-seconds"]) && intval($_GET["average-seconds"]) == 0) {
$this->sender->send_error_plain(
400, "Error: That average-seconds value is invalid (an integer greater than 0 required).", [