From 3af45b33d04e628ef550857501302eafcba05f72 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sun, 31 Mar 2019 15:12:10 -0600 Subject: [PATCH] Add location broadcast (Netsyms/HelpingHelenaApp/issues/5) --- api/actions/broadcast.php | 21 +++++++++++++++++++++ api/apisettings.php | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 api/actions/broadcast.php diff --git a/api/actions/broadcast.php b/api/actions/broadcast.php new file mode 100644 index 0000000..fdac93c --- /dev/null +++ b/api/actions/broadcast.php @@ -0,0 +1,21 @@ +get("authkeys", "accountid", ["key" => $VARS["key"]]); + +if (!$database->has("accounts", ["AND" => ["accountid" => $accountid, "type" => 2]])) { + sendJsonResp($Strings->get("Only receivers may broadcast their location to the map.", false), "ERROR"); +} + +$database->update("accounts", [ + "latitude" => $VARS["latitude"], + "longitude" => $VARS["longitude"], + "lastgpsfix" => date("Y-m-d H:i:s") + ], ["accountid" => $accountid]); + +sendJsonResp(); \ No newline at end of file diff --git a/api/apisettings.php b/api/apisettings.php index 14a7761..c801160 100644 --- a/api/apisettings.php +++ b/api/apisettings.php @@ -76,4 +76,12 @@ $APIS = [ "format (optional)" => "/(geojson)/" ] ], + "broadcast" => [ + "load" => "broadcast.php", + "vars" => [ + "key" => $keyregex, + "latitude" => "/-?[0-9]{2}\.[0-9]+/", + "longitude" => "/-?[0-9]{2,3}\.[0-9]+/" + ] + ], ];