Page 1 of 2
IP to location
Posted: Thu Oct 14, 2010 4:33 pm
by thosecars82
Hello
I am trying to translate IP addressses into locations.
To begin with, I was looking for a good script to translate an IP address to city and using this script in a website X. I have not found any reliable one yet though.
Moreover, I just found a few websites which might be reliable for this purpose.
On one hand, since these websites do not make their code available I had thought of doing an http request to any of these websites, let's call it Y, in order to get the address corresponding to the IP.
On the other hand, from the point of view of the delay involved, I am not sure whether it would be a good idea this http request to a website Y in order to get content which would be used to display website X.
What do you recommend?
Thanks.
Re: IP to location
Posted: Thu Oct 14, 2010 4:35 pm
by John Cartwright
MaxMind has some free geoIp2City databases for download.
And no, it's not a good idea to make external requests on every load.
Re: IP to location
Posted: Thu Oct 14, 2010 4:36 pm
by thosecars82
John Cartwright wrote:MaxMind has some free geoIp2City databases for download.
And no, it's not a good idea to make external requests on every load.
Thanks for the advices.
Is that freeware?
I just forgot to mention that I was looking for the most reliable freeware option.
Re: IP to location
Posted: Thu Oct 14, 2010 4:41 pm
by John Cartwright
thosecars82 wrote:Is that freeware?
I just forgot to mention that I was looking for the most reliable freeware option.
Like I said,
free geoIp2City database
See
http://www.maxmind.com/app/geolitecity
When it comes to GeoIP and free, you have to throw accuracy out the window. They generally do not update their databases frequently, and by nature IP addresses change very frequently (as IP blocks are sold, shifting, etc., sometimes to completely different continents). I don't know what they mean by realibility, you I assume you meant accuracy, and in that case I already touched on that.
Re: IP to location
Posted: Thu Oct 14, 2010 4:42 pm
by thosecars82
John Cartwright wrote:thosecars82 wrote:Is that freeware?
I just forgot to mention that I was looking for the most reliable freeware option.
Like I said,
free geoIp2City database
See
http://www.maxmind.com/app/geolitecity
When it comes to GeoIP and free, you have to throw accuracy out the window. They generally do not update their databases frequently, and by nature IP addresses change very frequently (as IP blocks are sold, shifting, etc., sometimes to completely different continents). I don't know what they mean by realibility, you I assume you meant accuracy, and in that case I already touched on that.
Thanks for the info.
Yeah, accuracy is what I meant, and that is what I should have said from the beginning.
Re: IP to location
Posted: Thu Oct 14, 2010 4:42 pm
by John Cartwright
I guess I really didn't answer your question. But yes, MaxMind is probably the best "freeware" geoIP out there (beyond external services).
Re: IP to location
Posted: Thu Oct 14, 2010 4:58 pm
by thosecars82
John Cartwright wrote:I guess I really didn't answer your question. But yes, MaxMind is probably the best "freeware" geoIP out there (beyond external services).
Thanks. I believe you did answer my question pretty well. Now I gotta test it.
Andyou are right, first time you mentioned GeoLite City you said it was free.
Re: IP to location
Posted: Thu Oct 14, 2010 5:12 pm
by thosecars82
Can this GeoIP C API from
http://www.maxmind.com/app/c work in Windows instead of Linux? If that is the case, how could it be installed in Windows?
I just saw in
http://www.maxmind.com/app/php that to make this work in php, this GeoIP C API must be installed.
Thanks
Re: IP to location
Posted: Thu Oct 14, 2010 5:19 pm
by John Cartwright
Please read the docs more carefully before asking questions.
You are looking at the
pure PHP module. It involves simply placing the text file somewhere in your filesystem, and using the functions provided to interface with the database. This option does not involve any extensions or installations.
They do however offer PHP extensions and Apache modules for faster performance, but thats beyond what I'm willing to help you debug (just use their documentation).
Re: IP to location
Posted: Sat Oct 16, 2010 6:24 am
by thosecars82
Sorry for asking something that was written on the website.
Another question: do you know whether this GeoLite City is useful all over the world. I just asked because I saw the US word mentioned in the following paragraph. I still think it must be usefull no matter the IP's country except for the postal code and area code fields which mightl only work in the US.
"Product Summary: Determine country, state/region, city, US postal code, US area code, metro code, latitude, and longitude information for IP addresses worldwide. The downloadable database is available to established businesses only, please see the availability section below for details."
It seems as if it might only work for the US.
Thanks
Re: IP to location
Posted: Sat Oct 16, 2010 9:48 am
by John Cartwright
From my experiece, it works beyond North America, but the accuracy isn't all that great.
Re: IP to location
Posted: Sat Oct 16, 2010 11:45 am
by thosecars82
I'm getting this warning
Warning: fopen(./GeoIP.dat) [function.fopen]: failed to open stream: the file or the directory does not exist in ...
Any idea?
The code is
Code: Select all
<?php
include("geoip.inc");
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
and is being used inside of wordpress.
Thanks
Re: IP to location [SOLVED]
Posted: Sat Oct 16, 2010 12:16 pm
by thosecars82
thosecars82 wrote:I'm getting this warning
Warning: fopen(./GeoIP.dat) [function.fopen]: failed to open stream: the file or the directory does not exist in ...
Any idea?
The code is
Code: Select all
<?php
include("geoip.inc");
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
and is being used inside of wordpress.
Thanks
Solved. I just had to use getCWD() in order to set the proper path when calling fopen.
Thanks
Re: IP to location
Posted: Sat Oct 16, 2010 2:28 pm
by thosecars82
I got another question.
I got different results for the same ip when I used my script (GeoLite) in contrast with
http://phpweby.com/services/iplocation which should give the same result becuase this website states they also use the same database GeoLite.
Do you know why I might be getting different results?
Thanks
Re: IP to location
Posted: Sat Oct 16, 2010 2:30 pm
by John Cartwright
John Cartwright wrote:When it comes to GeoIP and free, you have to throw accuracy out the window. They generally do not update their databases frequently, and by nature IP addresses change very frequently (as IP blocks are sold, shifting, etc., sometimes to completely different continents). I don't know what they mean by realibility, you I assume you meant accuracy, and in that case I already touched on that.