$ip = $_SERVER['REMOTE_ADDR']; 
  $this->data['ip'] = $ip; 
  $doc = new DOMDocument();  
  $url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20pidgets.geoip%20where%20ip%3D'" . $ip . "'&diagnostics=true&env=http%3A%2F%2Fdatatables.org%2Falltables.env";
  $xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
  $city =  $xml->xpath("/query/results/Result/city");
  $this->data['city'] = $city;
  echo $city;