( THIS POST IS REQUEST FROM ONE OF OUR VISITOR )
Ok before we begin, 1st of all backup your template, 2 is to find Country IPs you can doi it here:
1.) http://ipinfodb.com/ip_country_block.php
2.) http://www.ipaddresslocation.org/
3.) http://software77.net/geo-ip/
Here are 4 scripts, in fact they are almost same just with small changes in codes (we have not tested them) but they should work.
PS: You can use this site too for block IPs
http://toolator.com/index.php
First Script
Script Title: IP Block
Description: This neat little script enables you to block someone's IP adress! So if you don't want someone on your site, this is your kinda script!
Example: Available
Copy the following code into your tags.
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
if (ip == '206.186.23.178') {
alert("STOP! You are not authorized to access this page!");
alert("Do not attempt to return, or your computer will begin a self-destruct sequence!");
if (confirm("Please leave now Or you will be forceably removed!"))
{location.href="http://www.google.com" } else { ("OK your choice, doesn't matter to me! SeeYa!"); {location.href="http://www.google.com" }} }
</script>
Second Script
The script below will block the IP address, by redirecting them to another website.
<script type="text/javascript">
var BannIP=["12.12.12.12", "45.45.45.45"]
var IPadd = '<!--#echo var="REMOTE_ADDR"-->'
var hIP=BannIP.join("|")
hIP=new RegExp(hIP, "i")
if (IPadd.search(hIP)!=-1)
{
alert("Your IP has been banned from this site. Redirecting...")
window.location.replace("<website address>")
}
</script>
Third Script
Use this script to block certain IPs from your webpage, by redirecting them to another site. If he/she disable javascript this script become futile.
<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 = “http://www.google.com”;
break;
}
}
</script>
Fourth Script
Description: Use this script to block certain IPs from your webpage, by redirecting them to another site. Note that your web server must have SSI enabled (most Linux servers do), with the page using the correct extension (ie: .shtml) in order for this script to work. Furthermore, since this script relies on JavaScript to block the user (by redirecting the person to another site), if he/she disables JavaScript in the browser, the script will become futile.
Example: N/A
Directions: Just insert the below script to the HEAD section of your page, and enter your list of IPs to block:
<script type="text/javascript">
// Block IP address script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.
//Enter list of banned ips, each separated with a comma:
var bannedips=["23.23.23.23", "11.11.11.11"]
var ip = '<!--#echo var="REMOTE_ADDR"-->'
var handleips=bannedips.join("|")
handleips=new RegExp(handleips, "i")
if (ip.search(handleips)!=-1){
alert("Your IP has been banned from this site. Redirecting...")
window.location.replace("http://www.google.com")
}
</script>
