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?
Уоркс фор ми пърфектли ! Тенкю, баба ! 🙂
Едно малко грубичко решение от моя страна: в wp-comments-post.php забранявам на ръка домейни, съдържащи определена дума (покер, виагра, левитра и т.н.). Ето така:
if ( strpos($comment_author_url, 'viagra') ) {
echo "I hate spammers! Die matafaka!\n";
exit;
}
Гадовете въобще не съумяват да си пуснат спамчето. И броят на ‘нежеланите коментари’ намаля драстично.
There is a an easier way to acheive this – just use WordPress own filter to block spam words. Certainly the people who used to comment here don’t often talk about drugs or play games of chances 🙂
Ха ха, ако искате аз да имам по 3500 спама в спамбокса 😛
Не ползвам акисмет и имам максимум по 10 на ден awaiting moderation, в добри дни 1-2.
Why don’t you submit your changes to Akismet developers 😉
@yovko: Err… because I don’t know how :), and because I never did it. But I guess it’s always first time there…
To be entirely honest, by the looks of the Akismet I think there is most likely “Akismet developer” (mind the singular), rather than developers :). But I’m most probably wrong, as usual 🙂
Това значи ли, че ще мога да оставям коментари сега?
@__Владо__: Че ти винаги си могъл да оставяш коментари :). Просто понякога те бяха, хм, поизтрити. Но мисля, че Акисмет обеща вече да не прави така и както виждаш – този коментар дори мина директно.
Е, днес пак ми се случи да изваждам 2-3 коментара от Акисмета, но… да се надяваме че с времето ще поумнее.
Аз мислех да го пипна леко така, че ако текста на коментара е на кирилица, то да не го брои за спам. Аз поне не съм получавал спам на кирилица. Е, то аскимет-а ми изловил умопомрачителните 92 спама до сега 🙂 (усещам ли завист :)) и нямам кой знае каква база за анализ. По същата причина и не ми е нужна за сега твоята модификация, но ще я имам предвид, ако (когато) някой ден ми се струпат камари със спам и ако аскимет-а до тогава не е поумнял или не са му направили достоен заместник.
Поздрави Ему
@Emu: Такава модификация я има, доколкото знам, в блога на Васил Колев.
При мен идват някакви спамове за руски сайтове на кирилица, но при всички случаи е едно добро начало. Регионализацията ни дава уникални шансове за борба със спама, които другите нямат.
@dzver, Валери, Emu: това работи, когато имаш материали само на български. Аз имам и такива на английски, в които се очаква коментарите да са на английски 🙂
@Doncho: Да научат български ! 🙂 Bulgarian Total Domination ! Шегувам се. Идеята беше, че можеш автоматично да пускаш коментари, които съдържат някакъв минимален набор от кирилични символи (преди да са налазили и руски спамери :)).