Jul 26, 2008

Offensive Language Filter

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Offensive Language Filter

fsoftball
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 trap17.com could provied (if so, what lever hosting do you need....free?)

Thanks.

Reply

HmmZ
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 example
you 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

CODE
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.

 

 

 


Reply

snlildude87
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.

Reply

bjrn
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.

Reply

Mike
Create a function named censor with the parameter string. Below you will find the function and an example.

CODE


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--

CODE


$message = 'What the *BANNED WORD* is your problem?!';
$message = censor($message);



--New Message--

CODE


'What the -censored- is your problem?!'


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. computer offensive language filters - 24.42 hr back. (1)
Similar Topics

Keywords : offensive, language, filter

  1. Sos...sos...help Me Pls.
    Help to filter bad words (1)


      Looking for offensive, language, filter

Searching Video's for offensive, language, filter
advertisement



Offensive Language Filter



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE