anti-spam delete account based on
#1
Can someone make a plugin to delete account and their threads/posts (or better yet...execute purge spammer on them) based on a users first post, and their content... keywords/phrases with options to add to it in ACP?
Reply
#2
3 settings:
-Enabled/disabled
-Words/phrases separated by comma
-Maximun posts to check - if users has more than X posts, the check is ignoerd to prevent false-positves. 99% of spammers are recently registered users.

UPDATE:
v1.1: Added a setting for ban reason

If a phrase/word is detected, the thread/post is not created + the user gets automatically banned.

Known issues: The subject is even checked at thread replays. Too lazy to check if it's new post or new thread.

I tested it a bit and it is working.

UPDATE:
v1.2: Added check on post edit.
Added a setting to choose the action taken.

UPDATE:
v1.3: Fixed some bugs
Added a new custom error template
Added setting for custom ajax error for quick replay


Attached Files
.php   auto_ban.php (Size: 7.44 KB / Downloads: 69)
Reply
#3
Quote:I tested it a bit and it is working.
Thank You!!!!
How can i test it without banning myself? I am not sure if it bans IP/account/etc.
Quote:Known issues: The subject is even checked at thread replays. Too lazy to check if it's new post or new thread.

You mean it just rechecks the thread title on a new post? That seems no biggie.

Is there anyway to switch to just block a post VS block a ppost and ban user? I am assuming from looking at the code that to deny banning a user, and just block a user, to comment out the first line in this block?
            if (stristr($message, $phrase) || stristr($subject, $phrase)){
                ban_user($mybb->user['uid']);
                error_no_permission();
            }
EDIT:
If i add this original file to my plugins directory, i do not see it listed in my plugins available. Is it suppose to be elsewhere?
Reply
#4
(2016-10-24, 12:09 AM)metulburr Wrote: How can i test it without banning myself? I am not sure if it bans IP/account/etc.
Create a test account Big Grin. It bans the account only. Not sure if there is any internal function to ban by IP.

(2016-10-24, 12:09 AM)metulburr Wrote: You mean it just rechecks the thread title on a new post? That seems no biggie.
Exactly that. Not a big deal...

(2016-10-24, 12:09 AM)metulburr Wrote: Is there anyway to switch to just block a post VS block a ppost and ban user? I am assuming from looking at the code that to deny banning a user, and just block a user, to comment out the first line in this block?
            if (stristr($message, $phrase) || stristr($subject, $phrase)){
                ban_user($mybb->user['uid']);
                error_no_permission();
            }
EDIT:
If i add this original file to my plugins directory, i do not see it listed in my plugins available. Is it suppose to be elsewhere?
If you comment "ban_user" call, it will only block the post/thread.

You must name the plugin "auto_ban.php". I should had attached it. I updated my last answer with the file attached.
Reply
#5
Quote:If you comment "ban_user" call, it will only block the post/thread.

You must name the plugin "auto_ban.php". I should had attached it. I updated my last answer with the file attached.
Nice. Thanks.

Another question regarding the page they go to. In case of false positives i want the user to know they are being flagged as spam. The no error permission gives little info. Is there a way to add a box that gets inserted to above the editor like so
   

I tried getting the answer from "no links allowed" plugin whihc does just this
$plugins->add_hook("datahandler_post_validate_thread", "atuo_ban_trigger");

$plugins->add_hook("datahandler_post_validate_post", "auto_ban_trigger");

function auto_ban_trigger(){
    global $mybb;
    
    if ($mybb->settings['autoban_enabled'] == 0){
        return false;
    }
    
    if ($mybb->user['postcount'] < $mybb->settings['autoban_minposts']){
        $message = $mybb->get_input('message');
        $subject = $mybb->get_input('subject');
        
        $phrases = explode(',',$mybb->settings['autoban_words']);
        foreach ($phrases as $phrase){
            $phrase = trim($phrase);
            if ($phrase == ''){
                continue;
            }
            if (stristr($message, $phrase) || stristr($subject, $phrase)){
                //ban_user($mybb->user['uid']);
               // error_no_permission();
                $post->is_validated = false;
                $post->set_error(sprintf("Your post has been marked as spam, and notified admins and     mods. ", "Auto-Block"));

            }
        }
    }
} 


But it takes you to a white page. 

Here is the code for the plugin of no links allowed
<?php

/*********************************************************************************************

+ No Links Allowed v0.1 : A Plugin for MyBB 1.4 and 1.6

+ Free to Use

+ Free to Edit

+ But Not Allowed to distribute

**********************************************************************************************

*/

