<?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();