Hi Eliot.
I know this is going to be way off-topic... but I've tried what you suggested, and even spent little while trying to get it working.
I just don't seem to understand this good enough yet! (guess I need to get me a good cgi book!)
Well, here is the complete script that I'm trying to add the 'dirty word' mod into.
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">';
# You do not need to modify anything below this line.
##############################################################################
&ReadParse;
if ($in{'who'} ne "" && $in{'msg'} ne "") {
if (-e $filename) {
open(FILE, $filename) | | die $!;
@lines = <FILE>;
close(FILE);
}
open(F, ">$filename") | | die &PrintErrorPage("Can't write to file '$filename'\n");
print F '<tr bgcolor="' . $bgcolor . '">';
print F '<td align=left nowrap>' . $font_date . &GetDateString . '</font></td>';
print F '<td align=left nowrap>'.$font_msg . $in{'msg'} . '</font></td>';
print F '<td align=right nowrap>'.$font_who . $in{'who'} . '</font></td>';
print F "</tr>\n";
for ($i = 0; $i < $number_of_rows - 1; $i++) {
print F $lines[$i];
}
close(F);
}
print "Location: $ENV{'HTTP_REFERER'}\n\n";
exit;
##############################################################################
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;
}
}
##############################################################################
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>";
}
Code:
<table cellpadding=1 cellspacing=0 border=0 bgcolor="#303030"><tr><td>
<table cellpadding=2 cellspacing=0 border=0 bgcolor="#000000">
<form action="../oneliner.cgi" method=POST>
<tr bgcolor="#1a1a1a">
<td colspan=3 align=center>
<font face="tahoma, verdana, arial, geneva" size=1>
<b>Oneliners</b> - Created By: <a href="http://www.stefan-pettersson.nu/scripts/" target="_blank">Stefan</a>!
</font>
</td>
</tr>
<!--#include virtual="oneliners_incl.html"-->
<tr bgcolor="#1a1a1a">
<td colspan=3 valign="middle">
<font face="tahoma, verdana, arial, geneva" size=1>
msg: <input type="text" name="msg" maxlength=120 size=30 style="font-family:tahoma,verdana;font-size:10px">
who: <input type="text" name="who" maxlength=10 size=7 style="font-family:tahoma,verdana;font-size:10px">
<input type="submit" value="leave msg" style="font-family:tahoma,verdana;font-size:10px">
</font>
</td>
</tr>
</form>
</table>
</td></tr></table>
If you wouldn't mind spending a few seconds pointing out what I need to do.. it would definatly be a leason in cgi for me! (and a big yeehaa! too!)
Later.