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]+/" + ] + ], ];