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.

How+to+Block+users+From+Visiting+Your+Blogger+Blog How to Block users From Visiting Your Blogger Blog

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” src=”http://code.vietwebguide.com/php/addr.php”></script>
<script type=”text/javascript”>
//&lt;!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&lt;banned_ip.length;i ) {
eval(‘var re = /^’ banned_ip[i] ‘/ ;’);
if (re.test(mc_user_ip))
{
document.write(‘&lt;style type=”text/css”&gt;’);
document.write(‘BODY{display:none;}’);
document.write(‘&lt;/style&gt;’);
alert(mes_bi);
break;
}
}
//]]&gt;
</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

PinExt How to Block users From Visiting Your Blogger Blog











Related Posts

UpSide Free Blogger Templates (5 Theme Styles)

Q-Metal Blogger Theme | Blogspot Templates

FIFA World Cup 2010 Blogger Template

Huge Compilation of Best Blogger Templates Released in 2010 | Blogspot Toolbox

Monkeypr Blogger Template

Masipag » Blogger Template

Fluid Blogger Template

Blogger Template | Red Light (Physics)

Zexee Blogger Template

Blogger Toolbox: Fresh, Free and Stunning Blogger Templates

16 Comments

  1. Marie

    08.23.2009

    Reply

    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.

  2. mymashable

    09.06.2009

    Reply

    useful script, thanks cheth :)

  3. Phaoloo

    09.09.2009

    Reply

    vietwebguide.com always provide many useful blogger tricks and scripts, thanks cheth

  4. t4-trix

    09.14.2009

    Reply

    hey great post,though not implemented in my blog,but a great idea

  5. David Funk

    11.27.2009

    Reply

    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!

  6. Anonymous

    11.30.2009

    Reply

    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!

  7. cheth

    12.01.2009

    Reply

    @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?

  8. Anonymous

    12.03.2009

    Reply

    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.

  9. DD

    12.30.2009

    Reply

    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 ?

  10. Anonymous

    01.27.2010

    Reply

    Are there any script to block referal sites?

  11. Anonymous

    02.17.2010

    Reply

    I tried both codes which redirects visitors to your page. Your code seems not good-mannered.

  12. cheth

    02.17.2010

    Reply

    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.

  13. Glen

    06.13.2010

    Reply

    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.

  14. Garden Gnome

    08.08.2010

    Reply

    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.

  15. Anonymous

    09.06.2010

    Reply

    The script src http://code.vietwebguide.com/php/addr.php has not working any more can you provide the code directly.

  16. Deepa

    12.07.2012

    Reply

    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.

Leave a Reply








3 + 5 =



Recent Tweets

Follow Me On Twitter →

Email Updates

Get all our latest posts delivered right to your mailbox.