adr = $address; $location->lat = ''; $location->lng = ''; $location->dst = ''; $location->id = ''; $row = dbGetRow("select * from df_locations where address='".dbEscape($address)."' limit 1 "); if($row){ $location->id = $row->id; $location->lat = $row->latitude; $location->lng = $row->longitude; $location->dst = getDbDistance($locationId, $location->id); } if(!$row and $_REQUEST['geosrc']=='db'){ list($city, $countrycode) = explode(',', $address); $row = dbGetRow("select * from df_geocities where city='".dbEscape($city)."' and countrycode='".trim($countrycode)."' order by population desc limit 1 "); if($row){ $location->lat = $row->latitude; $location->lng = $row->longitude; dbInsert('df_locations', array( 'address' => formatAddress($address), 'latitude' => $location->lat, 'longitude' => $location->lng, )); $location->id = dbGetInsertId(); } } $locations[] = $location; } echo json_encode($locations);