Forum Moderators: open

Message Too Old, No Replies

Javascript IP blocker

Previous post closed, have to reopen, plz help!

         

holodoctor1

7:56 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



Hi, I'm in desperate need of an IP address blocker javascript. I found this one on this site:
----------------------------------------
<!--#if expr="${REMOTE_ADDR} = /^ENTERIPHERE!/" -->
<script language="javascript">
alert("STOP! You are not authorized to access this page!");
alert("Do not attempt to return, or your computer will begin a self-destruct sequence!");
if (confirm("Please leave now Or you will be forceably removed!"))
{location.href="http://www.google.com" } else { ("OK your choice, doesn't matter to me! SeeYa!"); {location.href="http://www.getalife.com" }}
</script>
<!--#endif -->
----------------------------------------
which worked, but it blockes everyone's IP insted of just the ip address that is entered. I have entered a full Ip, not a range, so that can't be it...
If anyone has any ideas at all how to get this script working so it just blocks one ip insted of all of them, it would be a huge help. I've searched the web for others, and this is the only one that even comes close to working for me.
Thanks again!

post where I got the script from here:
[webmasterworld.com...]
please note, this post has been closed due to age.

RonPK

7:44 am on Aug 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi & welcome,

The line with <!--#if expr="${REMOTE_ADDR} isn't JavaScript but some sort of SSI (server side include) script. That means that your server has to be SSI enabled, and that you probably have to rename your page into somthing.shtml .

Using javascript to do things like this is like using sticky tape to secure your home. It may work, but it's very easy to hack. If possible, you should handle this on the server.

holodoctor1

8:08 am on Aug 13, 2004 (gmt 0)

10+ Year Member



Unfortunately, I use a free server to host my website (www.blogger.com). I don't have a root directory, so I have to enter javascript into my html editor. I'm pretty sure the person I'm trying to block doesn't know how to disable javascript, and would probably just give up when they were redirected.

If you know of a javascript fix for this, that would be immensely helpful.

Thanks very much!

RonPK

9:05 am on Aug 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, but client-side JavaScript simply cannot detect the visitor's IP address.

holodoctor1

8:26 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



drat.

Ok, thank you very much for your response :)

Gul_Dukat

6:42 pm on Aug 15, 2004 (gmt 0)

10+ Year Member



Hi,

holodoctor1, if that server you're using has SSI enabled you can try with this:

create a new document and paste this code into

var ip = '<!--#echo var="REMOTE_ADDR" -->'
if(ip == '127.0.0.1'){
location.replace('accessdenied.htm')
}

Change de ip, of course and the url you want to redirect

save it as ip.shtm

Now, in the pages you need to block that ip put this line into the document head

<script language="JavaScript" type="text/javascript" src="ip.shtm"></script>

If your server supports SSI it will work ;-)

greetings