Spam word remover

Started on the old forum in April 2011 · view the original in the archive · old links redirect here

1 reply · 365 views · started 15 years ago · 1 min read

2 participants
Anshul Senior · 296 posts #2

adex3g wrote: Any body please help me with Spam word remover script or coding

function gum_banned_words($str) 
{ 
    $words = array('wapking','videowap','http','hotking', 'masalamob');
    $found_words = gum_banned_words_check($str,$words); 
    //Developed by gumslone from coding-talk.com 
    foreach ($found_words as $word) { 
        $word_length = strlen($word); 
        $str_length = strlen($str); 
        $i = 0; 
        $n = 0; 
        while($i<$word_length) 
        { 
            if (preg_match('/[0-9A-Za-z]/',$str[$n])) 
            { 
                $find = "/".$word[$i]."/i"; 
                if (preg_match($find, $str[$n])) 
                { 
                    if($i==0) $result['start'] = $n; 
                    if($i==($word_length-1)) 
                    { 
                        $result['end'] = $n+1; 
                        break; 
                    } 
                    $i++; 
                } 
                else  
                { 
                    $i=0; 
                } 
            } 
            $n++; 
            if($n>$str_length)break;//prevent infinite loop 
        } 
        $str = substr($str, 0, $result['start']).substr($str, $result['end']); 
    } 
    $found_word2 = gum_banned_words_check($str,$words); 
    if(is_array($found_word2)) $str = gum_banned_words($str,$found_word2); 
     
    return $str; 
} 
function gum_banned_words_check($str, $words) 
{ 
    $clean_string = preg_replace('/[^[:alnum:]]/', '', $str); 
    foreach ($words as $word) { 
        $find = "/".$word."/i"; 
        if (preg_match($find, $clean_string)) $found_words[] = $word; 
    } 
    return $found_words; 
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close