[PHP] Swear/Bad Word Censorship Script?

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

Does anyone know of an effective php censorship script? One that will filter the common ways of getting around the filters aswell.

I also need a Swear word/bad word list aswell.

Thanks...
 
Surely you can think them up yourself?

Code:
$swearies = array('sod', 'bleeding', 'blimey', 'cripes');
$replace = '&%@#$';

$string = 'Blimey! The sod clear took orf my bleeding ears!';

$string = preg_replace('#('.join('|', $swearies).'#i', $replace, $string);
 
robmiller said:
Surely you can think them up yourself?

Code:
$swearies = array('sod', 'bleeding', 'blimey', 'cripes');
$replace = '&%@#$';

$string = 'Blimey! The sod clear took orf my bleeding ears!';

$string = preg_replace('#('.join('|', $swearies).'#i', $replace, $string);
Erm, str_replace will do that just as well for a fraction of the CPU usage.

$string = str_replace($swearies, $replace, $string);

I'm sure you can come up with a list of swearies if you put your mind to it. ;) Just cover the most common ones and if a new one crops up in future, add it to the array.
 
Hi there,

Thanks for the replies, I could have done that myself, that is why i specifically put this.

Conrad11 said:
One that will filter the common ways of getting around the filters aswell.

I wanted an already made script that is known to stop most of the ways people get around it, like putting spaces, putting dots, putting commas....the list goes on.

Thanks....


[edit]

I am still reading through the preg-replace thing on php.net so if what you put does what i've asked, then sorry, and thanks....
 
Conrad11 said:
I wanted an already made script that is known to stop most of the ways people get around it, like putting spaces, putting dots, putting commas....the list goes on.

Thanks....


[edit]

I am still reading through the preg-replace thing on php.net so if what you put does what i've asked, then sorry, and thanks....

yeah, it's the list that'll have all the common ways of getting around the filter. then it'd be a simple case of adding things when you see people using them :)
 
Moredhel said:
Erm, str_replace will do that just as well for a fraction of the CPU usage.

$string = str_replace($swearies, $replace, $string);
Or str_ireplace() :)

I wanted an already made script that is known to stop most of the ways people get around it, like putting spaces, putting dots, putting commas....the list goes on.
That's why God invented the banhammer. You see it in action here - you can't efficiently filter swear words and all their typo forms automatically (as you get more complex, the user gets more complex in their attempts to mask, so it's a vicious circle), which is why there's moderators.

I suppose you could just use a basic list and flag users who get hit by the filter so you know to watch their future posts for attempts at masking the searies? Could be one way.
 
Back
Top Bottom