Welcome to WebmasterWorld Guest from 54.225.6.131

Forum Moderators: open

Message Too Old, No Replies

JavaScript Question - blocking access by browser and IP

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

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:6520
votes: 114


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>

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 4, 2001
posts:1265
votes: 12


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. ;-)

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

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:6520
votes: 114


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.