Take the 2-minute tour ×

We've been having a new type of spam-bot this week at PortableApps.com which posts at a rate of about 10 comments a minute and doesn't seem to stop - at least the first hour or so (we've always stopped it within that time so far). We've had them about a dozen times in the last week - sometimes stopping it at 50 or 60, sometimes up to 250 or 300. We're working to stop it and other spam bots as much as possible, but at the moment it's still a real pest.

I was wondering whether in the mean time whether there's any sort of module to control the frequency a user can post at to e.g. 50 an hour or something like 10 in an hour for new users. That at least would mean that instead of having to clear up 300 comments 50 at a time in admin/content/comment we'd have a smaller number to clear. (A module to add a page to delete all content by a user and block them would also be helpful!)

I believe that there's a plugin to do this available for WordPress, but can't find any such thing for Drupal.

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted

For your second question, i would have a look at the code of the User Delete module (click).

The module also disables the user account and unpublished all nodes/comments from a certain user. By extending the code, you could easily create another possibility to unpublish + delete all nodes/comments from a certain user and blocking the account.

After the unpublish code in the module, you should just put delete code (in sql if the module is selecting by a sql-query or by using the drupal delete functions).

Another option would be so make a view (using the view module) only to be viewed by administrators, where you choose a certain user using the filters and then lists his/her posts. Then in the node-contenttype.tpl.php you place a button that calls a function which deletes all nodes/comments and the user.

First problem (post frequency)

I've been thinking about the comment post limit. If I remember correctly Drupal stores comments in a seperate table and has comment specific functions.

I'd create a new module and using the comment_nodeapi function i would check in the operation 'insert' how much comments the current user has already made within a certain timeframe.

To check this I would write a custom sql query on the database which takes the count of alle comments made by uid where the post_date is larger then NOW-1hour. If that count is larger then 10 or 15 or whatever post frequency you want then you give a message back to the user. You can retrieve the user id and name by using the global $user variable.

(example: print $user->name;)

You have to check on your own for the sql query but here's some code when you have the amount:

function comment_nodeapi(&$node, $op, $arg = 0) {
  switch ($op) {

    case 'insert':
      if($count > 15){
          $repeat = FALSE;
          $type = 'status'
          drupal_set_message("You have reached the comment limit for this time.", $type, $repeat);
          db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid);

(this code has not been tested so no guarantees, but this should put you on the right track)

share|improve this answer
That looks as though it should do just what we want to help with cleanup; thanks! I'll see about us trying that out. –  Chris Morgan Nov 9 '10 at 21:48
add comment

I would suggest something like Mollom (from the creator of Drupal). It scans the message for known spam pattern/keywords/... and if this scan fails, it displays a CAPTCHA to the user to make sure that it's a real human that wants to enter content that has the same properties like spam.

They offer a free service and some paid solutions. We are using it for some customers and it's worth the money. It also integrates very well in Drupal.

share|improve this answer
We tried Mollom, but unfortunately, unlike my experience with a few other (smaller) sites I've deployed it on, it didn't work out - several known good users got blocked apparently due to their IP address, and there is no way to sort it out with Mollom - no whitelisting, etc. We talked things over with them but came to the conclusion that it just won't work at the moment, unfortunately. –  Chris Morgan Nov 9 '10 at 21:41
Oh, that's a pity. We never had any problems so far. That's bad because Mollom is IMO a very neat service. –  DrColossos Nov 10 '10 at 7:57
We used Mollom too on a huge site- it was a total wash out; it let the spammers through, and penalised legitimate users. –  cjm2671 Mar 27 '13 at 11:50
add comment

Comment Limit is probably what you need.

share|improve this answer
That looks to cover just commenting on one node, unfortunately, not on any nodes of such and such a type. We haven't ever had any spam bots posting more than a couple of comments per node so it wouldn't work for us. Thanks for helping anyway. –  Chris Morgan Nov 9 '10 at 21:47
add comment

http://drupal.org/project/spam http://drupal.org/project/antispam - with akismet support

share|improve this answer
I believe we already have the spam module and I think we decided our volume is too high for antispam. We have looked at both, sorry. –  Chris Morgan Nov 30 '10 at 21:08
add comment

Your Answer


