Webmaster's Community
Designing and Development => Programming => Topic started by: Tayab on November 05, 2012, 01:50:34 AM
-
Hello folks. Since my past week I had been working on Block IP script and today I am done making and thought to share it with you guys, you can use it if you need it for sure. Although, it was a exercise question from the book I bought of JavaScript.
var ip = '<!--#echo var="REMOTE_ADDR"-->'
var bannedip=["70.76.50.65", "192.168.1.2"]
var handleips=bannedip.join("|")
handleips=new RegExp(handleips, "i")
if (ip.search(handleips)!=1){
alert ("You are banned from this website. Wait...")
window.location.replace("http://ifandbut.com")
}
-
Good luck, I can see you are going right way..
So when user is from bad IP ,he is redirect to ifandbut.com :)
-
Haha, Yeah that is the basic way of popularity, most of the programmers are always curious about websites so they will surely visit it if I'll post this script somewhere else. :)