Monday, September 27, 2010

Troll Bouncing



Okay, that may have worked. I guess I'll find out soon enough.

Recently, there's been someone I...haven't cared to listen to particularly. And so, I idly scooted around the internet and thereby learned that no, there isn't any good way to ban people from your blog when aforementioned-blog is hosted on Blogger. You can delete comments, screen comments, restrict comments to a certain group of people, but you can't--for example--slap a "COOTIES!" sticker on someone's IP address.

There's no good way to ban someone, but after some experimentation, I found a way. As I'll explain later, it's not particularly robust protection, but it may be better than nothing.

So here's how to quasi-ban someone so they can't view your blog:

~~~~~~~~~~~~~~~~~~~~
Troll Bouncing Instructions

1) You do need the troll's IP address, which is a pain because Blogger doesn't give it to you.

However, if you have a hit counter service such as StatCounter, you may be able to figure it out. First, check the time stamps on the blog comments your troll has made.

Next, go into the statistics of your hit counter service and try to figure out which commenter has visited your blog at the same time as all those comments were left. Unless you have a high traffic blog, you might be able to sort out who your troll is.

Once this is done, record their IP address. You will need it later.

2) Now you're ready to wield your ban-hammer, flimsy as it is. To do so, you will need the following code:
~~~~~~~~~~~~~~~~~~~~

<!-- BEGIN TROLL BOUNCING -->
<script src="http://www.jjdebenedictis.com/ipnab.php"></script>
<script>
var ip=getip();
if (ip=="xxx.xxx.xxx.xxx")
{
window.location="http://www.dailysquee.com";
}
</script>
<!-- END TROLL BOUNCING -->

~~~~~~~~~~~~~~~~~~~~
Just so you know what this does, the first line returns a function containing your blog visitor's IP address via a bit of code on my personal website. (If my website goes down, this fix will stop working.) The rest of the code tests to see if the person visiting your blog has the same IP address as the troll, and if so, it bounces them to another website.
~~~~~~~~~~~~~~~~~~~~

3) Now log in to blogger and go to your "Dashboard" (where all the controls are.)

Up at the top, click on the "Design" tab, then click "Edit HTML". (See the image below.)



4) You see that heading that says "Backup/Restore Template"? I recommend you click "Download Full Template" and save the file to your computer before proceeding. That way, if something goes wrong and your blog gets borked, you can restore it by uploading the saved file.

5) In the section labelled "Edit Template", look in the code for the <head> tag. Once you've found it, insert a few spaces just after it and then paste in the code from Step (2) above.

6) Now: See the little xxx.xxx.xxx.xxx in the code? You have to replace that with the IP address of your troll.

By the way, if you want to ban more than one person, you would replace

if (ip == "xxx.xxx.xxx.xxx")

with

if (ip == "xxx.xxx.xxx.xxx" || ip == "yyy.yyy.yyy.yyy")

for two trolls or

if (ip == "xxx.xxx.xxx.xxx" || ip == "yyy.yyy.yyy.yyy" || ip == "zzz.zzz.zzz.zzz")

for three trolls (and so on), where the x's, y's and z's get replaced by IP numbers.

7) I recommend you preview the page just to make sure things look normal. Remember, the only person who is supposed to see something weird is the troll. Everyone else, including you, should just see your regular old blog.

8) If everything looks completely normal, save the changes and log out. Your troll has hopefully now been bounced.

(By the way, if you leave the IP address as xxx.xxx.xxx.xxx, then no one is going to trigger it, i.e. you can put the code in now and defer adding an IP address until you have someone you want rid of.)

9) If you want to test the code is working, put your own IP address into it and try to get to your blog. If you can't, then hurray! The code works. Go back into your blogger dashboard (which you won't be blocked from) and delete your IP address from the code to restore your access.
~~~~~~~~~~~~~~~~~~~~

So what exactly, you ask with concern, is the troll going to experience? After all, we are kindly, moral creatures here and would not wish harm upon our trolls.

Well, when they try to view your blog, they will instead get taken to The Daily Squee, where they can frolic among photos of adorable puppies and kittens. (Or eat them. I don't know. Whatever trolls do when they're confused.)

Okay, now the caveats.

This form of banning is stupidly easy to evade. For obvious reasons, I won't explain how to do it here, but anyone with even a modest understanding of how these things work can get past this sort of defence in five seconds flat.

Furthermore, some people's systems are set up in such a way they won't even notice you've done this.

So this isn't a good way to handle smart trolls, but thankfully some of the more obnoxious ones don't fall into that category. As long as they also fail to be lucky trolls, you're cooking with diesel.

Second caveat: Even if this works, someone who reads your blog via an RSS feed probably can still view your blog contents that way. They just can't show up and leave comments anymore.

Third caveat: As those who know how to get around this can attest, your troll may find that some of the time it can access your blog and sometimes it can't. With more hit counter snooping, you may be able to block their other means of entry.

One last note: The code should work on any HTML based webpage including blogs not hosted on Blogger. Just make sure you put the code right after the <head> tag and substitute in the troll's IP address correctly.

Happy Troll Bouncing!


PS - Brave New World, who recently left blogging due to trolls, suggested a very elegant alternative to the method mentioned above. It prevents the troll from accessing the comments form, but not from reading your blog. The troll might even be fooled into thinking the problem is with Blogger! This method is a little harder to implement, but here's how to do it:

1) Go into your template. Make sure to click the "Expand Widget Templates" option.

2) Do a search for "comment-form". Change <div class='comment-form'> to <div class='comment-form' id='comment-form'>.

3) Add the following script AFTER the <!-- end outer-wrapper --> comment:
~~~~~~~~~~~~~~~~~~~~

<!-- BEGIN TROLL BOUNCING -->
<script src='http://www.jjdebenedictis.com/ipnab.php'/>
<script language='javascript'>
var ele = document.getElementById("comment-form");
var ip=getip();
if (ip=="xxx.xxx.xxx.xxx")
{
ele.style.display = "none"
}
</script>
<!-- END TROLL BOUNCING -->

~~~~~~~~~~~~~~~~~~~~

4) Of course, change the "xxx.xxx.xxx.xxx" to whatever IP address you want to block from commenting.


PPS - Oh, and, um, if you're specifically having trouble with this person, email me at jen_deben ~at~ yahoo ~dot~ ca and I can give you their IP address.


Author website: J. J. DeBenedictis

Pageloads since 01/01/2009: