distancefinder/get-location1.php
2016-05-24 00:51:25 +02:00

28 lines
721 B
PHP

<?php
require_once 'bootstrap.php';
@unlink(DISTANCES_FILE);
$location = new stdClass;
$location->adr = trim($_REQUEST['address']);
$location->id = '';
$location->lat = '';
$location->lng = '';
$row = dbGetRow("select * from df_locations where address='".dbEscape($location->adr)."'");
if(!$row and $_REQUEST['geosrc']=='db'){
list($city, $countrycode) = explode(',', $location->adr);
$row = dbGetRow("select * from df_geocities where city='".dbEscape($city)."' and countrycode='".trim($countrycode)."' order by population desc limit 1 ");
}
if($row){
$location->id = $row->id;
$location->lat = $row->latitude;
$location->lng = $row->longitude;
}
echo json_encode($location);