Browse Source

Get worldwide chat messages by default when no radius specified

master
Skylar Ittner 2 years ago
parent
commit
600fe917e5
  1. 24
      api/actions/getchat.php

24
api/actions/getchat.php

@ -19,22 +19,24 @@ $database->update("players", [
"accountid" => getRequestUser()->getUID()
]);
$radius = 2;
if (!empty($VARS["radius"])) {
$radius = min(10.0, $VARS["radius"] * 1.0);
}
$searchbounds = $userlocation->boundingCoordinates($radius, "miles");
$where = [
"LIMIT" => 100,
"ORDER" => "time"
];
if (!empty($VARS["latitude"]) && !empty($VARS["longitude"])) {
$where["AND"] = [
'lat[<>]' => [$searchbounds[0]->getLatitudeInDegrees(), $searchbounds[1]->getLatitudeInDegrees()],
'long[<>]' => [$searchbounds[0]->getLongitudeInDegrees(), $searchbounds[1]->getLongitudeInDegrees()],
];
$radius = false;
if (!empty($VARS["radius"])) {
$radius = min(10.0, $VARS["radius"] * 1.0);
}
if ($radius != false) {
$searchbounds = $userlocation->boundingCoordinates($radius, "miles");
if (!empty($VARS["latitude"]) && !empty($VARS["longitude"])) {
$where["AND"] = [
'lat[<>]' => [$searchbounds[0]->getLatitudeInDegrees(), $searchbounds[1]->getLatitudeInDegrees()],
'long[<>]' => [$searchbounds[0]->getLongitudeInDegrees(), $searchbounds[1]->getLongitudeInDegrees()],
];
}
}
ob_flush();

Loading…
Cancel
Save