Hi everyone. I have seen some sites that have restrictions on viewing video and such. Was wondering how its done and if we can do that with CF? I have some videos and files that i only want people in North America to view.
Thanks
I figured as much. I did done research since this post and found a site that gives a list like this....
Example:
24.51.64.0/18
24.206.0.0/19
24.231.32.0/19
24.244.128.0/19
24.244.160.0/21
24.244.168.0/23
Question i have now is how would i use this in cf? I know i can write a code like <cfif FORM.userip EQ qIPDB.ipaddress > which would allow them to view the videos and such, but those ip addresses have a / in them. Not sure what the / is for and how i would write something to compare the user ip to the db one with those slashes in them.
In order to implement it properly, you'd have to find/write some IP address utilities which actually get an IP address, convert it to binary, then match it up with the subnet mask to see if it's within those ranges. I've done it before, and it's rarely pretty.
Before you get involved in that I'd consider the worth - IP addresses change all the time, different ISPs run through different proxies and even here I have a VPN service I pay £5 a month for that can route me through hundreds of different countries should I so wish it to.
Reliable geolocation is extremely difficult to do, and every time I've seen it implemented it's caused as many issues as it's solved. If you do decide it's worth it though, I'd Google around to see if anyone's already written any IP address utils for ColdFusion.
It depends on why you don't want people watching the videos to be honest.
Don't get me wrong, if you want something basic like BBC iPlayer does to stop you watching it from the States, you just need to find an accurate listing of known US IPs and only accept those. However you do need to be aware that by no means is it a guaranteed system, so if it's because you're hoping to peddle anti-European propoganda, probably not the best idea ![]()
If you're running IIS7 there's a built-in IP address filter for doing exactly this, might be easier to use that than try and re-invent the wheel in ColdFusion, which will be far slower than the .NET Module in Integrated Pipeline mode that IIS uses.
Well some of the things i wanted blocked was videos and voting options that are for the N. American issues. I won't get to detailed, but the client doesn't want "outside" votes and such. I did tell him nothing is 100%, but he wants me to find some way. Not sure what i should do at this point.
As Dan says, the hardest part is getting an accurate listing. People in North America will become extremely frustrated if they're constantly being told they can't access it as they're in another country, even if they're not. Likewise, if they're important issues people can easily get round the restriction.
Essentially you have two choices - you restrict functionality "precisely" by only sending logins to the people you want to vote (which obviously means knowing the email addresses of everyone in N. America) or you do it as best you can by restricting by IP and hoping for the best.
If you do go down the latter route, you might want to consider how you block people. Simply throwing them a 403 not authorised page would be annoying, so I'd recommend at that point you perhaps have a CF-based 403 page which stores their IP details in a database and perhaps has a text box where they can enter their location, or perhaps you store their votes in a separate table or flagged as "not verified", until someone manually verifies that their IP address is in the US.
If you *really* wanted to be sure, I'd look into finding a Java Whois client (there are a few about you can get for free IIRC) and in the case someone's outside your restriction you can look up the Whois data for their IP address and simply parse it for the "US" part of the ISP's address or something like that. Obviously that's quite resource-intensive, so you'd only want to do it if they did fall outside your allow list, not on every hit. Also perhaps then have a table of whitelisted IPs so you don't have to re-check the Whois on every page load.
That's a brain dump of all my ideas anyway...
cf_junkie wrote:
Hi everyone. I have seen some sites that have restrictions on viewing video and such. Was wondering how its done and if we can do that with CF? I have some videos and files that i only want people in North America to view.
Get a Geo IP database. The best and most comprehensive ones come at a price. Once you buy, you will usually get updates free of charge, or at a small additional premium. Search the web and compare price, frequency of updates, quality of service, recommendations, and so on.
Remember, I said database. Then you have full control, and this enables you to perform fast look-ups for each visitor. I would strongly advise against any solutions, like web services, which require you to perform the look-up on somebody else's server.
North America
Europe, Middle East and Africa
Asia Pacific