boo_lolly Posted August 1, 2009 Share Posted August 1, 2009 I'm trying to see how to write a script that can read the current user's IP, and reverse check to see the physical location (country, city, state, zip... whatever I can get) of the current user. I've seen a couple of sketchy sites that do it out there, already, but I need this information to be calculated on my server so I can store this information into a database, along with the IP address, simultaneously. So I was wondering, first, if it would be better to write this script on my own, or if I should use curl to communicate with one of the websites that can already does this. Second, how would I do either one of them? Not familiar at all with curl, and I'm not sure where to begin if I were to write it myself. The most useful of the websites I have found that do this is here: http://www.find-ip-address.org/ (it's pretty accurate. gets me within 10 miles of my actual current location.) Can I get some help with this? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted August 1, 2009 Share Posted August 1, 2009 You can retrieve the visitors IP address using $_SERVER variables, namely.. $ip=$_SERVER['REMOTE_ADDR']; Now that you have the IP you can query a database online that is updating to locate the IP to a physical region. If you check out the following link he explains how he implemented this onto his site. http://www.yougetsignal.com/tools/network-location/ Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted August 3, 2009 Author Share Posted August 3, 2009 I found a great deal of information from that link. Thanks! first, for a commercial ip/geo-locator service you can go to http://www.maxmind.com/app/geolocation which is known to be incredibly accurate. second, for a free ip/geo-locator service you can use a very simple http request using http://www.hostip.info/use.html . This website is not always accurate. however, when it encounters an ip that it can't locate, it requests the end user to provide their location. Don't you just love open-source? Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.