Chris Morgan
Chris Morgan

Reputation: 90832

Drupal module to control user post frequency?

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.

Upvotes: 1

Views: 567

Answers (4)

atomicjeep
atomicjeep

Reputation: 528

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

Upvotes: 0

Jozzeh
Jozzeh

Reputation: 841

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:

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

    case 'insert':
      //PLACE HERE THE SQL TO GET THE COUNT
      if($count > 15){
          $repeat = FALSE;
          $type = 'status'
          drupal_set_message("You have reached the comment limit for this time.", $type, $repeat);
          break;
      }else{
          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);
          break;
      }
   }
}
?>

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

Upvotes: 1

berkes
berkes

Reputation: 27573

Comment Limit is probably what you need.

Upvotes: 1

DrColossos
DrColossos

Reputation: 12998

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.

Upvotes: 1

Related Questions