random1 Posted December 31, 2007 Share Posted December 31, 2007 Part of my website needs to filter out offensive language from a string (message) in the site and replace swear words with *****. I have one that works from a text file: http://www.geekpedia.com/tutorial163_Foul-language-filter-in-PHP.html but I need it to work for my MySQL database instead. I have a lookup database table that contains the offensive words: table: language_filter fields: id, offensive_word Anyone have any suggestions on how to get a MySQL language filter working? Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/ Share on other sites More sharing options...
trq Posted December 31, 2007 Share Posted December 31, 2007 Anyone have any suggestions? Pertaining to what? You haven't asked a question. Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-426389 Share on other sites More sharing options...
Foser Posted December 31, 2007 Share Posted December 31, 2007 I don't think you will be able to find one which is already coded. Although you can learn Regex (Regular Expression) to make your own filter. Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-426391 Share on other sites More sharing options...
tippy_102 Posted December 31, 2007 Share Posted December 31, 2007 This one: http://gr0w.com/articles/code/php_bad_words_filter/ could easily be adapted to grab the bad word array from your database. Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-426832 Share on other sites More sharing options...
random1 Posted January 1, 2008 Author Share Posted January 1, 2008 Thanks tippy, I tried out: http://gr0w.com/articles/code/php_bad_words_filter/ but this works in the same way catching a swear word in 'scrap' for example. Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-427058 Share on other sites More sharing options...
random1 Posted January 26, 2008 Author Share Posted January 26, 2008 Anyone with a class that perform language filtering? Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-449616 Share on other sites More sharing options...
laffin Posted January 26, 2008 Share Posted January 26, 2008 You might have to use 2 preg statements. one to filter the words from the body of the subject. see preg_replace_callback than use the callback function to test the individual words against a list of bad words, using preg_match. if preg_match catches a bad word, it can return the [censored] tag or what have u, otherwise return the original word sent by preg_replace_callback. thats if u want the flexibility of using regular expressions Quote Link to comment https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-449636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.