Orionsbelter Posted November 25, 2008 Share Posted November 25, 2008 Ok, i find many users sign up with words like fuck and shit in thier name and sometime they send messages to each other swearing at one another i do replace the swears in the messages but how ever would like to have something that will stop them example if($_POST['username'] contains('fuck')){ echo"badword used";} is there anything like that? Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/ Share on other sites More sharing options...
mtoynbee Posted November 25, 2008 Share Posted November 25, 2008 Simple script to start with $wordlist = array of swear words; foreach ($wordlist as $word) { Do eregi_replace() on $word; } Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698701 Share on other sites More sharing options...
JonnoTheDev Posted November 25, 2008 Share Posted November 25, 2008 That will replace the word. To find words you can use a variety of string functions. You will need a bad words list to compare as the post above suggests. strstr() preg_match() strstr() ereg() preg_match_all() Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698704 Share on other sites More sharing options...
mtoynbee Posted November 25, 2008 Share Posted November 25, 2008 $wordlist = array("poop","ass"); foreach ($wordlist as $word) { if (eregi($bad_word,$string)) { exit("no swearing please"); } } Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698713 Share on other sites More sharing options...
JonnoTheDev Posted November 25, 2008 Share Posted November 25, 2008 Check your code mtoynbee. $bad_word variable is undefined in eregi function. You have defined $word in the foreach loop. Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698716 Share on other sites More sharing options...
MatthewJ Posted November 25, 2008 Share Posted November 25, 2008 Down with censorship! Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698719 Share on other sites More sharing options...
revraz Posted November 25, 2008 Share Posted November 25, 2008 You will never be able to filter it all, all you'll do is make them more creative. Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698723 Share on other sites More sharing options...
mtoynbee Posted November 25, 2008 Share Posted November 25, 2008 Yep saw that error. Sorry - it was only a quick and dirty example. Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698728 Share on other sites More sharing options...
flyhoney Posted November 25, 2008 Share Posted November 25, 2008 There was a rather involved thread on this here: http://www.phpfreaks.com/forums/index.php/topic,225600.0.html Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-698747 Share on other sites More sharing options...
Orionsbelter Posted November 26, 2008 Author Share Posted November 26, 2008 anymore? Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-699088 Share on other sites More sharing options...
DeanWhitehouse Posted November 26, 2008 Share Posted November 26, 2008 I have a massive word list if you want it i can email it as the word filters here will prevent it from being visible. Also i use str_ireplace(); and have an array of bad words. Quote Link to comment https://forums.phpfreaks.com/topic/134225-bad-word-is-text-or-text-field-find-and-stop/#findComment-699089 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.