As always, it's not that simple implementing something that needs PHP in Blogger (blogspot.com) so I keep an eye on new Blogger hacks.
Recently I discovered a script on ChicaBlogger which allows users which on a blogspot.com blog to ban someone by his IP address. You can do this with JavaScript and PHP, by adding the following code at the beginning of your blog's <head> tag:
UPDATE: The script no longer works because the address which got the ip of the user (http://code.vietwebguide.com/php/addr.php) is now redirecting to another website. To remove the code from your template, click on edit template and then quickly click the stop button on your template... that should work.
Replace the IP ranges from the above code with the IPs of the visitors you want to keep out of your blog. Example: If you want to block all IPs in the range '66.45.XXX.XXX', simply add "66.45" as the IP number in the above code.
Note: if entering the above code into your template returns the following error: "XML error message: The content of elements must consist of well-formed character data or markup.", use the code from this location (exactly as it is there) instead of the one above.
Recently I discovered a script on ChicaBlogger which allows users which on a blogspot.com blog to ban someone by his IP address. You can do this with JavaScript and PHP, by adding the following code at the beginning of your blog's <head> tag:
<script type="text/javascript" src="http://code.vietwebguide.com/php/addr.php"></script>
<script type="text/javascript">
//<!CDATA[
// Banned ip script 2.0
//(C)2009 Anhvo
//homepage: http://vietwebguide.com
var banned_ip = new Array();
banned_ip[0] = '85.142';
banned_ip[1] = '22.98.69.1';
banned_ip[2] = '22.98.69.146';
banned_ip[3] = '85.78';
var mes_bi = "Your IP is banned so you cannot visit this website!";
for(var i=0;i<banned_ip.length;i++) {
eval('var re = /^' + banned_ip[i] + '/ ;');
if (re.test(mc_user_ip))
{
document.write('<style type="text/css">');
document.write('BODY{display:none;}');
document.write('<\/style>');
alert(mes_bi);
break;
}
}
//]]>
</script>
UPDATE: The script no longer works because the address which got the ip of the user (http://code.vietwebguide.com/php/addr.php) is now redirecting to another website. To remove the code from your template, click on edit template and then quickly click the stop button on your template... that should work.
Replace the IP ranges from the above code with the IPs of the visitors you want to keep out of your blog. Example: If you want to block all IPs in the range '66.45.XXX.XXX', simply add "66.45" as the IP number in the above code.
Note: if entering the above code into your template returns the following error: "XML error message: The content of elements must consist of well-formed character data or markup.", use the code from this location (exactly as it is there) instead of the one above.