View Full Version : Can I add more Than One IP to This Script??
Lavergne
11-05-2002, 01:48 AM
Here It is...
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
if (ip == '206.186.23.178') {
alert("STOP! You are viewing this page from an IP address that is not allowed!");
alert("Why can't you guys just leave me alone?");
if (confirm("Do you want to leave peacefully? Or will I have to help you?"))
{location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
</script>
I would like to add as many IP's as possible...
JustAsking
11-05-2002, 01:58 AM
I think you could do it like this, use the key below the backspace (with shift button) on your keyboard.
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
if (ip == '206.186.23.178' || ip == 'ip address' || ip == '') {
alert("STOP! You are viewing this page from an IP address that is not allowed!");
alert("Why can't you guys just leave me alone?");
if (confirm("Do you want to leave peacefully? Or will I have to help you?"))
{location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
</script>
glenngv
11-05-2002, 02:03 AM
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
var arrIP = new Array("206.186.23.178","206.186.23.179");//add as many IPs as desired
for (var i=0;i<arrIP.length;i++){
if (ip == arrIP[i]) {
alert("STOP! You are viewing this page from an IP address that is not allowed!");
alert("Why can't you guys just leave me alone?");
if (confirm("Do you want to leave peacefully? Or will I have to help you?")) {
location.href="http://www.yahoo.com"
}
else {
alert("OK you choose I don't care! Bye bye! Don't come back!");
location.href="http://www.yahoo.com";
}
break;
}
}
</script>
Lavergne
11-05-2002, 02:40 AM
Thanks for your help script runs great...
joh6nn
11-05-2002, 01:26 PM
in my experience, this:
var ip = '<!--#echo var="REMOTE_ADDR"-->' ;
does not work. i'll bet that alert(ip) returns '<!--#echo var="REMOTE_ADDR"-->', and not a number.
if that's the case, then the way to get that value, would be this:
<form name="SSI" onsubmit="return false;">
<input name="REMOTE_ADDR" type="hidden" value="<!--#echo var="REMOTE_ADDR"-->">
</form>
document.SSI.REMOTE_ADDR.value;
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.