Click to See Complete Forum and Search --> : Banned Words in Bulletin Board


Geat
06-12-2003, 06:18 AM
I'm putting the finishing touches to a PHP bulletin board, whcih includes screening posts for inappropriate language (important as it is an official site).

The problem is that some words (such as s****horpe) contain incerdibly offensive words, but need to be displayed...

Does anyone know where I can get hold of all such words so I can override the banning of them?

AdamGundry
06-12-2003, 07:59 AM
Could you check for the word with spaces/punctuation before or after it, which would stop your problem? Of course, your users could then easily add something to the word to convey its meaning without exactly the same text.

Adam

pyro
06-12-2003, 08:16 AM
I would match the words with regexp... that would help alleviate your problem. What the below will do is check if the word is preceded or followed by a alphebetic character, and if so, it will let it slide. If not, it will change to asterisks...

<?PHP
$text = "s****horpe";

$new_text = preg_replace("/[^a-zA-Z]swear[^a-zA-Z]/i","****", $text); #replace "swear" with the swear ;)
echo $new_text;

?>