¿Cómo registrar IP por país en PHP?

how to determine which country the IP is coming from ? like e.g when a visitor came to a site, I can log the ip using

$_SERVER['REMOTE_ADDR'] , 

but that's all a combination of numbers, if let's say I want to log only the IP address coming from the US,AU,UK, or any other country that I want specifically, how to do that "without" using any database tables where the logger is hosted ?

preguntado el 02 de febrero de 12 a las 10:02

Try to google for ip country, you'll come up with results like this maxmind.com/app/geoip_country -

You "have" to use some kind of database to lookup the IP address against list of countries. -

You have to use a lookup API like ipinfodb.com. There is no mathematical order to the geo-location of IP addresses, the only solution is to use a lookup table, be that one you host your self or somebody else's. -

3 Respuestas

A nice web service for this is http://www.whoisxmlapi.com/.

You can get the data as XML or JSON and use the country attribute of the header.

Respondido 02 Feb 12, 15:02

You can use the IP to country mappings provided by Webnet77. The database contains about 100000 entries for various IPv4 blocks and can be downloaded in CSV format. You can later include that CSV in your logger script to find a country.

Respondido 02 Feb 12, 15:02

Look into using a geoip location service like Maxmind

respondido 15 nov., 12:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.