Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Replace

Empfohlene Antworten

Veröffentlicht

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

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]

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]

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.