if(!defined("IN_MYBB")){

    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");

}

function no_links_info(){

    return array(

        "name"          => "No Links Allowed",      "description"   => "This plugin used to deny posting links before reaching min. amount of posts.",      "website"       => "http://yaldaram.com",       "author"      => "Yaldaram",      "authorsite"    => "http://yaldaram.com",       "version"       => "0.1",      "compatibility" => "14*,16*,18*", "guid" => "7cfbe49416c7ffc03af0801cde9c59fc"

    );

}

function no_links_activate(){

    global $db, $mybb;

    $no_links_group = array(

        "gid"           => "NULL",      "name"          => "no_links",      "title"         => "No Links Allowed",      "description"   => "Settings for the plugin.",      "disporder"     => "1",     "isdefault"       => "no",

    );

    $db->insert_query("settinggroups", $no_links_group);

    $gid = $db->insert_id();

    $no_links_setting_1 = array(

        "sid"           => "NULL",      "name"          => "no_links_power",        "title"         => "Power",       "description"   => "Select Yes if you really wants this plugin to run.",        "optionscode" => "yesno",     "value"         => "no",        "disporder"     => "1",     "gid"           => intval($gid),

    );

    $db->insert_query("settings", $no_links_setting_1);

    $no_links_setting_2 = array(

        "sid"           => "NULL",      "name"          => "no_links_groups",       "title"         => "Restricted_Groups",       "description"   => "Specify who is not allowed to post link. Separate each with ,",      "optionscode"   => "text",      "value"         => "1,2,5",     "disporder"     => "2",     "gid"           => intval($gid),

    );

    $db->insert_query("settings", $no_links_setting_2);

    $no_links_setting_3 = array(

        "sid"           => "NULL",      "name"          => "no_links_forums",       "title"         => "Restricted_Forums",       "description"   => "Specify where this plugin is functional. Separate each with ,",      "optionscode"   => "text",      "value"         => "2,3",       "disporder"     => "3",     "gid"           => intval($gid),

    );

    $db->insert_query("settings", $no_links_setting_3);

    $no_links_setting_4 = array(

        "sid"           => "NULL",      "name"          => "no_links_posts",        "title"         => "Minimum_Posts",       "description"   => "Specify minimum amount of posts.",      "optionscode"   => "text",       "value"         => "25",        "disporder"     => "4",     "gid"           => intval($gid),

    );

    $db->insert_query("settings", $no_links_setting_4);

    rebuild_settings();

}

function no_links_deactivate(){

    global $db, $mybb;

    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='no_links'");

    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_power'");

    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_groups'");

    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_forums'");

    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_posts'");

    rebuild_settings();

}

$plugins->add_hook("datahandler_post_validate_thread", "no_links_do");

$plugins->add_hook("datahandler_post_validate_post", "no_links_do");

function no_links_do($post){

    global $mybb, $fid;

    $power = $mybb->settings['no_links_power'];

    $group = $mybb->user['usergroup'];

    $groups = explode(",",$mybb->settings['no_links_groups']);

    $forums = explode(",",$mybb->settings['no_links_forums']);

    $postcount = $mybb->user['postnum'];

    $posts = $mybb->settings['no_links_posts'];

    if ($power != "0"){

        if (in_array($fid,$forums) && in_array($group,$groups) && $posts > $postcount){

            if (preg_match('@((http|https|ftp|irc)://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $post->data['message'])){

                $post->is_validated = false;

                $post->set_error(sprintf("You cannot post clickable links on this board until you proved you are not a spammer.", "No Links Allowed"));

            }

        }

    }

}

?>

Apparently a user above the post count still gets blocked.

I blocked http:// for users with less than 2 posts...and i have 600+ posts, and get blocked as well when i post that string.
Reply
#6
I was getting the posts count from another index that didn't exist, that's why the "Max posts" settings wasn't working. Download the file again.

Let me check how error_nopermissions function is done, to create something similar with a custom template... maybe tomorrow I will check it.
Reply
#7
thanks
Reply
#8
I've just released a new version. I've added a custom template so you can modify it as you want.

After you update the plugin, you will find a new template under "global templates" called "auto_ban_error_page". It's an exact copy of the "no permissions" page, but you can change it as you wish...

Please follow these steps for updating:
1. Download 1.3 version.
2. Backup your plugin configs.
3. Uninstall 1.2 version.
4. Replace auto_ban.php with new version.
5. Install it.
6. Restore your plugin settings.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)