Create function in your controller file..
and call this function like this in your controller.
This will give user's location based on its IP address.
<?php
function _get_location()
{
$country=file_get_contents('http://api.hostip.info/get_html.php?ip=');
$_country = explode ("\n", $country);
$_country = str_replace("City: ", "", $_country);
return $_country[1];
}
?>
and call this function like this in your controller.
<?php echo $this->_get_location(); ?>
This will give user's location based on its IP address.