2011-06-03, 06:29 PM
So the current (v1.6.3) ModCP supports GeoIP lookups when you do an IP Lookup, but your host needs to support it on the server.
If that is not possible, you can easily add a few lines of code to the modcp.php file to get country and city from a hosted solution.
Open modcp.php and find:
and add below:
So when you click "(Information on This IP Address)" when searching IPs you can get GeoIP info when it is available, even if your host does not support GeoIP.
With the above "position=true" it also includes the lat/lon of the location. I have not included that in the above as it would require a template change. As it shows right now, it simply replaces the typical "n/a" output if you don't have GeoIP support on your server.
If that is not possible, you can easily add a few lines of code to the modcp.php file to get country and city from a hosted solution.
Open modcp.php and find:
// gethostbyaddr returns the same ip on failure
if($ipaddress_host_name == $mybb->input['ipaddress'])
{
$ipaddress_host_name = $lang->na;
}
and add below:
$api_result = @file_get_contents('http://api.hostip.info/get_html.php?ip='.$mybb->input['ipaddress'].'&position=true');
$each_line = explode("\n", $api_result);
for ($i=0;$i<count($each_line);$i++)
{
$line = explode(':', $each_line[$i]);
$data[$line[0]] = $line[1];
}
$ipaddress_location = $data['Country'].': '.$data['City'];
So when you click "(Information on This IP Address)" when searching IPs you can get GeoIP info when it is available, even if your host does not support GeoIP.
With the above "position=true" it also includes the lat/lon of the location. I have not included that in the above as it would require a template change. As it shows right now, it simply replaces the typical "n/a" output if you don't have GeoIP support on your server.