Spomment stopper (I hope)
Sterling Camden
As I mentioned in a previous post (At least I’m splogworthy now), I have been having some trouble with spomments on my first blog entry, Blog 0. Sorry for the misnomer in that post — I have since learned that splogging is the practice of setting up a blog entry that contains spam links, whereas my poor blog entry has been subjected to “spam comments”. The wikipedia article doesn’t refer to the term “spomment”, but a quick
Google search for the term shows that it has indeed entered the blogging vernacular to represent the plight that my post shares with many in the otherwise merry old land of blog.
I could have enabled CAPTCHA, but since I don’t enjoy puzzling through my bifocals at those astigmatic characters I won’t subject my readers to that either.
Most of the spomments attaching themselves to my post contain a series of many links to other sites. I took a hint from Rogers Cadenhead’s blog, “Workbench” and decided to limit comments to containing no more than three url links. Since I’m using Marko’s muBlog, I had to acquire a little more knowledge of PHP than I possessed this morning. Here’s the code I used:
if (count($matches[0]) > 3) {
print_content(“Sorry, comment contains more than 3 URL links” );
}
else
Thank (insert Prime Mover of choice) that PHP supports PERL regular expressions. As you can plainly see, this expression searches (case insensitive) for all occurrences of “[url=", followed by anything up to a matching "]” (non-greedy), followed by anything up to “[/url]” (again, non-greedy). It places those in an array that is element 0 of the $matches array, and I use the count of that array to tell me how many were found. The PHP documentation I used seems to indicate that preg_match_all should return the number of matches, but that didn’t seem to work for me.
Anybody have any better ideas for stopping spomments?
Stop spomments! (say it ten times fast)
Posted in Blog Blog |
4 Comments » RSS 2.0 | Sphere it!




Interestingly, WordPress has a built-in link-limit capability for comment filtering, and the default setting moderates (holds back for moderation, that is) all comments with more than two links. I haven’t had any attempts to spam SOB show up yet in moderated comments.
Um. I hope the pseudomarkup this thing uses in comments works the way I think it does, else there’s going to be a mess of something where I meant to include a neat little link.
Looks like you interpreted the "bbcode" markup syntax correctly, apotheon. I’m thinking of rewriting this entire site in Ruby on Rails, but then I’ll have to host it myself or find another host for it, because my ISP stubbornly refuses to install Ruby. If I do that, I’ll probably change the comment box to enable limited HTML instead of using bbcode.
How do you like WordPress as a host? I haven’t investigated it. How customizable is it?
Thanks for stopping by.
I just added a link ("BBcode syntax" ) to the wikipedia entry for BBcode. I placed it at the end of the markup buttons above the comment text box. Hey, if apotheon was unsure, most keyboard jockeys wouldn’t make it around the first turn without a little help.
WordPress is pretty customizable. It actually provides an interface for editing the PHP and CSS files provided by the theme you use, which I found surprising (and good).
WordPress is in general a very good set of scripts for blogging. I’m finding some mild frustration with the way it turns complex formatting into presentation, and haven’t looked into how easy it is to fix that yet, but judging by what I’ve seen so far it shouldn’t be too bad. Among other things, though, I like the fact that it uses limited (X)HTML rather than BBcode, which should among other things make for an easier fix to the formatting problems.
It’s possible that the formatting issues are related to the theme rather than WP itself. I’ll see in due time, I suppose, when I get around to investigating the matter.