Mind Probe

Science Fiction, Handbells, Software Engineering, Physics

[powered by WordPress.]

10-April-2006

Blog Comment Spamming

by @ 10:07 am. Filed under Blogging

Over the last week, I have been receiving spam in the form of Blog Comments. Luckily, Canned Platypus (http://pl.atyp.us/wordpress/) recently posted how he cuts down on comment spam by adding a password field to the comment post webpage. The value of the password is listed on the Add Comment page and all a person has to do is type in the password in the Comment Password field. This should be beyond the capacity of spambots.


There are two files that need to be editted to enable the password requirement. The following are the steps that I took with modifying the WordPress 2.0.2:

  1. Edit the file wp-content/themes/journalized-blue/comments.php. Note, edit the comments.php file that is used by your blog; this may be in the journalized-blue, default, or classic subdirectory.
    • Find the <input … name=”author” id=”author” … > tag. This tag should be at the beginning of the else block.
    • At the end of the then block add the following tag:
    • <input type=”hidden” name=”spamalot” value=”skyhook” />
    • Back at the beginning of the else block, add a comment similar to the following:
    • <p style=”color: red”>
      To stop comment spam, I’ve added a password field for comments.
      The password is <strong>skyhook</strong> and should be entered into the
      comment password field below. This should take you no more than a couple of
      seconds and hopefully the spambots will not be able to deal with it.
      </p>
    • At the end of the else block add the following input and label tags:
    • <p><input type=”text” name=”spamalot” id=”spamalot” value=”"
      size=”22″ tabindex=”4″ />
      <label for=”spamalot”><small>Comment Password (see note above)</small></label>
      </p>
    • Save these changes.
  2. Edit the file wp-comments-post.php.
    • Find the PHP code that tests for an no comment error and calls die(“…”) if there is no comment.
    • After that if block, insert the following code:
    • $spamalot = strtolower(trim($_POST["spamalot"]));
      if ($spamalot != “skyhook“)
      {
      die(“Incorrect coment password. Please go back and read the comment in red if you are a real person, or send me an email if this is not working. If you are a comment spammer, please spam elsewhere or, better yet, stop spamming.\n”);
      }
    • Save changes.

It is as simple as that. Remember to save the original versions of these files in case you make a coding mistake.

Leave a Reply

To stop comment spam, I've added a password field for comments. The password is skyhook and should be entered into the comment password field below. This should take you no more than a couple of seconds and hopefully the spambots will not be able to deal with it.

[powered by WordPress.]

jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.

Get Firefox!

internal links:

categories:

search blog:

archives:

April 2006
S M T W T F S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

hearing:

other:

Quotes:

"The objection to fairy stories is that they tell children there are dragons. But children have always known there are dragons. Fairy stories tell children that dragons can be killed."
    — G.K. Chesterton

"Zoology, eh? That's a big word, isn't it"
"No, actually it isn't", said Tiffany. "Patronizing is a big word. Zoology is really quite short."

    — Terry Pratchett
         from "The Wee Free Men"

general links:

I read:

bloggy links

Science Fiction

Handbells

Friends and Family

Science Fiction Authors

35 queries. 2.109 seconds