Skip to main content
May 9, 2012
Question

Prevent viewers outside N. America

  • May 9, 2012
  • 2 replies
  • 2562 views

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

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 10, 2012

    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.

    Inspiring
    May 9, 2012

    It is based on the requesting IP address.

    May 9, 2012

    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.

    Owainnorth
    Inspiring
    May 9, 2012

    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.