View Full Version : PHP - Identify User's Continent?
akanevsky
12-31-2005, 11:38 PM
How can you identify user's continent via PHP? (ex: http://www.talkloud.net/forums/vbstats.php?s=&action=region)
Or maybe there is a country=>continent mapping database? Thanks.
Paul M
12-31-2005, 11:46 PM
Simple answer - you can't.
You could try a reverse dns lookup on their ip and see if it's a country based url (like xxxx.co.uk) - but if it's .net or .com you're out of luck.
You could also see if you can extract any language information from their browser user-agent, or possibly a bit of JS to check their pc locale - but there is no foolproof method.
akanevsky
12-31-2005, 11:50 PM
There is no "you can't" in this world. Every question has an answer.
As for this, simple and honest answer is "I don't know."
Now, there are databases which have the info.
My question is: Where can I get such database (for free)? Even if it's not PHP?
Paul M
12-31-2005, 11:54 PM
Even they are not perfect - they normally rely on ip to location lookups, but even that is not 100% accurate (even assuming you can get the users real ip). I'm afraid I don't know where you could get such a database.
akanevsky
12-31-2005, 11:56 PM
This is just for statistics, it does not need to be accurate. I making a stats hack, whose features are to be a rip off of Bane's vbstats hack which will apparently never be released... So I just want to know any method to replicate that.
EDIT:
I think I just found a nice database. I'll need to adjust its syntax to fit my needs... and I don't even think I'ma do it by hands. I'ma make me a nice lil php script that will do all the dirty work of syntax conversion for me ;)
Paul M
01-01-2006, 12:11 AM
Most stats hacks use the reverse dns lookup method - and assume .net and .com to be the USA. If you 've found a usable database then that would probably be better. :)
akanevsky
01-01-2006, 12:22 AM
Last time I checked, regular site visitors don't have a domain name associated with them ;) Happy new year btw!
soulfly
01-01-2006, 12:55 AM
ment you in postbit? or for every action the user does
baronvonwalz
01-01-2006, 03:39 AM
Well IP address blocks are reserved by various companies, which vary from area to area.
I suppose you could create a database in which it would analyze their ip and match it to a list of known IP address blocks, which would compare it to a list of blocks by country.
soulfly
01-01-2006, 05:30 AM
Psionic Vision, if you need an ip->country db let me know i have one *bg*, there are which includes the shortname of country and longname, but no continent info, you could add id by yourself, if needed->post here.
best regards, soulfly
firstrebel
01-01-2006, 09:23 AM
Of use?
http://www.codeproject.com/asp/geoip.asp
Bob
akanevsky
01-01-2006, 11:56 AM
Well IP address blocks are reserved by various companies, which vary from area to area.
I suppose you could create a database in which it would analyze their ip and match it to a list of known IP address blocks, which would compare it to a list of blocks by country.
I ain't that crazy, there are pre-existing databases, so I don't see the point to reinvent the wheel. ;)
Psionic Vision, if you need an ip->country db let me know i have one *bg*, there are which includes the shortname of country and longname, but no continent info, you could add id by yourself, if needed->post here.
best regards, soulfly
I already have an ip->country database which works perfectly.
BUT, post yours here, and I'll merge the two. :)
Of use?
http://www.codeproject.com/asp/geoip.asp
Bob
There's no download link :(
firstrebel
01-01-2006, 12:19 PM
There's no download link :(
It's all under these headings:
Prerequisite
(Updated 1.sep.03, new urls) You need the GeoIP database - http://www.maxmind.com/app/standard, and you need ADO 2.5 or later since GeoIP.asp uses the ADO Stream object to read the GeoIP database.
Installation
Download the GeoIP.dat database from MaxMind
http://www.maxmind.com/app/standard
Put GeoIP.asp, example.asp and GeoIP.dat in a catalog on your web server.
Test the installation by accessing the example.asp page
http://yourserver/path/example.asp
Bob
norwichcanary
01-01-2006, 01:00 PM
I ain't that crazy, there are pre-existing databases, so I don't see the point to reinvent the wheel. ;)
I already have an ip->country database which works perfectly.
BUT, post yours here, and I'll merge the two. :)
There's no download link :(
http://ip-to-country.webhosting.info
There is also this database that i have used in the past :)
akanevsky
01-01-2006, 01:13 PM
Thanks :) That db seems more updated that the one I have previously downloaded. Will have to make an importer, too, since it is updated often. ;) The only problem is, your DB does not contain the following info:
Capital, Currency, Continent.
But that's no problem, I'll have it merged with my database. ;)
I don't even know which is better.
http://www.ip2country.net/download.html -> Updated January 1st, 2006
http://ip-to-country.webhosting.info/node/view/6 -> Updated December 14, 2005
norwichcanary
01-01-2006, 02:02 PM
Thanks :) That db seems more updated that the one I have previously downloaded. Will have to make an importer, too, since it is updated often. ;) The only problem is, your DB does not contain the following info:
Capital, Currency, Continent.
But that's no problem, I'll have it merged with my database. ;)
I don't even know which is better.
http://www.ip2country.net/download.html -> Updated January 1st, 2006
http://ip-to-country.webhosting.info/node/view/6 -> Updated December 14, 2005
Would you be willing to share your importer code please?
I changed the table to contain a countryid as opposed to all the information to save disk space.
akanevsky
01-01-2006, 08:55 PM
Why do you need the imported code? But yes, maybe.
Are you the creator of that database?
EDIT: What do you use 3-symbol codes for?
EDIT2: Even though I made a converter, I decided to use a different database, that has separate files. The reason being is, I don't want to store ips in the database, and one csv file, even converted into an array, takes up megabyte or two. Which is too much to parse at once. The database I found isn't updated THAT often, but it has separate files, which is better in this case. Not too rare either, it has been updated in november :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.