the code below is where the script does the replacement. Can this be done and if so could someone point me in the direction. As a perl dummy I have tried several thing without success. I thought I could use some sort of counter and if the count was > 1 just send an error.
Any help would be appreciated
Thanks in advance
my $word;
foreach $word(@badwords){ $FORM{$_} =~ s/$word/$censored/gisex; }
$line .="$FORM{$_}$separator";
$field{$_}=1;
if ($FORM{$_} ¦¦ (!$only_fields_with_values)) {
$message.="$_: " unless $send_just_data;
$message.="$FORM{$_}\n";
my ($word,$score,$wordlimit);
$score = 0;
$wordlimit=5; # for example
foreach $word(@badwords){
if ($FORM{$_} =~ /$word/ig) { $score++; }
}
if ($score > $wordlimit) { &return_to_form; }
... Where "&return_to_form" is a call to the sub that generates the form, fields populated. &return_to_form should output the form and immediately exit so there's no need for an "else" following the if:
sub return_to_form {
my ($form);
$form = qq¦
<html><head><title>Error</title></head>
<body>
<form method="post" action="yourscript.cgi">
<input type="text" name="fname" value="$FORM{'fname'}">
(and so on)
</form>
</body>
</html>
¦;
print "content-type: text/html\n\n";
print $form;
exit 0;
}
Set $wordlimit to 0 to have it stop if any of the words are found.
as a side note, all word censors/filters are fairly easy to circumvent.
But you can slow them down. :-)
$in = 'this is my in with the word [test it]';
@bad_words = ('add','words','here');
foreach $word (@bad_words) {
@letters = split ('',$word);
$regexp = join ('.*',@letters);
$in =~ s/$regexp/\*\*\*\*\*\*/ig;
}
print "$in";