Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
03-22-2013, 09:13 PM #1
- Join Date
- Mar 2013
- Thanked 0 Times in 0 Posts
Need help with blocking content from specific IP's
So basically I need some help of where to start with this code. I need to write a script that will block content on a web page if someone is accessing it from a IP from specific countries.
More specifically I need to show certain products on my webpage if the consumer is accessing the page from Canada. I don't really know where to start but I imagine it might be something like this?
f IP address in Canada
show product 1
Show product 2
I prefer to use HTML & Java script
otherwise if anything else can be combined with HTML page it is fine with me
Any help would be awesome!
03-22-2013, 09:24 PM #2
- Join Date
- Apr 2012
- St. Louis, MO
- Thanked 101 Times in 101 Posts
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
03-22-2013, 09:25 PM #3
You will need an IP to location database or equivalent.
Also, these databases are not free. Only a few hundred dollars per year, depending on what features you want, but not something a hobbyist would normally use.
There are also so RESTFUL services out there that you could use, but I don't know of any that are free for more than a handful of queries per day.Be yourself. No one else is as qualified.
03-22-2013, 09:29 PM #4
Just for example, the ip2location database that we use has over 8 million records in it and is updated with from 50,000 to 100,000 changes each month.
The current count of records just for Canada is just under 150,000.
No practical way to put that much data into client-side code.Be yourself. No one else is as qualified.
03-22-2013, 10:40 PM #5
if all you need is the user's country name, you can use a free IP lookup like maxmind:
03-22-2013, 11:23 PM #6
Ahh...that's even simpler than the RESTFUL url that I had in mind.
Are there no "terms of service" though, for using that? Oh, never mind...I looked it up.
So staring May 1st, it's free if you give them attribution. But pretty darned cheap even if you don't.Be yourself. No one else is as qualified.
03-23-2013, 08:46 AM #7
- Join Date
- Jun 2002
- London, England
- Thanked 2,597 Times in 2,575 Posts
I have noticed a practical difficulty in identifying the country. Is the USA returned as US, USA, United States or what? The UK is returned as "United Kingdom". Is the country name returned with its English spelling or its proper name in the local language? Finland vs Suomen Tasavalta, etc. How can you find out unless you are in Finland? It would help if a list of the countries was shown!!
Perhaps you have to subscribe to find out!
Last edited by Philip M; 03-23-2013 at 10:09 AM.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
03-23-2013, 02:06 PM #8
Users who have thanked xelawho for this post:
Philip M (03-23-2013)