Jump to content

[SOLVED] SQL swear filter


Spectre

Recommended Posts

Hey all, using an ajax chat and have the filter set up by db table to replace $before with $after...

 

 

Pretty simple, just not so sure how to make it take the before as non case sensitive so i don't have to put every combination of a word in the before column, any tips? ideas? ways to do this easily?

Link to comment
Share on other sites

That depends on how you're doing your replacement. If you're using ereg_replace(), use eregi_replace(), if you're using preg_replace(), use the case insensitive modifier. If you're using str_replace(), use str_ireplace()

 

Of course, you'll still have users putting spaces/other symbols in between letters to get around your filter anyway.

Link to comment
Share on other sites

you can use an array in something like str_replace, right? So you can have an array or words you want to filter and just one statement?

 

Indeed - but take any swear word and think of all the different ways that you could communicate that swear word without spelling it out exactly (e.g. symbols to represent letters, spaces in between, other symbols inbetween, mis-spelling etc). Now do the same for every other swear word you can think of. That's going to be one very large array.

Link to comment
Share on other sites

you can use an array in something like str_replace, right? So you can have an array or words you want to filter and just one statement?

 

Indeed - but take any swear word and think of all the different ways that you could communicate that swear word without spelling it out exactly (e.g. symbols to represent letters, spaces in between, other symbols inbetween, mis-spelling etc). Now do the same for every other swear word you can think of. That's going to be one very large array.

 

It is indeed a large array, use what GingerRobots previously said (ignoring str_replace):

 

That depends on how you're doing your replacement. If you're using ereg_replace(), use eregi_replace(), if you're using preg_replace(), use the case insensitive modifier. If you're using str_replace(), use str_ireplace()

 

Of course, you'll still have users putting spaces/other symbols in between letters to get around your filter anyway.

 

The idea being ereg, preg, etc... is that it uses PATTERNS to match swear words. While I can almost guarantee that there is no perfect system for all swear words, you can get pretty darn close.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.