Move lat/long validation to seperate file, add terrain data from gis
parent
31881d5e69
commit
3cc5cd9374
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
require 'required.php';
|
||||
require 'onlyloggedin.php';
|
||||
require 'latlong_validate.php';
|
||||
|
||||
$terrain = json_decode(file_get_contents("http://gis.terranquest.net/terrain.php?key=" . GIS_API_KEY . "&lat=" . $VARS['lat'] . "&long=" . $VARS['long']));
|
||||
|
||||
if (!is_empty($terrain['error'])) {
|
||||
sendError($terrain['error'], true);
|
||||
} else {
|
||||
$out = [
|
||||
"status" => "OK",
|
||||
"typeid" => $terrain['type'],
|
||||
"latitude" => $terrain['latitude'],
|
||||
"longitude" => $terrain['longitude'],
|
||||
"typename" => $terrain['name']
|
||||
];
|
||||
die(json_encode($out));
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?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);
|
||||
}
|
Reference in New Issue