Add location broadcast (Netsyms/HelpingHelenaApp/issues/5)
This commit is contained in:
parent
b15c2a0b99
commit
3af45b33d0
21
api/actions/broadcast.php
Normal file
21
api/actions/broadcast.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$accountid = $database->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();
|
@ -76,4 +76,12 @@ $APIS = [
|
|||||||
"format (optional)" => "/(geojson)/"
|
"format (optional)" => "/(geojson)/"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"broadcast" => [
|
||||||
|
"load" => "broadcast.php",
|
||||||
|
"vars" => [
|
||||||
|
"key" => $keyregex,
|
||||||
|
"latitude" => "/-?[0-9]{2}\.[0-9]+/",
|
||||||
|
"longitude" => "/-?[0-9]{2,3}\.[0-9]+/"
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user