Welcome to WebmasterWorld Guest from 54.147.20.131

Forum Moderators: open

Message Too Old, No Replies

JavaScript Question - blocking access by browser and IP

     

keyplyr

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

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



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

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



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month