distancefinder/get-location1.php

28 lines
721 B
PHP
Raw Normal View History

<?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);