<?php include_once '../../config.php'; //http://mkgalaxy.com/api/locations/iptocity.php try { $g = new world_Geography(); $ip = !empty($_GET['ip']) ? $_GET['ip'] : $_SERVER['REMOTE_ADDR']; $r = $g->iptocity($ip); $r2 = $g->get_nearby_cities($r['lat'], $r['lon']); $r['nearby'] = $r2; if (empty($r)) { throw new Exception('Empty Data', 2001); } } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r); if (!empty($_GET['jsoncallback'])) { echo $_GET["jsoncallback"] . "(" . $content . ")"; } else { echo $content; }
<?php include_once '../../config.php'; //http://world.mkgalaxy.com/api/cities.php?id=3469 try { $g = new world_Geography(); $id = !empty($_GET['dg_key']) ? $_GET['dg_key'] : 0; $r = $g->cityList($id); if (empty($r)) { throw new Exception('Empty City List', 2001); } $return = array(); $fieldSeparater = ' | '; foreach ($r as $k => $v) { $return[] = $v['city'] . ';' . $v['id']; } echo implode($fieldSeparater, $return); exit; } catch (Exception $e) { echo $e->getMessage(); }
<?php include_once '../config.php'; //http://world.mkgalaxy.com/api/states.php?id=223 try { $g = new world_Geography(); $country_id = !empty($_GET['dg_key']) ? $_GET['dg_key'] : 0; $r = $g->stateList($country_id); if (empty($r)) { throw new Exception('Empty State List', 2002); } $return = array(); $fieldSeparater = ' | '; foreach ($r as $k => $v) { $return[] = $v['state'] . ';' . $v['id']; } echo implode($fieldSeparater, $return); exit; } catch (Exception $e) { echo $e->getMessage(); }
<?php include_once '../config.php'; //http://world.mkgalaxy.com/api/nearby.php?lat=37.338475&lon=-121.885794&radius=50&limit=100 try { $g = new world_Geography(); $lat = !empty($_GET['lat']) ? $_GET['lat'] : null; $lon = !empty($_GET['lon']) ? $_GET['lon'] : null; $radius = !empty($_GET['radius']) ? $_GET['radius'] : 30; $order = !empty($_GET['order']) ? $_GET['order'] : 'distance'; $limit = !empty($_GET['limit']) ? $_GET['limit'] : 30; if (empty($lat) || empty($lon)) { throw new Exception('Empty lat or lon', 2002); } $r = $g->get_nearby_cities($lat, $lon, $radius, $order, $limit); if (empty($r)) { throw new Exception('Empty List', 2001); } } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r); if (!empty($_GET['jsoncallback'])) { echo $_GET["jsoncallback"] . "(" . $content . ")"; } else { echo $content; }
<?php include_once '../../config.php'; //http://world.mkgalaxy.com/api/locations/findcity.php?q=sunnyvale try { $g = new world_Geography(); $q = !empty($_GET['q']) ? $_GET['q'] : ''; $r = $g->findcity($q); if (empty($r)) { throw new Exception('Empty City List', 2001); } } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r); if (!empty($_GET['jsoncallback'])) { echo $_GET["jsoncallback"] . "(" . $content . ")"; } else { echo $content; }
<?php include_once '../../config.php'; //http://world.mkgalaxy.com/api/countries.php try { $g = new world_Geography(); $r = $g->countryList(); } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r); if (!empty($_GET['jsoncallback'])) { echo $_GET["jsoncallback"] . "(" . $content . ")"; } else { echo $content; }
<?php include_once '../../config.php'; //http://world.mkgalaxy.com/api/nearbycities.php?lat=37.338475&lon=-121.885794&radius=50&limit=100 try { $g = new world_Geography(); $lat = !empty($_GET['lat']) ? $_GET['lat'] : 0; $lon = !empty($_GET['lon']) ? $_GET['lon'] : 0; $radius = !empty($_GET['radius']) ? $_GET['radius'] : 30; $limit = !empty($_GET['limit']) ? $_GET['limit'] : 30; if (empty($lat) || empty($lon)) { throw new Exception('empty lat or lon'); } $r = $g->get_nearby_cities($lat, $lon, $radius, $order = 'distance', $limit); if (empty($r)) { throw new Exception('Empty City List', 2001); } } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r); if (!empty($_GET['jsoncallback'])) { echo $_GET["jsoncallback"] . "(" . $content . ")"; } else { echo $content; }
<?php include_once '../config.php'; //http://world.mkgalaxy.com/api/citydetail.php?id=1&nearby=1 try { $g = new world_Geography(); $id = !empty($_GET['id']) ? $_GET['id'] : 0; if (empty($id)) { throw new Exception('empty city id'); } $r = $g->cityDetail($id); if (empty($r)) { throw new Exception('Empty City List', 2001); } if (!empty($_GET['nearby']) && !empty($r[0])) { $lat = !empty($r[0]['latitude']) ? $r[0]['latitude'] : null; $lon = !empty($r[0]['longitude']) ? $r[0]['longitude'] : null; $radius = 30; $order = 'distance'; $limit = 30; if (empty($lat) || empty($lon)) { $r[0]['nearby'] = array(); } else { $r[0]['nearby'] = $g->get_nearby_cities($lat, $lon, $radius, $order, $limit); } } } catch (Exception $e) { $r = array('success' => 0, 'error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()); } //echo json_encode($r); $content = json_encode($r);