Code: Select all
function cleanWords($value) {
/* strip naughty words */
$bad_word_file = 'standards/badwords.txt';
$strtofile = fopen($bad_word_file, "r");
$badwords = explode("\n", fread($strtofile, filesize($bad_word_file)));
fclose($strtofile);
for ($i = 0; $i < count($badwords); $i++) {
$wordlist .= str_replace(chr(13),'',$badwords[$i]).'|';
}
$wordlist = substr($wordlist,0,-1);
$value = preg_replace("/\b($wordlist)\b/ie", 'preg_replace("/./","*","\\1")', $value);
return $value;
}