Hi Dan.
Thanks for the suggestion.
However, I'm still getting the same error message.
Code:
#!/usr/local/bin/perl
#
# Oneliner
#
# Copyright (c) Stefan Pettersson 2000
#
# You may not redistribute this script, but it's free to use.
#
# Version History:
# v0.9 2000-01-26 - Initial public beta version.
#
# For further information see:
# http://www.stefan-pettersson.nu/scripts/
#
##############################################################################
# Filename to write the messages to. This file is then included by a HTML page.
$filename = '/export/www/humbee/humbee/oneliner/oneliners_incl.html';
# How many message should be displayed at once
$number_of_rows = 8;
# How the date and time will be displayed
$dateformat = '[monthnameshort] [day], [hour0]:[min0] [ampm]';
# Names of weekdays
@daynames = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
# Names of months
@monthnames = qw(January February March April May June July August September October November December);
# Background color of the entered messages, specified in hex as in HTML
$bgcolor = '#000000';
# Font tag to use for date
$font_date = '<font face="tahoma, verdana, arial, geneva" size=1 color="#4FE59D">';
# Font tag to use for the actual message
$font_msg = '<font face="tahoma, verdana, arial, geneva" size=1 color="#EFEF80">';
# Font tag to use for the nickname
$font_who = '<font face="tahoma, verdana, arial, geneva" size=1 color="#EF80EF">';
# Dirty Word Censor
@dirty_words = ('@!#$','@!#$','cocksucker','@!#$','cunt','pussy','tits','bastard','bitch','piss','fuck','ass');
# You do not need to modify anything below this line.
##############################################################################
&ReadParse;
## ADDED FOR 'DIRTY WORD' CODE
$bwords = $in{'who'};
$bwords2 = $in{'msg'};
foreach $bwords (@dirty_words) {
if ($in{'who'} =~ / $bwords/i) {
&submit_error;
return;
}
}
foreach $bwords2 (@dirty_words) {
if ($in{'msg'} =~ / $bwords2/i) {
&submit_error;
return;
}
}
if ($in{'who'} ne "" && $in{'msg'} ne "") {
if (-e $filename) {
open(FILE, $filename) | | die $!;
@lines = <FILE>;
close(FILE);
}
&submit_success;
}
## END 'DIRTY WORD' CODE
##############################################################################
sub GetDateString {
my $formatstring = $dateformat;
my %datestr;
my ($sec, $min, $hour, $day, $month, $year, $weekday) = localtime($^T);
$datestr{'sec'} = $sec;
$datestr{'sec0'} = sprintf("%02d", $sec);
$datestr{'min'} = $min;
$datestr{'min0'} = sprintf("%02d", $min);
$datestr{'hour24'} = $hour;
$datestr{'hour240'} = sprintf("%02d", $hour);
$datestr{'ampm'} = ($hour > 12) ? 'pm' : 'am';
$hour -= 12 if $hour > 12;
$hour = 12 if ($hour == 0);
$datestr{'hour'} = $hour;
$datestr{'hour0'} = sprintf("%02d", $hour);
$datestr{'day'} = $day;
$datestr{'day0'} = sprintf("%02d", $day);
$datestr{'dayname'} = $daynames[$weekday];
$datestr{'daynameshort'} = substr($daynames[$weekday], 0, 3);
$datestr{'month'} = $month + 1;
$datestr{'month0'} = sprintf("%02d", $month + 1);
$datestr{'monthname'} = $monthnames[$month];
$datestr{'monthnameshort'} = substr($monthnames[$month], 0, 3);
$datestr{'year'} = 1900 + $year;
$datestr{'shortyear'} = sprintf("%02d", $year % 100);
while ($formatstring =~ /\[([^\]]+)\]/) {
my $tag = $1;
$formatstring =~ s/\[$tag\]/$datestr{$tag}/;
}
return $formatstring;
}
##############################################################################
sub ReadParse {
my $buf, @pairs;
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buf);
}
foreach (@pairs) {
local($key, $val) = split(/=/);
$key =~ tr/+/ /;
$val =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Strip dangerous characters, removes HTML and SSI for example
$val =~ s/<([^>]|\n)*>//g; # Strip SSI and HTML
$in{$key} = $val;
}
}
#################################################################
# 'Dirty Word' MOD
sub submit_success
#-------------------------------------------
# Submits data
open(DB, ">$filename") or &PrintErrorPage("Can't write to file '$filename'\n");
print DB '<tr bgcolor="' . $bgcolor . '">';
print DB '<td align=left nowrap>' . $font_date . &GetDateString . '</font></td>';
print DB '<td align=left nowrap>'.$font_msg . $in{'msg'} . '</font></td>';
print DB '<td align=right nowrap>'.$font_who . $in{'who'} . '</font></td>';
print DB "</tr>\n";
for ($i = 0; $i < $number_of_rows - 1; $i++) {
print DB $lines[$i];
}
close(DB);
}
&thank_you;
exit;
}
sub submit_error {
#--------------------------------------------
# Error Message
print "Content-type: text/html\n\n";
print qq|
<html>
<head>
<title>Submission Error</title>
</head>
<body bgcolor="ffffff">
<center>
<h1>Submission Error</h1>
</center>
<br>
You have posted inappropriate language in one of the fields. Use your back button in your browser to fill out the form again.
</body>
</html>
|;
}
sub thank_you {
#--------------------------------------------
# Error Message
print "Content-type: text/html\n\n";
print qq|
<html>
<head>
<title>Thank you!</title>
</head>
<body bgcolor="ffffff">
<center>
<h1>Thank you!</h1>
</center>
<br>
Thank you for submitting your message.
</body>
</html>
|;
}
######################
## End Dirty Word MOD
######################
##############################################################################
sub PrintErrorPage {
print "Content-type: text/html\n\n";
print "<html><head><title>Script error!</title></head><body>";
print "<b>Script error!</b><p>\n";
print $_[0];
print "</body></html>";
}