Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Trying to block a range of IP address

    I found a trick little script to block an indivual IP address. However the offender that I'm trying to block access to my web site has an ip address within a range.
    I want to either be able to block the entire range or a easy way to list the 8 or so known IPs I want to block.

    <script language="javascript">
    var ip = '<!--#echo var="REMOTE_ADDR"-->'
    if (ip == '206.186.23.178') {
    alert("STOP! You are viewing this page from an IP address that is not allowed!");
    {location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
    </script>

    Trying to block 209.255.8.30 thru 209.255.8.40

    I'm am very new to all of this so any and all help will be great!
    Thanks!!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    the person still can view your page by turning javascript off, it is better to do this all on the server side,.....

    but here is what you asked for.....

    Code:
    var ip = '<!--#echo var="REMOTE_ADDR"-->'
    ipParts = ip.split(".");
    if(parseInt(ipParts[3])>=30 && parseInt(ipParts[3])<=40){

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks so much for the quick reply, but where do I place this inside the original script. Or is this the entire script as is?

    You said I should turn it off on the server side. What does that mean and how is it accomplished. I just curious really. The person I'm blocking isn't very bright and would unlikely know to turn off the java script. I didn't even know it would do that.

    This script you provided, will this only block the IP address I mentioned and allow all others to enter?

    Thanks

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    <script language="javascript">
    var ip = '<!--#echo var="REMOTE_ADDR"-->';
    ipParts = ip.split(".");
    if(parseInt(ipParts[3])>=30 && parseInt(ipParts[3])<=40){
    alert("STOP! You are viewing this page from an IP address that is not allowed!");
    {location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
    </script>

    you just needed to add it where th if staement was...all i am saying if you would use a server side code, asp or jsp you would not have to worry about the person turing off their javascript in their browser.

    This willwor for the range you specify....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •