How to Block users From Visiting Your Blogger Blog
Some time you will notice that certain IP users are visiting and performing some unwanted ( spam ) activities. This can be tracked using a tracker placed in your website/blog. Then the noted IP can be used to block or literally ban users from visiting your blogger blog. This trick is Implemented using JavaScript and PHP.
Login into your Blogger Dashboard >Edit HTML
As I always say before attempting any tutorial or hack its wise to make a backup of your blogger template. So please download your blogger template.
Locate <head> in your blog template. And paste the following code just at the beginning of your blog’s <head> tag.
<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>
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 ’11.22.XXX.XXX’, simply add “11.22″ 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 website (exactly as it is given) instead of the code given above.
Thank you for reading: “How to Block users From Visiting Your Blogger Blog” You can also get a free subscription to Chethstudios updates. We will be back with more useful content. Get latest hacks and updates on your email















16 Comments
Marie
08.23.2009
I used the code to block the range, and she is still able to comment on my blog (she is a a psycho troll who now makes me moderate my comments.)
And when I enter the addresses into blogger, blogger automatically attaches an ampersand {&} and the number 39 before and after each address.
mymashable
09.06.2009
useful script, thanks cheth
Phaoloo
09.09.2009
vietwebguide.com always provide many useful blogger tricks and scripts, thanks cheth
t4-trix
09.14.2009
hey great post,though not implemented in my blog,but a great idea
David Funk
11.27.2009
Cheth, you have no idea how much time you have saved me with this. I tested it with my own IP to see if it will work, and it did. I had used Toolator before, but for some reason, it no longer works on my page.
Once again, your work and help for bloggers is appreciated! Thanks!
Anonymous
11.30.2009
oh HELP…. tried the code … saves fine without any error message but tried to test by blocking my own IP and it doesn't work!
I have some one I HAVE to block or shut down completely as they are taking my work! And I WON'T won't won't let that happen anymore!
cheth
12.01.2009
@Anonymous
It works, please check out the previous comment by @David Funk he too had this trick to work on his blog.. I think you did a mistake.. kindly let me know which is your blog?
Anonymous
12.03.2009
What about new control for user to block another users in blog site? I am tried to looking for plugin to help users to have good control to delete comment or block users, etc.
DD
12.30.2009
the first code didnt work for me so i went to the other site, used the second code at the bottom , and problem is , it worked to well lol , it redirected and banned everyone ! do u have a fix for it ?
Anonymous
01.27.2010
Are there any script to block referal sites?
Anonymous
02.17.2010
I tried both codes which redirects visitors to your page. Your code seems not good-mannered.
cheth
02.17.2010
update: this code used to work perfectly earlier… but it isn't working the desired way. I will try to work out a fix to it.
Glen
06.13.2010
Maybe you can get it's original source code from that page (http://code.vietwebguide.com/php/addr.php) and modified it, so i can place it on my desired host and redirect troll to my desired page, it helps me a lot in earlier time.
Your work and help for bloggers is appreciated! Thanks Cheth.
Garden Gnome
08.08.2010
Hey Cheth, I tried the code. If I put it right after the -head- it redirects everyone but if I put it after the meta tags in the head is block no one and I did test my IP but it didn't work. Using the corrected code for xml keeps giving an xml error. Please help.
Anonymous
09.06.2010
The script src http://code.vietwebguide.com/php/addr.php has not working any more can you provide the code directly.
Deepa
12.07.2012
Don’t you also need to change the src= part to replace the website in this code with your own website? I tried to use the code as given and only replaced the IP but it messed up my blog entirely redirecting it to the website mentioned in src. Fixing it was a bigger pain because I had to somehow stop the browser before it redirected and then had to remove the code. Please confirm. If so, I request you to mention it in the instructions where you talk about replacing IP, to also replace the src website.
There are no trackbacks to display at this time.