fsoftball 0 Report post Posted May 23, 2005 Hi,I would like to create a demo page to show perspective users how my site will work. This would entail allowing a stranger to fill in several forms. I am concerned that these users will fill in the form with offense content. Is there an offensive language filter for PHP? For MySQL? Is there something that Xisto.com could provied (if so, what lever hosting do you need....free?)Thanks. Share this post Link to post Share on other sites
HmmZ 0 Report post Posted May 23, 2005 I dont know if this works perfectly, but i did something similar with my chat.First, when your setting the variable for the users message input:$usermessage //for exampleyou filter it with the badwords function, giving:$usermessage=badwords($usermessage);then somewhere else (for comfort in the same page) make a bad words filter array Function badwords($post){$badwords=array( '*BLEEP*'=>"$$$$", '*BLEEP*'=>"%$%#", '*BLEEP*'=>"^&^%", '*BLEEP*'=>"@#$#", '*BLEEP*'=>"@$#@", //you can easily expand your array ); $post=str_replace(array_keys($badwords), array_values($badwords), $post); return $post; } Like i said, this is a small amount of code ive taken from my chat but it works great, you can edit it to fit your needs. Share this post Link to post Share on other sites
snlildude87 0 Report post Posted May 23, 2005 I was going to suggest something along the line of using a string replace in PHP to replace offensive words with asterisks and the like, but the problem with this is that you absolutely cannot filter all swear words because users can still use 1337 to bypass all the words that you've blocked.I suggest using the script that Hmmz has provided and monitor whatever the user sends to you for a couple of times. Then, you can change the script to include more words as necessary. Share this post Link to post Share on other sites
bjrn 0 Report post Posted May 23, 2005 I don't know what you were planning for the demo, but unless you need the prospective users to share content you don't really need a filter, do you? As long as whatever is filled in is only seen by the visitor (and possibly you) then they can type whatever they want.But otherwise staring off with a reasonable array, and then monitoring input is probably the best option. Share this post Link to post Share on other sites
Mike 0 Report post Posted May 23, 2005 Create a function named censor with the parameter string. Below you will find the function and an example. function censor($string) {$banned_words = array();$banned_words[] = 'BANNED WORD';$banned_words[] = 'BANNED WORD';$banned_words[] = 'BANNED WORD';foreach ($banned_words AS $banned_word) {str_replace('$banned_word','-censored-',$string);}} --Example-- $message = 'What the *BANNED WORD* is your problem?!';$message = censor($message); --New Message-- 'What the -censored- is your problem?!' Share this post Link to post Share on other sites