|
[ Autoren gesucht! ]
|
PHP-Homepage.de sucht laufend Autoren für News und Artikel
Interesse?
|
|
 |
|
[Start] [Suche] [Neue Einträge]
| bad_word_filter | <?php
######################################################
#
# Function to check text content for bad words and replace it
# very useful for Guestbook Scripts.
#
# simply edit the $word_list array and add the words you don`t want
# to read on your website. $contra is the string to replace bad word
#
# example text checking:
# $temp_text = check_content($content);
# if ($temp_text != FALSE) {
# $content = nl2br(addslashes($temp_text));
# } else {
# $content = nl2br(addslashes($content));
# }
#
# function written by Henning Jödden henning@wonderpixel.de
# no copyrights, use it as you like
#
# function is written in PHP3 so it can be used on most Webservers
# with PHP4 you can modify it with substr_replace() AND/OR stristr() to
# make it faster.
#
# send any comments to henning@wonderpixel.de thnx for using this snippet.
#
######################################################
$word_list = array ("sex","porn","fuck","xxx","fick","verdammt","scheiß","scheiss","verflucht","schwul","schwuchtel","gay","arsch","wix","wichs","blöd","bloed","kack","piss","schrott","mist");
$contra = "*&%§$%*";
function check_content($field) {
global $word_list, $contra;
$list_size = count($word_list);
$count = 0;
for ($q=0; $q<=$list_size-1; $q++) {
$bad_word_check = strstr($field,$word_list[$q]);
if ($bad_word_check != FALSE) {
$position = strpos($field,$word_list[$q]);
$first = substr($field,0,$position);
$scnd = substr($field,$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);
$field = $first . $bad_word . $scnd;
$count++;
}
}
if ($count > 0) {
return $field;
} else {
return FALSE;
}
}
?> |
|