Page 2 of 2

Anti Spam Mod

Posted: 08 Dec 2011, 22:43
by Mii
Vox Populi wrote:Ahhh, I see. Looks great. So a person can add to this easily. The array takes away the load... Good thought again.
Yeah, but it has some negative things too. The replacement of word 1 has to have the id 1.
But you probable already noticed. XD

Anti Spam Mod

Posted: 08 Dec 2011, 22:48
by Vox Populi
You can always change things later. Getting it going now and finding ways to trim it down later. Probably 3 versions to get it right then a couple of tweaks..... 1 - 2 more versions. Then EVERYBODY is going to have a better way. I think you are on to something.

Anti Spam Mod

Posted: 08 Dec 2011, 22:59
by Mii
I beated the word censor. The new version includes new words and automatically detects the difference between a capitalized and uncapitlized word and respects the capital letter.
e.g. Brocolli[c] becomesBroccoli[/c] without having Broccoli or Brocolli defined in the array. You'll only need to add the uncapitalized words.

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',
            16    => 'chauvinism',
            17    => 'chocolaty',
            18    => 'chauvinism',
            19    => 'colosseum',
            20    => 'collectible',
            21    => 'definite',
            22    => 'development',
            23    => 'drunkenness',
            24    => 'dumbbell',
            25    => 'exercise',
            );
        $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',
            16    => 'chauvanism',
            17    => 'chocolatey',
            18    => 'chauvanism',
            19    => 'colliseum',
            20    => 'collectable',
            21    => 'definate',
            22    => 'developement',
            23    => 'drunkeness',
            24    => 'dumbell',
            25    => 'excercise',
            );
        $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);
                }
                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;
            }
            return $message;
        }
        else
        {
            return $message;
        }
    }
    else
    {
        return $message;
    }
} 

Anti Spam Mod

Posted: 08 Dec 2011, 23:18
by Mii
Sorry for the double post, but I created a new method for defining the array.

Code: Select all

Removed because a newer version is available.  
EDIT
I added check of typos. A user can only have 20 typos, otherwise the corrector will quit correcting it to reduce server load.

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 

Anti Spam Mod

Posted: 09 Dec 2011, 00:14
by Vox Populi
I have not tested it out as of yet, but what is the server load? Is it directly related to how many items in the array or in the misspelled words when submitting.

How about on submit "You have misspelled words. Would you like me to correct them?" Yes / No...

Naw, that won't work either. It still has to read before asking the question.

Anti Spam Mod

Posted: 09 Dec 2011, 00:19
by Mii
Vox Populi wrote:I have not tested it out as of yet, but what is the server load? Is it directly related to how many items in the array or in the misspelled words when submitting.

How about on submit "You have misspelled words. Would you like me to correct them?" Yes / No...

Naw, that won't work either. It still has to read before asking the question.
How more spelling errors, how more server load. I've to say, 20 words isn't a big server load time yet, so you can change this if you want.
How about on submit "You have misspelled words. Would you like me to correct them?" Yes / No...
It's not reading that take serverload, but it's the replacing.
Also we would loose possible integration with other mods like the already integrated mchat.
Also, most users don't care about spelling, so they probably won't correct it, nor search all their words on Google to see if they spelled them right.

Anti Spam Mod

Posted: 01 Jan 2012, 13:40
by master412160
This is quite a nic mod !

Anti Spam Mod

Posted: 01 Jan 2012, 16:04
by Mii
Thanks!

Anti Spam Mod

Posted: 27 Feb 2012, 19:59
by Mii
Redo the ./includes/functions_posting.php edits, I edited them to apply for topic title too.