homepage Welcome to WebmasterWorld Guest from 54.197.215.146
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JavaScript Question - blocking access by browser and IP
keyplyr




msg:1482568
 8:31 am on Mar 1, 2002 (gmt 0)

Found this while surfing. Oddly enough, I had been looking for a way to exclude a certain group of repeat trouble makers. Does this script also work in IE?

<SCRIPT LANGUAGE="JavaScript">
netscape = (navigator.appName.indexOf("Netscape") != -1);
version4 = (navigator.appVersion.indexOf("4.") != -1);

if (netscape && version4) {
ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
if (ip.indexOf("XXX.XX.XXX.XXX") >= -1)
// This would block anyone from XXX.XX.XXX.XXX

{
alert("YOU are NOT permitted to access this site.");
history.go(-1);
}
}
// End -->
</script>

 

IanKelley




msg:1482569
 8:06 am on Mar 2, 2002 (gmt 0)

If you want it to work for all browsers, just remove the browser detection part of the code entirely.

That said, here are the reasons why it's pretty much useless:

-All someone that your site isn't allowing has to do is turn off javascript and try again.

-If you run a similar script using a server side script to avoid this problem then they can get around it by using any of the free anonymizers out there.

-Blocking an IP doesn't really work for dial up users because most are assigned a different IP each time they log in. This means that they're going to be able to access your site the next time they log in and somone else is going to get assigned the IP address you banned.

-You can get around this problem by blocking the IP at a higher level (i.e. xxx.xxx.xxx) but that, of course, doesn't solve the anonymizer/proxy problem. Also if your problem user is using, say, Earthlink, blocking at a higher level is going to ban a pretty large chunk of the internet.

Just so ya know. ;-)

keyplyr




msg:1482570
 9:00 am on Mar 2, 2002 (gmt 0)

Thanks Ian

I have re-thought the methodology and have just disallowed the IP (webtv, now called msntv) for the particular directory they were abusing.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved