Anti Spam Mod

Mods, snippets and styles postet and supported by the users
Forum rules
As the forum title says this is for User Contributions
Post a support request in this forum and you will be banned!
User avatar
Mii
BBCoder II
BBCoder II
Posts: 47
Joined: 28 Nov 2011, 23:16
BBCodes: 14

Anti Spam Mod

Post by Mii »

Don't you like it that people spam your board with posts containing !!!!!!!!!!! and other characters at the end?
This snippet will replace strings in a posts from !!!!! to ! and some other stuff.
./includes/functions.php wrote: Find

Code: Select all

function phpbb_user_session_handler()
{
    global $phpbb_hook;

    if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__))
    {
        if ($phpbb_hook->hook_return(__FUNCTION__))
        {
            return $phpbb_hook->hook_return_result(__FUNCTION__);
        }
    }

    return;
} 
Add After

Code: Select all

//Spelling corrector START
function message_validate_spam($message)
{
    if(isset($message) && $message != '')
    {
        $corr = array(
            'accidentally',    // 0
            'accordion',
            'acquaintance',
            'acquaintance',
            'aquire',
            'acquit',    // 5
            'a lot',
            'a lot',
            'argument',
            'a while',
            'axle',    // 10
            'barbeque',
            'believable',
            'broccoli',
            'cemetary',
            'chauvinism',    // 15
            'chocolaty',
            'colosseum',
            'collectible',
            'definite',    // 20
            'development',
            'drunkenness',
            'dumbbell',
            'exercise',
            'existence',    // 25
            'fiery',
            'flabbergast',
            'flotation',
            'frustum',
            'genius',    //30
            'grammar',
            'handkerchief',
            'harass',
            'inadvertent',
            'incidentally',    //35
            'indispensable',
            );
        $wrong = array(
            'accidently',    // 1
            'accordian',
            'acquaintence',
            'aquaintance',
            'acquire',
            'aquit',    // 5
            'alot',
            'allot',
            'arguement',
            'awhile',
            'axel',    // 10
            'barbeque',
            'believeable',
            'brocolli',
            'cemetery',
            'chauvanism',    // 15
            'chocolatey',
            'colliseum',
            'collectable',
            'definate',    // 20
            'developement',
            'drunkeness',
            'dumbell',
            'excercise',
            'existance',    // 25
            'firey',
            'flabberghast',
            'floatation',
            'frustrum',
            'genious',    // 30
            'grammer',
            'hankerchief',
            'harrass',
            'inadvertant',
            'incidently',    // 35
            'indispensible',
            );
        $l['corr'] = count($wrong) - 1;
        $l['wrong'] = count($corr) - 1;
        $typos = 0;
        if($l['corr'] == $l['wrong'])
        {
            while($l['corr'] >= 0&& $typos <= 20)
            {
                while(strstr($message,$wrong[$l['corr']]) !== false)
                {
                    $message = str_replace($wrong[$l['corr']], $corr[$l['corr']], $message);
                }
                while(strstr($message, ucwords($wrong[$l['corr']])) !== false)
                {
                    $message = str_replace(ucwords($wrong[$l['corr']]), ucwords($corr[$l['corr']]), $message);
                }
                $l['corr'] = $l['corr'] - 1;
                $typos = $typos + 1;
            }
            return $message;
        }
        else
        {
            return $message;
        }
    }
    else
    {
        return $message;
    }
}
//Spelling corrector END     
./includes/functions_posting.php wrote: Find

Code: Select all

    // Start the transaction here
    $db->sql_transaction('begin'); 
Add After

Code: Select all

    $data['message'] = message_validate_spam($data['message']);
$subject = message_validate_spam($subject);  
---------------------------- THE NEXT PART IS OPTIONAL FOR MCHAT INTEGRATION ----------------------------
./mchat.php wrote:Find

Code: Select all

        // Reguest...
        $message = utf8_normalize_nfc(request_var('message', '', true)); 
Add After

Code: Select all

        $message = message_validate_spam($message); 
You can add strings to replace in the message_validate_spam function in ./includes/functions.php. I'm sure you'll know how.
Last edited by Mii on 27 Feb 2012, 19:58, edited 2 times in total.
User avatar
Vox Populi
BBCoder III
BBCoder III
Posts: 135
Joined: 27 Jul 2011, 15:44
BBCodes: 51
Favourite BBCode: YouTube
Favourite MOD: mChat, Welcome on Index
Location: Index,WA
Contact:

Anti Spam Mod

Post by Vox Populi »

I can't say this is a true Anti Spam snippet however, it does assist in keeping your board consistent and clean. The code is appreciated and I saved it for a later date.

I know where you are coming from as it does get old, the !!!! and ???? and ......... etc;. Heck, with your code, complete words can be rewritten .... It'd be pretty darn big, but it's almost like a spell checker... :)

The most commonly mis-spelled words could be invoked with this code. It's a great start!

Thanks again.
Be who you are and say what you feel.
Those who mind don't matter.
Those who matter don't mind.
- Dr. Seuss
User avatar
doktornotor
BBCoder IV
BBCoder IV
Posts: 167
Joined: 14 Sep 2011, 23:20
BBCodes: 30
Favourite MOD: Thanks for Posts
Contact:

Anti Spam Mod

Post by doktornotor »

Hmm, indeed, this would be quite interesting with some level of abstraction and ACP settings. :thumb:
Support requests via PM go straight to /dev/null!
User avatar
Mii
BBCoder II
BBCoder II
Posts: 47
Joined: 28 Nov 2011, 23:16
BBCodes: 14

Anti Spam Mod

Post by Mii »

Vox Populi wrote:I can't say this is a true Anti Spam snippet however, it does assist in keeping your board consistent and clean. The code is appreciated and I saved it for a later date.

I know where you are coming from as it does get old, the !!!! and ???? and ......... etc;. Heck, with your code, complete words can be rewritten .... It'd be pretty darn big, but it's almost like a spell checker... :)

The most commonly mis-spelled words could be invoked with this code. It's a great start!

Thanks again.
Yeah, I already thought about using it as a spell checker, but that would seriously increase server-load. This snippet was written because members were spamming posts with incredibly many "!!!"'s, just to gain points. (Ultimate Points System)
If you want you can use it as a spelling correcter though.
User avatar
Vox Populi
BBCoder III
BBCoder III
Posts: 135
Joined: 27 Jul 2011, 15:44
BBCodes: 51
Favourite BBCode: YouTube
Favourite MOD: mChat, Welcome on Index
Location: Index,WA
Contact:

Anti Spam Mod

Post by Vox Populi »

I was thinking not so much a spell checker but an automated correction type of mod. I know there is a list of most commonly mis-spelled words. Server load, yup. You are correct for sure on that.

I have a feeling, somebody is going to snatch this and run with it.

You have come up with a brilliant idea and simple too.

Again, thanks for sharing.
Be who you are and say what you feel.
Those who mind don't matter.
Those who matter don't mind.
- Dr. Seuss
User avatar
Mii
BBCoder II
BBCoder II
Posts: 47
Joined: 28 Nov 2011, 23:16
BBCodes: 14

Anti Spam Mod

Post by Mii »

Vox Populi wrote:I was thinking not so much a spell checker but an automated correction type of mod. I know there is a list of most commonly mis-spelled words. Server load, yup. You are correct for sure on that.

I have a feeling, somebody is going to snatch this and run with it.

You have come up with a brilliant idea and simple too.

Again, thanks for sharing.
Hmm, I just tested, and it doesn't take that much server load. Especially since it isn't loaded on every page, but only when submitting a post. (Other then wordcensor) I'm going to create a modification for this, but I first need to have a decent list of common misspelled words.

I only need to find out how to notice capitol letters in the words and how to not change them. I think I just create 2 versions of each word. (1 with a starting capital letter, and one without).
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Anti Spam Mod

Post by martin123456 »

Going bk to anti spam idea i just use this in the word censor
place the censored characters in it and replace word is in the code box bellow this way it never shows

