Error filter in PHP?

I am writing a flag filter in PHP.

I have a list of badwords in the array and the cleanse_text () method is written as follows:

public static function cleanse_text($originalstring){
   if (!self::$is_sorted) self::doSort();
   return str_ireplace(self::$badwords, '****', $originalstring);
}

This works trivially for exact matches, but I also wanted to censor words that were disguised as "ab * d", where "abcd" is a bad word. It turns out to be a little more complicated.

Here are my questions:

  • Is the flag filter worthy of attention (this is a site for professionals, so a minimum degree of decency is required - I would think)

  • Is it worth the fuss trying to capture an obvious job, such as "f * ck", or not try to filter them out.

  • Is there a better way to write cleanse_text () method above?

+3
source share
5

.

  • , , . . , . .

  • . ( "clbuttic" ), , , . (: f*ck) . , .

  • . , , .

+13

, . -, , , , - . , , , . ( , , , .)

, , , , , . ( Scunthorpe, @deceze .) , , . , , .

. , - - .

+1

, :

, , , , .

, , - . , , - " " , . , . , //, . , , , .

, . , . , . . , . , , .

.

+1

8u11 $# 1 + . , .

0

, . - 100% //? , , , !

OPs ( post/user-input) " " , . - "", " " , .

function spam_found($full_string){
    $spam = array('100%', '100 %', '110%', '110 %', 'free');
    $i = 0;
    foreach ($spam as $spamword) {
        if (strrpos($full_string, $spamword)) {
            $i++;
        }
    }
    if($i > 0){
        return true;
    }else{
        return false;
    }
}

"", ( MVC, , , ). , , true, 3 -.

, , , , . , -, " ". , (.. Facebook), - ( /, ) / .

Facebook " " , , ", , , ..".

-1

Source: https://habr.com/ru/post/1746123/


All Articles