Hi,
I found the site hostip.info recently and have been using the api through php with success, posted this a few days ago but it got removed at the same time as some spam was !
have cut and pasted some parts from my php code below for you if it is of any help :
$ipadd = stripslashes($_SERVER['REMOTE_ADDR']);
$url = "
http://api.hostip.info/get_html.php?ip=".$ipadd."&position=true";
$result = file($url);
print_r($result);
does this make sense ?
If you have problems with that, can you try typing the part in
bold above into a web browser and adding an ip address, you can find your own using :
http://www.whatismyip.com, you can also compare results from other sites i.e.
http://www.melissadata.com/lookups/iplocation.asp On how to use the database that is downloaded, I had a look today for the first time and did a few queries :
This will work where a city is found, would need to make it an outer join if wanted to include results where no city could be discerned :
SELECT i4.ip, i4.country, i4.city, c.name country_name, c.code country_code, y.name cityname, y.state, y.lat, y.lng
from ip4 i4 , countries c, cityByCountry y
where i4.ip = (select min(i.ip)
FROM ip4 i
where i.ip >= {
enter your ip address as a number here} )
and i4.country = c.id
and y.country = i4.country
and y.city = i4.city
In fact, just take out references to the country city table to get country info only :
SELECT i4.ip, i4.country, c.name country_name, c.code country_code
from ip4 i4 , countries c
where i4.ip = (select min(i.ip)
FROM ip4 i
where i.ip >= {
enter your ip address as a number here} )
and i4.country = c.id
to get the number for the above query take the ip address e.g. 1.2.3.4 : so, 1 is the most significant byte, 4 s the least:
echo "((1*256+2)*256+3)*256+4" | bc {if your using linux/unix}
I also took the small script found at
http://www.hostip.info/use.html and added 2 more commands for my own use to get me details where I can't find them in hostip.info
called
findip.sh :
#!/bin/tcsh -f
lynx -dump
http://api.hostip.info/get_html.php?ip=$1 nslookup $1
whois $1 | egrep -i "country|city|state|longitude|latitude"
Hope that this is of some help.
When I have some time, I was going to create some mysql functions and procedure and upload them here.