Fork me on GitHub
Current releases are 2.1.1 (2 Aug 2014) and 2.0.18.13 (5 Aug 2014)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

Automatic ban?

theallantheallan New
edited February 2012 in Vanilla 2.0 Help

Hello,

I'm really loving the spam / moderation options with the Akismet plug-in, but I'm wondering how it might be possible to "enhance" it slightly? What would be nice is if a user is found to have 5 posts (or whatever) in the spam moderation queue, their role would automatically be changed to banned. Is that possible? Any suggestions on how to do it would be very welcome!

Thanks, Allan

Answers

  • try to put its IP into .htaccess ban

  • Yeah I guess that would work given that I could scan the DB and check the posting rate. But really it would be nice to be able to change the user name to being banned as that is part of the forum software. Is there an API for doing that?

    Allan

  • It's probably really easy to do, although i'm not sure how you would incorporate it as a plugin and therefore you'd have to change the core files.

    You're best just waiting for something like this to be included in later releases.

  • theallantheallan New
    edited February 2012

    Figured I should stop being lazy and have a peak at the code (should have done that in the first instance rather than wasting everyone's time - sorry about that!).

    This is my solution - add the following to the "CheckAkismet" plug-in for the Akismet spam detection:

      if ( $Result ) {
         $spamCount = Gdn::SQL()->GetCount('GDN_Log', array('Operation'=>'Spam', 'InsertUserID'=>$UserId));
         // Three messages already in Spam queue, and this now will be a forth so ban the sucker
         if ( $spamCount >= 3 ) {
            Gdn::SQL()->Update('GDN_User', array('Banned'=>1), array('UserID'=>$UserId));
         }
      }
    

    I suspect that there are a few defines that should be used to make it integrate with the system fully, and ultimately it would be nice to have it as a configuration option for the plug-in I guess, but this is fine for my use atm :-)

    Regards, Allan

  • Actually - a couple of errors in the above code... Here is the correct code should anyone else be interested in this:

      if ( $Result ) {
         $spamCount = Gdn::SQL()->GetCount('Log', array('Operation'=>'Spam', 'InsertUserID'=>$UserID));
         // Three messages already in Spam queue, and this now will be a forth so ban the sucker
         if ( $spamCount >= 3 ) {
            Gdn::SQL()->Update('User')->Set('Banned', '1', FALSE)->Where('UserID', $UserID)->Put();
         }
      }
    

    Allan

Sign In or Register to comment.