############################################################################### # # # D I R T Y W O R D C E N S O R # # # # Last modified: 10 Aug 1999 # ############################################################################### ############################################################################### # # # The purpose of this modification is to censor any words that you might not # # want to appear in your database. There are 6 different levels of censoring # # you can choose from. Each is described within the modification itself. # # # # The wordlist is completely editable, so that you can decide for yourself # # which words you consider "dirty." There is a list to start with, but you can# # add or delete any words you want. # # # ############################################################################### ############################################################################### # file: default.cfg # # # # somewhere in the authentication definitions # # add the following # ############################################################################### # Censor dirty words # 0 = do not censor # 1 = reject records that contain any of the words # 2 = replace words with *** # 3 = replace the middle letters with *s, as in "f**k" "a*****e" "c********r" # 4 = replace vowels with *s, as in "f*ck" "*ssh*l*" "c*cks*ck*r" # 5 = replace words with the first letter of the word and * for the other letters, as in f*** a******, c********* # 6 = replace each letter with a *, as in **** ******* ********** $db_censor = 1; ## You can edit the @dirty_words list however you want. Just be sure to put ## single quotes around each word, keep the list all on one line, and be sure they ## are in lower case. # Dirty word list @dirty_words = ('fuck','shit','cocksucker','asshole','cunt','pussy','tits','bastard','bitch','piss'); ############################################################################### # file: db.cgi # # # # sub validate_record # # replace the entire subroutine with the following # # Modified 3-8-04 for DBMan SQL Version 1 by shann123 # # # Note: there is another change in this subroutine from the DBMan 2.04 script # # which will allow for empty date fields. # ############################################################################### sub validate_record { # -------------------------------------------------------- # Verifies that the information passed through the form and stored # in %in matches a valid record. my ($col, @input_err, $errstr, $err, $line, @lines, $id, @rest); if ($in{'add_record'} and !$db_supply_key) { my $query = "SELECT 1 FROM $db_table WHERE $db_key = ?"; $sth = $DBH->prepare($query); $sth->execute($in{$db_key}); if ($sth->rows()) { return (@input_err, "duplicate key error"); } } foreach $col (@db_cols) { if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace if ($db_not_null{$col}) { # entry is not allowed to be null. push(@input_err, "$col (Can't be Blank)"); # so let's add it as an error } } else { # else entry is not null. if ($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) { push(@input_err, "$col (Invalid Format)"); # but has failed validation so add } # it as an error. } if ($db_lengths{$col} and (length $in{$col} > $db_lengths{$col})) { push(@input_err, "$col (Too long. Max length: $db_lengths{$col})"); } ############################################################################### # Censoring routine # ############################################################################### if ($db_censor) { foreach $dirty_word (@dirty_words) { if (lc($in{$col}) =~ /$dirty_word/) { if ($db_censor == 1) { push(@input_err, "$col (Includes a banned word -- $dirty_word)"); } else { if ($db_censor == 2) { $replace = "***"; } elsif ($db_censor == 3) { $replace = substr($dirty_word,0,1).("*" x (length($dirty_word)-2)).substr($dirty_word,length($dirty_word)-1,1); } elsif ($db_censor == 4) { $replace = $dirty_word; $replace =~ s/a|e|i|o|u/\*/ig; } elsif ($db_censor == 5) { $replace = substr($dirty_word,0,1).("*" x (length($dirty_word)-1)); } else { $replace = ("*" x (length($dirty_word))); } $in{$col} =~ s/$dirty_word/$replace/ig; } } } ############################################################################### # end Censoring routine # ############################################################################### } } if ($#input_err+1 > 0) { # since there are errors, let's build foreach $err (@input_err) { # a string listing the errors $errstr .= "
  • $err"; # and return it. } return ""; } else { return "ok"; # no errors, return ok. } }