edman78 Posted May 27, 2009 Share Posted May 27, 2009 Hello I have a community type website that allows private messages and i want to be able to filter certain words sent in messages. Their are many bad word filters but all apply to the whole site, i need it to be turned on or off per user. For example if i have ".com" filtered out every member won't be able to send ".com" in the message and i dont want that. I want to be able to apply the filter to certain users not the whole site. I plan on charging a fee to upgrade to have the filter turned off that is why i need this. Is this hard to do? Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 27, 2009 Share Posted May 27, 2009 Umm no? Assume you already have a "rank" field in your database? if( rank != "freebee" ) { echo applyFiltering( $data ); } else { echo $data; } As long as you got something to differentiate the paying from the non-paying users it's easy as pie, if you don't have a way to do that.. then well, start making a way as it's impossible without. Quote Link to comment Share on other sites More sharing options...
grissom Posted May 27, 2009 Share Posted May 27, 2009 Try this for an idea : Presumably you've got a database somewhere with the details of all the users on it. Add a field to the database, call it something like "filter". The value in this field can be a boolean (true = filter on) or you can set it to a SMALLINT to have differing levels (0 -9 for example) of filtering. Then in your PHP code, when the user logs in, dig out their credentials from the database. You may (if you so desire) save the value of "filter" in a SESSION variable so you can quickly grab hold of it at any time without having to mess about with the database each time. Now, write a PHP function called something like filtertext(text_input) which strips out any naughty words and returns a text string minus those words Then, all you do is when the user inputs something, test to see if they are filtered or not, and if they are, invoke the function to clean up the text. To turn the filter off, just amend the value in the database table. That's probably not the only way, but its the best I can think of at this hour of night in the UK, hehe : ) Good luck !! 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.