Welcome to WebmasterWorld Guest from 54.205.251.179

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Bad words filter

Bad word filter with php and mysql

   
9:11 pm on May 15, 2004 (gmt 0)

10+ Year Member



How can i go about getting a bad words filter that uses mysql for ease of editing , deleting , and adding filter words
--Thanks in advance
--Tripp
1:44 am on May 16, 2004 (gmt 0)

10+ Year Member



<?
function edit_words($STRING,$bannedwords) {
foreach($bannedwords as $key => $v) {
$STRING = eregi_replace($v,"*@!\$",$STRING);
}
return $STRING;
}

//i don't know how to populate the list using mySQL, never used it
$words = array('this','that','and','the','other','thing');

// call it like this
$uneditedString = "hi, this and that and the other thing. yup!";
$edited = edit_words($uneditedString,$words);
?>

hope this helps a little, i'm sure there are much better ways

4:22 pm on May 19, 2004 (gmt 0)

10+ Year Member



MYSQL_QUERY (SELECT * FROM bad words list.....

$badWords=MYSQL_FETCH_ARRAY(YOUR RESULT);
OR

$badWords=array("word1","word2");

for($x=0; $x< count($badWords); $x++)
{
$input = eregi_replace($badWords[$x], "****", $input);

}

Replaces bad words with **** in $input