Block entrance depending on IP address script

liunx

Guest
Hi,<br />
<br />
I want to block entrance to my site depending on IP address. I have found this script below, i added it to my index.htm file (my website is made up of frames by the way) but it seems to block everyone out!<br />
<br />
Can you tell me if this script will work or not please.<br />
<br />
<head><br />
<script language="javascript"><br />
var ip = '<!--#echo var="REMOTE_ADDR"-->'<br />
if (ip == '206.186.23.178') { <br />
alert("STOP! You are viewing this page from an IP address that is not allowed!");<br />
alert("Why can't you guys just leave me alone?");<br />
if (confirm("Do you want to leave peacefully? Or will I have to help you?"))<br />
{location.href=http://www.htmlforums.com/archive/index.php/"http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href=http://www.htmlforums.com/archive/index.php/"http://www.yahoo.com" }} } <br />
</script><br />
</head><br />
<br />
What must I do, to make it work correctly.<br />
<br />
Many Thanks in advance.<br />
<br />
P.S. It's for use in IE browser, but use in Netscape would be good too. Cheers.<!--content-->this line should have a semi-colon on the end I believe, see if that helps:<br />
<br />
var ip = '<!--#echo var="REMOTE_ADDR"-->'<br />
<br />
its not good protection anyway, easy to get around javascript, look into using htacess if your webhosting service allows it.<br />
<br />
Kevin<!--content-->Hi,<br />
<br />
I tried your suggestion of adding ";" but it didn;t make a difference.<br />
<br />
Any ideas anyone?<br />
<br />
btw, what this htacess? my webhoster does allow it so how can i use it?<br />
<br />
cheers<!--content-->Originally posted by uniquetouch <br />
btw, what this htacess? my webhoster does allow it so how can i use it?Read this stuff:<br />
<br />
- <!-- m --><a class="postlink" href="http://www.perlaccess.com/odc/tutorials/File_and_Directory/Htaccess/">http://www.perlaccess.com/odc/tutorials ... /Htaccess/</a><!-- m --> <br />
- <!-- m --><a class="postlink" href="http://baremetal.com/gadgets/htaccess/">http://baremetal.com/gadgets/htaccess/</a><!-- m --> <br />
- <!-- m --><a class="postlink" href="http://home.golden.net/htaccess.html">http://home.golden.net/htaccess.html</a><!-- m --><!--content-->
 
Back
Top