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); } $searchbounds = $userlocation->boundingCoordinates($radius, "miles"); ob_flush(); $people = $database->debug()->select("players", [ "accountid", "level", "nickname", "energy", "maxenergy", "latitude", "longitude", "teamid" ], [ "AND" => [ 'latitude[<>]' => [$searchbounds[0]->getLatitudeInDegrees(), $searchbounds[1]->getLatitudeInDegrees()], 'longitude[<>]' => [$searchbounds[0]->getLongitudeInDegrees(), $searchbounds[1]->getLongitudeInDegrees()], "lastping[>]" => date("Y-m-d H:i:s", strtotime("-1 minute")), "kick" => "" ], "LIMIT" => 100 ] ); $query = ob_get_contents(); ob_clean(); $people = $database->query($query)->fetchAll(); $nearby = []; $geojson = [ "status" => "OK", "name" => "Nearby People", "type" => "FeatureCollection", "features" => [] ]; foreach ($people as $person) { $geojson["features"][] = [ "type" => "Feature", "geometry" => [ "type" => "Point", "coordinates" => [ $person["longitude"] * 1.0, $person["latitude"] * 1.0 ] ], "properties" => [ "id" => $person["accountid"], "name" => $person["nickname"], "latitude" => $person["latitude"], "longitude" => $person["longitude"], "team" => $person["teamid"] ] ]; } exitWithJson($geojson);