Author Topic: Block IP Script - JavaScript  (Read 11963 times)

Tayab

  • Full Member
  • ***
  • Posts: 149
Block IP Script - JavaScript
« 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.
Code: [Select]
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")
}

Jaffery

  • Administrator
  • Full Member
  • *****
  • Posts: 158
Re: Block IP Script - JavaScript
« Reply #1 on: November 08, 2012, 03:36:45 PM »
Good luck, I can see you are going right way..

So when user is from bad IP ,he is redirect to ifandbut.com :)

Tayab

  • Full Member
  • ***
  • Posts: 149
Re: Block IP Script - JavaScript
« Reply #2 on: November 08, 2012, 11:17:28 PM »
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. :)

 

X

Do you know?

IfAndBut.com gives you a platform where you can ask questions related to web and internet..
So, why wait..
Join Now!
anything