Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is there a way to ban an IP from viewing the site? (2003)

    Just as the topic says. We have an unwanted guest who we want to keep out of our site. Is there a way to ban the person by thier IP or possibly with a cookie of some kind?

    At the very least, have them taken to a differnet page on our site, and nowhere else.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Is there a way to ban an IP from viewing the site? (2003)

    You can use server-side code to get the IP address using either .shtml or .asp pages. I'm not aware of any way to do it in pure HTML. One year I posted a prank on our web site that only was visible to internal users. I created an ASP page that calculated a simple "true/false" value for whether the IP address was matched (as a JavaScript variable declaration), and then imported that into the home page using a script source include. I then took a paticular action in client-side script based on that value.

    The downside with ASP is that it is inefficient: a connection object is created on the server and a cookie passed to the client, and this will slow the responsiveness of the page.

    I don't have that code handy any more, but if you don't find a simpler solution and your server supports ASP, you could ask the ASP gurus on the Web Development board for a hand.

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is there a way to ban an IP from viewing the site? (2003)

    Our server supports .asp, but I am not a programmer. I couldn't code my way out of a wet paper bag.

    Your idea sounds promising, but I wouldn't know where to begin.

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is there a way to ban an IP from viewing the site? (2003)

    Try Javascript! In fact, why not try The Javascript Source?
    <hr>JavaScript can prevent visitors with certain IP addresses from visiting your site.<hr>

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Is there a way to ban an IP from viewing the site? (2003)

    I didn't realize you could run Java code inline as part of java script:

    ip = "" + java.net.InetAddress.getLocalHost().getHostAddress ();

    Judging by how slowly my runtime seems to load, I wonder whether this will be worthwhile? I guess it's worth a test. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  6. #6
    Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is there a way to ban an IP from viewing the site? (2003)

    That is EXACTLY what I wanted!!!! Thanks guys!

    I wonder, though, if it still lets the visitor in if he doesn't have JAva enabled? I guess I'll hafta test it!

Posting Permissions

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