Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
javascript to block ip address visiting my website
#1
Hello, Howi.In users,

Today I am going to post an interesting thread which helps you to block certain IP Address users visiting your site. Recently. I found an issue in My site that, I am getting extra 2000+ Traffic daily. I researched the IP which getting traffic to My site and I finally found the IP address. 

Now I got a solution for the problem. All We want to do that, Collect the IP address of the Spam IP address and paste it in a notpad.

Now follow the below step.

Code:
<script language=”javascript” type=”text/javascript”>

var blockedIP = new Array();

blockedIP[0] = “x.x.x.x”;
blockedIP[1] = “x.x.x.x”;
blockedIP[2] = “x.x.x.x”;

var ip = ‘<?php echo $_SERVER["REMOTE_ADDR"]; ?>‘;

for(var i=0; i<blockedIP.length; i++){

if(blockedIP[i] == ip){

alert(”you are not allowed to visit this site anymore”);
window.location = “[url=http://www.google.com%E2%80%9D;]http://www.google.com”;[/url]
break;

}

}

</script>


Paste the above code to your site and replace the xxxx with the IP Address that you need to block.

Thanks

If you have any kind of question, You can ask me on this thread.
Reply
#2
Ok, Got It, Thanks for sharing. This is very interesting information.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)