Veröffentlicht 4. April 200322 j Hallo ! Ich habe mir eine Art Gästebuch programmiert und wollte nun ein Wortfilter einbauen für Bad Words. Nun habe ich mir das hier schonmal gedacht: $kommentar = ereg_replace("badword1","********", $kommentar); Dies funktioniert auch aber ein enormer Aufwand. Gibt es da eine bessere Lösung oder könnte man das vielleicht so machen: $badword = "badword1, badword2, badword3"; $kommentar = ereg_replace("$badword","********", $kommentar); Ich hoffe ihr könnt mir ein paar gute Vorschläge machen wie ich so einen Wortfilter bauen könnte... EDIT: Hab gerade was gefunden: http://www.php-homepage.de/scripts/source.php?scriptid=79
4. April 200322 j arrgs ich habe das nun so gemacht aber das funktioniert nicht ?!? könnt ihr mir sagen warum? ich will die variable $bemerkung checken... $word_list = array ("schwanz","****er","sex","porn","****","xxx","****","verdammt","******","*******","verflucht","schwul","**********","gay","*****","wix","wichs","blöd","bloed","****","****","schrott","mist"); $contra = "*****"; function check_content($kommentar) { global $word_list, $contra; $list_size = count($word_list); $count = 0; for ($q=0; $q<=$list_size-1; $q++) { $bad_word_check = strstr($kommentar,$word_list[$q]); if ($bad_word_check != FALSE) { $position = strpos($kommentar,$word_list[$q]); $first = substr($kommentar,0,$position); $scnd = substr($kommentar,$position); $count_chars = strlen($exclusion[$q]); $bad_word = substr($scnd,0,$count_chars); $scnd = substr($scnd,$count_chars); $bad_word = str_replace($bad_word,$bad_word,$contra); $kommentar = $first . $bad_word . $scnd; $count++; } } if ($count > 0) { return $kommentar; } else { return FALSE; } } [/PHP]
4. April 200322 j benutzt du ne datenbank? dann würde ich das vor dem speichern erledigen. vieleicht in der art: $badwords = array("******", "blasen", "bumsen", "clinton"); $text = "clinten lässt sich einen von monica blasen"; for($i=0; $i < sizeof($badwords); $i++){ $text = str_replace($badwords[$i],"*****",$text); } [/PHP]
4. April 200322 j Originally posted by Art benutzt du ne datenbank? dann würde ich das vor dem speichern erledigen. Okay alles klar ich habs hinbekommen. Vielen Dank! :floet: *froi*
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.