My Spamgarden

SpamgardenSpamgardenis a wordpress plugin to display your comment-spam in a fun way. It takes random words from your recent comments that were marked as ’spam’, and uses them as fertilizer to grow your own private Spamtree.” Kewl … if it only would work for everyone immediately after installing.

So I installed it when it was released a while back and noticed that the thing didn’t work. Problem is – after investigating it a bit – that Netlash (the developers of the plugin) did not take in account that wordpress can have its own directory … Well, they partially did …

In the spamgarden.php file they – correctly!! – used get_bloginfo(‘wpurl’) which gets the WordPress address URI instead of get_bloginfo(‘url’) which gets the Blog address URI, as explained in the codex.

The problem however is situated in the words.php file and this due to the fact that get_bloginfo(‘wpurl’) is not available there, as it directly is called by the spamgarden.swf file.

One line 3 you’ll find this tiny piece of code, which tries to include the wp-config.php file:

if ( !file_exists( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php') ) {

Problem with $_SERVER[‘DOCUMENT_ROOT’] is that it gets the document_root (duuuh!), which is something like /home/username/public_html

If you have wordpress in its own directory, for example lets name it /wp2 the wp-config.php would be located in /home/username/public_html/wp2

So what’s the solution then? Simple, instead of getting the document root (from which we’ll never will know where wordpress is to be found) we’ll get the directory of the words.php file and then go 3 levels up (that is if you correctly installed spamgarden into /wp-content/plugins/spamgarden/)

In php code, this results in this piece of code here:

dirname(__FILE__)."/../../../"

Summaring it all into a tiny howto:

  • Open up wp-content/plugins/spamgarden/words.php
  • On line 5 replace $_SERVER[‘DOCUMENT_ROOT’] with dirname(__FILE__).”/../../../”
  • On line 8 replace $_SERVER[‘DOCUMENT_ROOT’] with dirname(__FILE__).”/../../../”
  • Upload your edited words.php file to wp-content/plugins/spamgarden/

Now y’all enjoy this inventive/original/fun plugin!

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

2 Comments

  1. having problems, whats to be inserted:

    a)dirname(__FILE__).”/../../../”
    b)dirname(__FILE__).\”/../../../\”

    could you mail me your modified file?

    thx

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.