Any one enhance this code to filter badwords.

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
vibhavram
-


Joined: 30 May 2010
Posts: 2
Location: Hyderabad

PostPosted: Sun Sep 25, 2011 10:06 am    Post subject: Any one enhance this code to filter badwords. Reply with quote

I am using the following php functions to filter bad words from the user generated content. This is still not sufficient to filter in a better way since users are posting words added with spaces like for word 'badword' they are posting like 'b a d w o r d'.

Here are the functions

Code:
function load_bad_words(){
   global $bad_words;
    $bad_words = @file_get_contents(CFDSPATH . "badwords.lst");
    $bad_words = preg_split( '/\r\n|\r|\n/', $bad_words );
}

function strip_abbusive_words($str){
   global $bad_words;
   foreach($bad_words as $bad_word){
      $bad_word_regex = '/' . ($bad_word[0] == '*' ? '': '\b') . str_replace('*', '', $bad_word) . ($bad_word[(strlen($bad_word)-1)] == '*' ? '': '\b') . '/i';
      $str = preg_replace($bad_word_regex, '', $str);
   }
   return $str;
}


Can any one enhance these functions to filter bad words with combinations of spaces and special characters?
_________________
I am a professional developer of web content having expertise in PHP and Javascript working as Manager for a Technical dept of a software development company. My newest development is Free Classifieds
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 295
Location: Chicago, IL

PostPosted: Sun Oct 02, 2011 9:04 am    Post subject: Reply with quote

How would one do assassinate or assume if you're stripping out spaces to remove bad words?

No matter how much filtering you put in, people will find a way to f*ck with your code until you realize you couldn't do 5hit about it.

^If you catch my drift with the words I put in there :P
_________________
Portfolio: Robert Lerner
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group