Leaner Akismet Management Page
My Akismet saga will never end. That’s the conclusion, which I achieved today, looking at the 3650 comments, which Akismet claimed as spam.
Few weeks earlier I had very bad experience with Akismet, because it was keeping to mark non-spam messages as such. And I eventually lost some of them into the huge pile of spam, which I daily receive. After that point I started to consider disabling Akismet, but the spammers brought me back in the reality quite fast… with one 5000 spam comments per hour pick.
After that point it was clear – Akismet will stay for a while. But how do I manager better (and most important – faster!) the daily spam heap? That was the question, which was bothering me again and again.
If you happen to have blog with Akismet protection, you will know that it displays the spam comments in a list of 50 messages/screen. This can be quite frustrating in the cases where you have 3500 messages to handle, because first – it does not have the “next/prev” page links at the bottom of each page too, and second – because 3500 spam comments fit “nicely” into about 70 pages.
I was not able to handle all that today, so I decided to make some changes. First I started with changing the amount of messages per page. That was easy – just found the magic number (yes, it’s a magic number) 50 and replaced it with variable, which had value of 500. So far – so good.
But now I hit another problem. The page become way too long to handle. “cialis”, “viagra” again and again and forever. Now, if you have had issues with that many spam messages, you usually develop the ability to judge the “spamness” of the message only by looking at the author and/or the reference link s/he provides. I mean, I don’t have much people who I care about and who sign also as “big cock mothefuka” in my comments section. Right?
So the next task was to develop a nice addition to Akismet, which will hide all bodies (with the “not spam” little form) and display only the person, it’s link and the IP address. That way I was expecting to see a nice table and to be able to browse through the comments much faster. If I need the body of a specific comment, the only thing I have to do is to click the expand/collapse link.
Surprisingly, it all happen much easier than I was expecting. Now I’m happy owner of Akismet management page, which looks like this:

If you want the same result, you can achieve it in these easy steps:
1. Locate and backup your akismet.php file. It should be located at “…/content/plugins/akismet” directory of your WordPress installation
2. Now when you have done that, find the function “ksd\_caught”. It’s a long function, but inside there you must find the place, where comment list generation occurs. The easiest way is just to look for this text: “<p><strong><?php comment\_author”, but it can be different across the different Akismet verstions.
3. Now after you found the text above, copy this text into the clipboard:
<a href="#" onclick="var content = this.parentNode.parentNode.getElementsByTagName('div')[0];if (content.style.display != '') { content.style.display = ''; this.innerHTML='[-]'; } else { content.style.display = 'none'; this.innerHTML='[+]'; }; return false;">[+]</a>
4. Paste the code __between__ the <p> and the <strong> in (2)
5. Now find the text “<?php comment\_text() ?>”. It should be just few lines after the text (2).
6. Copy and paste the code below __before__ the text in (5)
<div style="display:none;">
7. Now find the code
<?php
}
}
8. Copy and paste the code below __before__ the code in (7):
</div>
After all, the picture should look like this:

Please note that some browsers might trick you, if you copy/paste directly from here. They might provide you with incorrect symbol for “double quotes”, especially if you have non-US locale, which has different opening and closing double quotes. If that happens, PHP will not understand your “sense of humor” and will award you with interesting, hairy error messages. To avoid all this pain, you must ensure that your the browser correctly copied to the clipboard the double quotes. The best way to check this is by pasting the copied text in Notepad or similar text editor, where usually you can immediately tell if the double quotes are the correct ones. But in general you should care about all this only if you do not succeed with the integration as I described it, or if you’re _sure_ that you have the incorrect double quotes.
At the end, after saving the file and loading your Akismet spam management page, it all should work as described. And I think you will love it!
If you’re interested in the “lazy” way of (not)doing all above, you can use this file, where I placed the following:
* akismet.php – Akismet 1.2.1 with the code changes integrated (it also includes my modifications for 500 comments per page, which is not described above)
* akismet.old.php – Akismet 1.2.1 before I started to apply the changes, described here (but it already contains the 500 comments per page change)
* akismet.new.php – Akismet 1.2.1 after the changes. This is actually identical to akismet.php, which is included only for convenience of the lazy people, who would not like to rename this file :).
Questions? Comments? Concerns?
