{"id":1123,"date":"2013-05-22T09:07:10","date_gmt":"2013-05-22T07:07:10","guid":{"rendered":"http:\/\/www.greenman.co.za\/blog\/?p=1123"},"modified":"2013-05-22T09:07:10","modified_gmt":"2013-05-22T07:07:10","slug":"wordpress-spam-akismet-and-cookies-for-comments","status":"publish","type":"post","link":"https:\/\/www.greenman.co.za\/blog\/?p=1123","title":{"rendered":"WordPress spam, Akismet and Cookies for Comments"},"content":{"rendered":"<p>This blog gets about 1 spam comment a second.<\/p>\n<p>Not bad for an obscure blog with, as I write this, only one post open for comments.<\/p>\n<p><a href=\"http:\/\/wordpress.org\/plugins\/akismet\/\">Akismet<\/a>, the spam plugin does a great job of keeping the spam out, although recently a few more spam posts have been sneaking through for moderation, perhaps two a week. Still considering I get about 600 000 spam comments in that week, a miss ratio of 1 in 300 000 is rather exceptional.<\/p>\n<p>The volume of spam shot up markedly after <a href=\"http:\/\/www.greenman.co.za\/blog\/?p=1068\">this post<\/a>, which in retrospect, isn&#8217;t so surprising, since it contains every about spam phrase out there.<\/p>\n<p>A feature I&#8217;d like to see in WordPress is the ability to automatically delete spam after a certain period. Apparently this is automatically set to one month, but since in that month I&#8217;d get about 2.5 million posts, and have to up the space on my backup server, I prefer to delete spam posts manually a little more often than that.<\/p>\n<p>Deleting spam posts isn&#8217;t entirely smooth. If the number is too large, the script times out and I have to re-run a number of times. Since the spam arrives so quickly, I never have an empty spam folder, as by the time the deletion has happened, but before the page reloads, there&#8217;s normally a couple more posts.<\/p>\n<p>After coming back from the weekend to 40 000 spam posts, I decided to look for a solution. It&#8217;d be easy enough to adjust the period in the code manually, but since I&#8217;d have to re-implement the change each time I upgraded, I prefer to look for an existing solution.<\/p>\n<p>Enter <a href=\"http:\/\/wordpress.org\/plugins\/cookies-for-comments\/\">Cookies for Comments<\/a>. The solution is simple &#8211; the plugin sets a random cookie, which, if it doesn&#8217;t exist when a comment is posted, is almost a sure sign that the comment is being placed by a bot.<\/p>\n<p>You can set the plugin to either automatically mark the comment as spam (effectively catching the two or so comments a week Akismet misses, but not solving my problem), or automatically delete the comment.<\/p>\n<p>I set it automatically delete comments. Boom! Blissful silence with my recently-cleared spam folder now not moving from 247 comments.<\/p>\n<p>You can play further and use an Apache rewrite rule to block the requests from even reaching WordPress, which I haven&#8217;t implemented yet, but looks hopeful in reducing unnecessary load further.<\/p>\n<p>What&#8217;s that? You&#8217;re suspicious of cookies and have disabled them, and now you can&#8217;t comment on my blog? I doubt you can do much else on the internet either&#8230;<\/p>\n<p>Related posts:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.greenman.co.za\/blog\/?p=1068\">You like my blog?<\/a><\/li>\n<li><a href=\"http:\/\/www.greenman.co.za\/blog\/?p=429\">An attractive honeypot<\/a><\/li>\n<li><a href=\"http:\/\/www.greenman.co.za\/blog\/?p=42\">Defeat<\/a><\/li>\n<li><a href=\"http:\/\/www.greenman.co.za\/blog\/?p=320\">Cleaning up spam referers in b2evolution<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This blog gets about 1 spam comment a second. Not bad for an obscure blog with, as I write this, only one post open for comments. Akismet, the spam plugin does a great job of keeping the spam out, although recently a few more spam posts have been sneaking through for moderation, perhaps two a&hellip; <a class=\"more-link\" href=\"https:\/\/www.greenman.co.za\/blog\/?p=1123\">Continue reading <span class=\"screen-reader-text\">WordPress spam, Akismet and Cookies for Comments<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1123","post","type-post","status-publish","format-standard","hentry","category-metal-technical","entry"],"_links":{"self":[{"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1123"}],"version-history":[{"count":6,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1129,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions\/1129"}],"wp:attachment":[{"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greenman.co.za\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}