From dc52028474b63c65bd345c3d6d6a8b01f85818ca Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 6 May 2019 15:35:22 -0600 Subject: [PATCH] Update player location and lastping when we get a lat/lng from them --- api/actions/getchat.php | 9 +++++++++ api/actions/nearbyplaces.php | 11 ++++++++++- api/actions/nearbyplayers.php | 9 +++++++++ api/actions/sendchat.php | 9 +++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/api/actions/getchat.php b/api/actions/getchat.php index 59bec22..ab16b27 100644 --- a/api/actions/getchat.php +++ b/api/actions/getchat.php @@ -10,6 +10,15 @@ use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation; $userlocation = GeoLocation::fromDegrees($VARS["latitude"], $VARS["longitude"]); +// Update player ping/location +$database->update("players", [ + "latitude" => $VARS["latitude"], + "longitude" => $VARS["longitude"], + "lastping" => date("Y-m-d H:i:s") + ], [ + "accountid" => getRequestUser()->getUID() +]); + $radius = 2; if (!empty($VARS["radius"])) { $radius = min(10.0, $VARS["radius"] * 1.0); diff --git a/api/actions/nearbyplaces.php b/api/actions/nearbyplaces.php index 67ced69..10c828d 100644 --- a/api/actions/nearbyplaces.php +++ b/api/actions/nearbyplaces.php @@ -6,6 +6,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// Update player ping/location +$database->update("players", [ + "latitude" => $VARS["latitude"], + "longitude" => $VARS["longitude"], + "lastping" => date("Y-m-d H:i:s") + ], [ + "accountid" => getRequestUser()->getUID() +]); + $radius = 0.5; if (!empty($VARS["radius"])) { @@ -60,4 +69,4 @@ foreach ($nearby as $n) { ]; } -exitWithJson($geojson); \ No newline at end of file +exitWithJson($geojson); diff --git a/api/actions/nearbyplayers.php b/api/actions/nearbyplayers.php index 70b7b6b..313cfbe 100644 --- a/api/actions/nearbyplayers.php +++ b/api/actions/nearbyplayers.php @@ -10,6 +10,15 @@ use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation; $userlocation = GeoLocation::fromDegrees($VARS["latitude"], $VARS["longitude"]); +// Update player ping/location +$database->update("players", [ + "latitude" => $VARS["latitude"], + "longitude" => $VARS["longitude"], + "lastping" => date("Y-m-d H:i:s") + ], [ + "accountid" => getRequestUser()->getUID() +]); + $radius = 2; if (!empty($VARS["radius"])) { $radius = min(10.0, $VARS["radius"] * 1.0); diff --git a/api/actions/sendchat.php b/api/actions/sendchat.php index 8980a82..e710f48 100644 --- a/api/actions/sendchat.php +++ b/api/actions/sendchat.php @@ -19,4 +19,13 @@ $database->insert('messages', [ 'accountid' => getRequestUser()->getUID() ]); +// Update player ping/location +$database->update("players", [ + "latitude" => $VARS["latitude"], + "longitude" => $VARS["longitude"], + "lastping" => date("Y-m-d H:i:s") + ], [ + "accountid" => getRequestUser()->getUID() +]); + sendJsonResp();