{"id":45,"date":"2004-10-07T14:24:35","date_gmt":"2004-10-07T14:24:35","guid":{"rendered":"http:\/\/kubasek.com\/blog\/lifelong_learner\/?p=45"},"modified":"2004-10-07T14:24:35","modified_gmt":"2004-10-07T14:24:35","slug":"say-no-to-movabletype-spam","status":"publish","type":"post","link":"https:\/\/lifelonglearner.kubasek.com\/?p=45","title":{"rendered":"Say No To MovableType Spam"},"content":{"rendered":"<p>This entry is only applicable if you use MovableType. \ud83d\ude41<\/p>\n<p>Are you getting spam comments in you MovableType blog? I see this as a growing problem among many bloggers. A lot of the bloggers are so fed up that they stop comments altogether. I think that&#8217;s too extreme. I&#8217;ll give you a Anti-spam solution for MovableType that I put in in place (it was suggested to me by a friend :-)) for my MT blog and that has been working 100%.<\/p>\n<p>What&#8217;s the trick? Adding a new, custom, hidden field on the comments form and checking for it when the comment is submitted.<\/p>\n<p>Why does it work? It works because spammers don&#8217;t go to your site to post the comment. They use a crawler to do that.  And using a crawler, they have to have to same script work for all MovableType, and possible others, blogs. Like I said, it has worked 100% for me &#8212; not a single spam comment passed through. How can I tell? That&#8217;s the fun out of the solution. I log each request by a spammer in the activity log. The solution presented here does that.<\/p>\n<p>The solution requires some tweaking with couple of MT files. But if you can change couple lines in a file manually, you can do it. It&#8217;s a two step process. Very simple.<\/p>\n<p><b>Step 1: Add a new hidden parameter to your Comment Listing Template<\/b><\/p>\n<p>You can find it under TEMPLATES in MT.<\/p>\n<p>Locate the following in that file:<\/p>\n<p><pre>&lt;form method=\"post\" action=\"\/mt\/mt-comments.cgi\"<\/pre>\n<p>Add a new hidden field inside the form. I named the field &#8220;saynotospam&#8221; but you can name it anything you want. You should, actually, so spammers don&#8217;t write the script for it. After you&#8217;re done, it will look something like this (you only need to add the bolded code):<\/p>\n<p><pre>&lt;form method=\"post\" action=\"\/mt\/mt-comments.cgi\" name=\"comments\"onsubmit=\"this.saynotospam.value='donny';if (this.bakecookie[0].checked) rememberMe(this)\"&gt;<p><b>&lt;input type=\"hidden\" name=\"saynotospam\" \/&gt;<\/b><\/pre>\n<p>If you allow to Preview comments, you have to add the field there as well (same code). Plus, if you have the comment enabled\/embedded somewhere else, you have to do the same (I had to add it to my Individual Entry Archive).<\/p>\n<p><b>Step 2: Verify that the parameter exists when MT posts it.<\/b><\/p>\n<p>When the MT posts the comment and the field does not exist, you stop it, not letting the comment be added.<\/p>\n<p>Open mt\/lib\/MT\/App\/Comments.pm<\/p>\n<p>and add the following in the &#8220;post&#8221; method (search for it):<\/p>\n<p><pre>sub post {my $app = shift;my $q = $app-&gt;{query};<p><b># 7\/13\/2004 skif (!$q-&gt;param('saynotospam')) {$app-&gt;log(\"spammer ignored\");return $app-&gt;error(\"get lost\");}<\/b>...}<\/pre>\n<p>That&#8217;s it. Watch the spam comments in the Activity Log of MT. I had done the above and I have not received a single spam comment. I used to receive couple per week before. Thanks Rob.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This entry is only applicable if you use MovableType. \ud83d\ude41 Are you getting spam comments in you MovableType blog? I see this as a growing problem among many bloggers. A lot of the bloggers are so fed up that they stop comments altogether. I think that&#8217;s too extreme. I&#8217;ll give you a Anti-spam solution for MovableType that I put in in place (it was suggested to me by a friend :-)) for my MT blog and that has been working 100%. What&#8217;s the trick? Adding a new, custom, hidden field on the comments form and checking for it when the comment is submitted. Why does it work? It works because spammers don&#8217;t go to your site to post the comment. They use a crawler to do that. And using a crawler, they have to have to same script work for all MovableType, and possible others, blogs. Like I said, it has worked 100% for me &#8212; not a single spam comment passed through. How can I tell? That&#8217;s the fun out of the solution. I log each request by a spammer in the activity log. The solution presented here does that. The solution requires some tweaking with couple of MT files. But if you can change couple lines in a file manually, you can do it. It&#8217;s a two step process. Very simple. Step 1: Add a new hidden parameter to your Comment Listing Template You can find it under TEMPLATES in MT. Locate the following in that file: &lt;form method=&#8221;post&#8221; action=&#8221;\/mt\/mt-comments.cgi&#8221; Add a new hidden field inside the form. I named the field &#8220;saynotospam&#8221; but you can name it anything you want. You should, actually, so spammers don&#8217;t write the script for it. After you&#8217;re done, it will look something like this (you only need to add the bolded code): &lt;form method=&#8221;post&#8221; action=&#8221;\/mt\/mt-comments.cgi&#8221; name=&#8221;comments&#8221;onsubmit=&#8221;this.saynotospam.value=&#8217;donny&#8217;;if (this.bakecookie[0].checked) rememberMe(this)&#8221;&gt;&lt;input type=&#8221;hidden&#8221; name=&#8221;saynotospam&#8221; \/&gt; If you allow to Preview comments, you have to add the field there as well (same code). Plus, if you have the comment enabled\/embedded somewhere else, you have to do the same (I had to add it to my Individual Entry Archive). Step 2: Verify that the parameter exists when MT posts it. When the MT posts the comment and the field does not exist, you stop it, not letting the comment be added. Open mt\/lib\/MT\/App\/Comments.pm and add the following in the &#8220;post&#8221; method (search for it): sub post {my $app = shift;my $q = $app-&gt;{query};# 7\/13\/2004 skif (!$q-&gt;param(&#8216;saynotospam&#8217;)) {$app-&gt;log(&#8220;spammer ignored&#8221;);return $app-&gt;error(&#8220;get lost&#8221;);}&#8230;} That&#8217;s it. Watch the spam comments in the Activity Log of MT. I had done the above and I have not received a single spam comment. I used to receive couple per week before. Thanks Rob.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45"}],"version-history":[{"count":0,"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions"}],"wp:attachment":[{"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lifelonglearner.kubasek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}