Du kannst nicht mehr als 25 Themen auswählen
Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
23 Zeilen
746 B
PHP
23 Zeilen
746 B
PHP
<?php
|
|
|
|
require 'required.php';
|
|
|
|
// Validate input
|
|
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
|
|
sendError("Missing information.", true);
|
|
}
|
|
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['lat'])) {
|
|
sendError("Latitude (lat) is in the wrong format.", true);
|
|
}
|
|
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['long'])) {
|
|
sendError("Longitude (long) is in the wrong format.", true);
|
|
}
|
|
|
|
// Round to 2 digits (approx. 1.1km)
|
|
$lat = number_format((float) $VARS['lat'], 2, '.', '');
|
|
$long = number_format((float) $VARS['long'], 2, '.', '');
|
|
|
|
$terrainid = $database->select('terrain', 'type', ["AND" => ["latitude" => $lat, "longitude" => $long]])[0];
|
|
|
|
$out = ["status" => "OK", "type" => $terrainid];
|
|
echo json_encode($out); |