skbanta Posted January 31, 2008 Share Posted January 31, 2008 I have a swear filter coded, but where would I put it: Into the code for the form action or the code for displaying the information? Quote Link to comment Share on other sites More sharing options...
drisate Posted January 31, 2008 Share Posted January 31, 2008 How abbout starting to show us how the code is made Quote Link to comment Share on other sites More sharing options...
resago Posted January 31, 2008 Share Posted January 31, 2008 I would filter before wasting cpu cycles trying to do something usefull with it. Quote Link to comment Share on other sites More sharing options...
skbanta Posted January 31, 2008 Author Share Posted January 31, 2008 $swears=array('ass','fuck','shit','a$$','ASS','FUCK','SHIT','$hit','bitch','BITCH','porn','PORN','p0rn','P0rn','faggot','fag','FAGGOT','FAG','sex','SEX'); $newword="****" $newword = str_replace( $swears, '****', $newword ); Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted January 31, 2008 Share Posted January 31, 2008 You have 2 choices on filtering A) you filter on the initial inputting happens once and as suggested saves CPU, however this means to recover the swear (if you want) you need to store it twice B) You filter on presentation resulting in more CPU usage, bu you can make it more dynamic. The amount of CPU usage on a simple filter isn't that much, but its the principle of it Quote Link to comment Share on other sites More sharing options...
drisate Posted January 31, 2008 Share Posted January 31, 2008 Well then you have to catch the message while it's being posted and replace the bad words. If you make the replace everytime you open the page you might slow it down. $_POST[message]= str_replace( $swears, '****', $_POST[message]); $_POST[subject]= str_replace( $swears, '****', $_POST[subject]); ... For the rest already posted make your self a loop programme that you will run only one time to replace all the bad stuff. Quote Link to comment Share on other sites More sharing options...
skbanta Posted January 31, 2008 Author Share Posted January 31, 2008 I don't think I'll ever need to recover the swear, so where would I put it to filter before it is saved to my database? Quote Link to comment Share on other sites More sharing options...
drisate Posted January 31, 2008 Share Posted January 31, 2008 lol when your message is posted and abbout to be entered in the database Quote Link to comment Share on other sites More sharing options...
skbanta Posted January 31, 2008 Author Share Posted January 31, 2008 yeah, so i'd put it in code right after the form? or in the form action code? Quote Link to comment Share on other sites More sharing options...
drisate Posted January 31, 2008 Share Posted January 31, 2008 Just before the INSERT INTO MySQL command Quote Link to comment 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.