First of all thanks to all ....
I read that i can use the free IP geolocation webservice to get Country name from an Ip address. But how i get the response to my site , Actually this is what i look , In my site there is a need of displaying the country name from Ip address. Can uou please tell in detail... How can i display the country Name from that site ..
geoip_country_code_by_name can give you the country for an arbitrary IP address or hostname (not just the one from the current visitor as apache_note("GEOIP_COUNTRY_NAME") does), it uses the same MaxMind database. There is also the geoip_country_name_by_name function if you want the full country name rather than the ISO code.
http://www.maxmind.com/app/php
You need to install the php module and then use the following code to get the country name:
$country_name = apache_note("GEOIP_COUNTRY_NAME");
Have checked this functionality in Oplim? It is free for up to 500k pageviews, and you can set your code and custom condition (country, or even areas such as all the EU).
Disclosure: I am among the service developers.
Related
I am trying to validate addresses input from users, where they give their street name, zip code, house number etc ...
The question is, how can I validate weather the address is valid?
The even better question would be, how can I check using the IP of the user, weather the input match the current country of the user or not, according to those informations I am gonna flash some validation errors.
Can I implement this in a Google Map for example?
Thanks
You can't.
There are simply too many edge cases, where addresses might seem wrongful, but are correct. Where I live some companies get their own zip code, also some roads do and some addresses does not have a town name.
If you want to be as precise as possible, you should ask the user to enter their address through a Google Maps auto complete field, as Google Maps knows a lot of the edge cases.
That being said, It's not accurate to check whether the users inputted address matches their origin country, as they can be behind a VPN. Also some IP addresses maps to another country than the user is actually in.
I have a database with user information (including IP Address) and I was wondering if it's possible to show the users location on a world map by getting the IP from the database in php?
Any help appreciated :)
To view the IP address of a visitor to your site, insert this code in the area where you want it to appear.
echo $_SERVER["REMOTE_ADDR"];
You can then use the API to locate your GeoLite MaxMind visitor
http://dev.maxmind.com/geoip/legacy/geolite/
It is possible to associate an IP address with a physical location, but only loosely. IP addresses are not registered to an individual user's exact location. You will be finding the location of the administrative domain of an IP address...but still on a world map that should be good enough.
Basically it works like this. You get a tool called geoip that should come packaged with a tool called geoiplookup. You then go to http://dev.maxmind.com/geoip/legacy/geolite/ to download GeoLiteCity.dat. Then you run this command.
geoiplookup -f /path/to/GeoLiteCity.dat <target IP or hostname>
For example, just now I ran
geoiplookup -f ~/Downloads/GeoLiteCity.dat stackoverflow.com
and I got this output
GeoIP City Edition, Rev 1: US, CA, California, San Francisco, 94107, 37.769699, -122.393303, 807, 415
Using this from PHP should be easy using the built in exec function from you PHP script.
I want a way to get the IP details like country name. I am getting the IP address using this code :
$_SERVER['REMOTE_ADDR'];
But I don't know how to get info of that IP.
IP address ranges are assigned to top providers that usually represent countries. The ranges are subdivided and sold to sub regions. This covers 90% of the case, although some ISPs can cover multiple countries, and addresses get bought and sold all the time. A commercial database is actively maintained. You may use such database (one example would be the MaxMind GeoIP database) to perform a reverse IP lookup. i.e. (IP -> geo division). There's no deterministic/mathematical way to look at the IP and "figure out" its origin. Location is not forwarded in the IP request.
I am wondering if it's possible to make my website only available to a specific country.
So anyone who tries to visit the website outside the specific country, will not have access.
I was thinking of getting a php IP Geo Locator script and do a redirect if they IP address is from the country I decide.
How would you guys recommend it?
Thank you.
EDIT
This doesn't have to be 100% accurate. Just need the php code that will do what I need.
The country is Romania by the way. Thanks! :)
The answer depends on what you mean by "available to a specific country".
What if an in-country computer has an IP address not on your list? That computer won't have access, but it's located in country.
What if an out-of-country computer has an IP address on your list? That computer will have address, but it's not located in country.
What if a router with an in-country IP address forwards requests from out-of-country? What if an in-country router is part of the TOR network?
What if a citizen leaves the country and wants to get access to your in-country web site from another country? The citizen will have an IP address not your list and will be denied access.
Until you define "available to a specific country" your question cannot be answered.
I am making a website that would allow users to post classified listings, buy/sell products etc. you can think of it as a limited version of Craigslist or oodle.com or something.
I want to automatically filter listings/results by user's city. How do I detect user's city?
There is MaxMind API that I could use to get city from ip address. Anything else?
Hmm.. what's the best way of implementing this? My site is going to be available in only 4-5 cities. If a user from outside of these 4-5 cities visits my site, I'd like to show "all" listings (that is, listings from all over US). Each of these cities have suburbs so I'd like to consider users from nearby suburb cities as part of my target city. How to code this? Should I look at the map and decide which suburbs to consider as part of target city or is there a way to decide target city + radius in miles/kms to be considered part of my target city?
Sounds like you want something like the GeoIP City service.
In my opinion maxmind is good tool for ip detection and mapping with location, Below you can read documentation and they have uploaded sample code too, so you can get help from that
http://dev.maxmind.com/geoip/web-services