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