htmanning has asked for the wisdom of the Perl Monks concerning the following question:
sub filter_bad_words_suspect { $bad_words_file = "/bad-words-suspect.txt"; $badword_found = 0; open(BADWORDS,"$bad_words_file") || die "*** Could not open bad wo +rds list.\n"; @badwords = <BADWORDS>; close(BADWORDS); foreach $badword (@badwords) { # Strip any extra CR/LF's $badword =~ s/\n//g; $badword =~ s/\r//g; if (($description =~ /$badword/i) || ($email =~ /$badword/i) +|| ($title =~ /$badword/i) || ($contact =~ /$badword/i) || ($organiza +tion =~ /$badword/i)) { $badword_found = 1; # If a bad word is found, highlight all occurances of it #$contact =~ s/($badword)/<B>$1<\/B>/ig; #$email =~ s/($badword)/<B>$1<\/B>/ig; #$title =~ s/($badword)/<B>$1<\/B>/ig; #$description =~ s/($badword)/<B>$1<\/B>/ig; #$organization =~ s/($badword)/<B>$1<\/B>/ig; } # end if (($name =~ /$badword/i) || ($email =~ /$badword/i). +.. } # end foreach $badword (@badwords) &error2(bad_words) if ($badword_found == 1); return; } # end filter_bad_words subroutine sub error2 { require "all-common.sub" || die "Error loading all-common.sub"; $error = $_[0]; $admin_email = "info\@123.com"; open (MAIL, "|$mailprog $admin_email") || die "Can't open +$mailprog!\n"; print MAIL "From: Test Server <admin@123.com>\n"; print MAIL "To: $admin_email\n"; print MAIL "Subject: Error: Suspect Words\n"; print MAIL "Content-type: text/plain\n"; print MAIL "The spam filter was triggered.\n\n"; print MAIL "Name: $name\n"; print MAIL "Username: $username\n"; print MAIL "Email: $email\n"; print MAIL "IP: $IP\n"; print MAIL "Badword: $badword\n"; close (MAIL); return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Badwords Routine
by toolic (Bishop) on Aug 15, 2009 at 03:41 UTC | |
by htmanning (Friar) on Aug 15, 2009 at 05:40 UTC | |
by ig (Vicar) on Aug 15, 2009 at 06:28 UTC | |
|
Re: Badwords Routine
by Perlbotics (Archbishop) on Aug 15, 2009 at 20:21 UTC |