Code: Select all

 
But saying that i agree with the dok and sir vox :)
User avatar
Vox Populi
BBCoder III
BBCoder III
Posts: 135
Joined: 27 Jul 2011, 15:44
BBCodes: 51
Favourite BBCode: YouTube
Favourite MOD: mChat, Welcome on Index
Location: Index,WA
Contact:

Anti Spam Mod

Post by Vox Populi »

Yeah, that's an idea that should be used too. Good thought.

By the way, Google has a plethora of commonly misspelled words in the English language.. http://www.infoplease.com/ipa/A0862708.html and many more.

Also, you'll need to know how the word was misspelled to change it. So, now you need to search for most commonly misspelled words in the English language AND HOW they are misspelled most of the time. You can only correct those really. You can't add every misspelling eg; Knowledge. Misspelled : Knowlege, noledge???? too? Hmmm, pretty complex.
Last edited by Vox Populi on 08 Dec 2011, 22:39, edited 1 time in total.
Be who you are and say what you feel.
Those who mind don't matter.
Those who matter don't mind.
- Dr. Seuss
User avatar
Mii
BBCoder II
BBCoder II
Posts: 47
Joined: 28 Nov 2011, 23:16
BBCodes: 14

Anti Spam Mod

Post by Mii »

Bl4d3 x wrote:Going bk to anti spam idea i just use this in the word censor
place the censored characters in it and replace word is in the code box bellow this way it never shows

Code: Select all

 
But saying that i agree with the dok and sir vox :)
Using the word censor would take way more server load. Here is my first version. (Easy to use, all strings are placed in an array.

Code: Select all

//Anti spam start
function message_validate_spam($message)
{
    if(isset($message) && $message != '')
    {
        $corr = array(
            1    =>    'accidentally',
            2    =>    'accordion',
            3    =>    'acquaintance',
            4    =>    'acquaintance',
            5    =>    'aquire',
            6    =>    'acquit',
            7    =>    'a lot',
            8    =>    'a lot',
            9    =>    'argument',
            10    =>    'a while',
            11    =>    'axle',
            12    => 'barbeque',
            13    => 'believable',
            14    => 'broccoli',
            15    => 'cemetary',
            );
        $wrong = array(
            1    => 'accidently',
            2    => 'accordian',
            3    => 'acquaintence',
            4    => 'aquaintance',
            5    => 'acquire',
            6    => 'aquit',
            7    => 'alot',
            8    => 'allot',
            9    => 'arguement',
            10    => 'awhile',
            11    => 'axel',
            12    => 'barbeque',
            13    => 'believeable',
            14    => 'brocolli',
            15    => 'cemetery',
            );
        $l['corr'] = count($wrong);
        $l['wrong'] = count($corr);
        if($l['corr'] == $l['wrong'])
        {
            while($l['corr'] > 0)
            {
                while(strstr($message,$wrong[$l['corr']]) !== false)
                {
                    $message = str_replace($wrong[$l['corr']], $corr[$l['corr']], $message);
                }
                $l['corr'] = $l['corr'] - 1;
            }
            return $message;
        }
        else
        {
            return $message;
        }
    }
    else
    {
        return $message;
    }
}
//Ant spam end 
User avatar
Vox Populi
BBCoder III
BBCoder III
Posts: 135
Joined: 27 Jul 2011, 15:44
BBCodes: 51
Favourite BBCode: YouTube
Favourite MOD: mChat, Welcome on Index
Location: Index,WA
Contact:

Anti Spam Mod

Post by Vox Populi »

Ahhh, I see. Looks great. So a person can add to this easily. The array takes away the load... Good thought again.

I think it's best to keep it away from the ACP too but then, somebody will mess the file up and be hammering you!! :D

http://www.alphadictionary.com/articles ... words.html
Last edited by Vox Populi on 08 Dec 2011, 22:43, edited 1 time in total.
Be who you are and say what you feel.
Those who mind don't matter.
Those who matter don't mind.
- Dr. Seuss
Locked