CBaZ Posted September 6, 2007 Share Posted September 6, 2007 the $blockwords are like so $blockwords=array('word','word'); function has_bad_words($quote) { global $blockwords; $split = preg_split("#\s+#", $post, -1, PREG_SPLIT_NO_EMPTY); if (is_array($split)) { foreach ($split as $quote_word) { if (in_array($quote_word, $blockwords)) { return true; } } } return false; } if (has_bad_words($quote_word)) { echo "<BR><BR><p><center></center></p>"; echo "<li>Your Submission Encountered The Following Problem:<center><strong>$name, </strong>Left<strong> $quote_word <br>..Spam Detected..</strong><br><font color=red>$ip</font> Banned</center></li>"; echo "<p><center></center></p>"; $date = date("d.m.Y H:i:s"); $bp = fopen("banip/banip.txt", "a"); $domain = gethostbyaddr($_SERVER['REMOTE_ADDR']); $ip = $_SERVER['REMOTE_ADDR']; $browser = getenv("HTTP_USER_AGENT"); fwrite($bp, "\n$ip, $date, $browser, $domain"); fclose($bp); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/ Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 please state the problem? Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343174 Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 <?php function has_bad_words($quote) { global $blockwords; $split = preg_split("#\s+#", $quote, -1, PREG_SPLIT_NO_EMPTY); if (is_array($split)) { foreach ($split as $quote_word) { if (in_array($quote_word, $blockwords)) { return true; } } } return false; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343177 Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Looks like just a typo to me: This line: $split = preg_split("#\s+#", $post, -1, PREG_SPLIT_NO_EMPTY); Should be: $split = preg_split("#\s+#", $quote, -1, PREG_SPLIT_NO_EMPTY); Of course, this function isn't going to help much if someone doens't put a space between their swear words. darkfreaks : That wouldn't help. If you used that function, then it would only ever compare the first word in the string, because the function returns something after that first word. Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343178 Share on other sites More sharing options...
CBaZ Posted September 6, 2007 Author Share Posted September 6, 2007 how could i make it multiple words? one word just like you say isn't really going to help me and the space thing is another issue Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343210 Share on other sites More sharing options...
CBaZ Posted September 6, 2007 Author Share Posted September 6, 2007 i think this script is not even being checked for in my current form i type in a word everything till gets posted. Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343213 Share on other sites More sharing options...
darkfreaks Posted September 6, 2007 Share Posted September 6, 2007 <?php $cast = 'Profanity, Profanity2, Profanity3'; // Naughty Sailor Talk $st_str = trim($cast, ' '); // Trim white spaces $strs = explode(',', $cast); // Explode into an array by delimiter $content = 'What the Profanity is going on' //the text to apply it to. for($i=0; $i<sizeof($strs); $i++) { $str = ' '.$strs[$i].' '; $text = eregi_replace($str,' ',$text); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343216 Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Well, you could look into using regular expressions to search for your swear words - this would remove issues of capitalization and use of spaces before/after words, however, people will ALWAYS be able to beat the filters. You can't possibly block all possible variations on spelling and use of symbols that could be read by humans. You have to decide how important it is to block the words. Im pretty sure there are existing language filters out there. Perhaps you could have a look for one. Quote Link to comment https://forums.phpfreaks.com/topic/68259-badword-script-function-non-functional/#findComment-343224 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.