#!/usr/bin/perl -w
open( STDERR, ">>/home/sulfericacid/public_html/error.log" )
or die "Cannot open error log, weird...an error opening an error log: $!";
use strict;
use warnings;
use POSIX;
use CGI qw

standard start_table end_table);
use lib "";
use Tie::IxHash;
require SDBM_File;
my %chat;
my %chatorder;
my $chat = "list.dbm";
my $file = "iplog.txt";
tie %chat, "Tie::IxHash";
tie %chatorder, "Tie::IxHash";
tie %chat, 'SDBM_File', $chat, O_CREAT | O_RDWR, 0644;
if ( !tied %chat ) {
print "database unsuccessful $!.\n";
}
$| = 1; # maybe this will help page refreshing
my $js = "<script langauge=\"Javascript\">
document.write('<form><input type=button value=\"Refresh\" onClick=\"history.go()\"></form>');</script></noscript></noscript>";
print header, start_html;
#
# Time to keep accurate logs
#
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
localtime(time);
print "the local time is $hour:$min:$sec";
print start_table;
print Tr(
td(
{ -height => '5', width => '700', bgcolor => '#BBCCEE' },
"<font size=2><b>ChatterBox version 1.0</b></font>"
)
);
print Tr( td( { -height => '5', width => '700', bgcolor => '#BBCCEE' }, "" ) );
my $add;
foreach ( reverse keys(%chat) ) {
$add++;
if ( $add <= 10 ) {
$chatorder{$_} = $chat{$_};
}
}
foreach ( reverse keys(%chatorder) ) {
my ( $name, $message, $time ) = split /::/, $chatorder{$_};
print Tr(
td(
{ -width => '700' },
"<font color=blue>$name @ $time:</font> $message"
)
),
;
}
print Tr( td( { -height => '5', width => '700', bgcolor => '#BBCCEE' }, "" ) );
print Tr(
td(
{ -height => '5', width => '700', bgcolor => '#BBCCEE' },
"<font size=2 palign=right><b>
)
);
print start_form(), table(
Tr(
td("Name: "

,
td(
textfield(
-name => 'name',
-size => 40
)
)
),
Tr(
td("Message: "

,
td(
textfield(
-name => 'message',
-size => 100,
-force => 1,
)
)
),
Tr( td(), td( submit('send'), $js ), ),
end_form(),
hr(),
);
print "(<a href=\"log.pl\" target=\"new\">chat logs</a>)";
my $name = param('name');
my $message = param('message');
my $cnt;
if (param) {
if ($name) {
if ($message) {
open( LOG, "$file" );
$cnt = <LOG>;
close(LOG);
$cnt++;
open( LOG, "> $file" );
print LOG $cnt;
close(LOG);
my $keeptime = join ( ':', $hour, $min, $sec );
my $info = join ( '::', $name, $message, $keeptime );
$chat{$cnt} = $info;
}
else {
print "Message was missing, data not sent.<br>";
}
}
else {
print "Name was missing, data not sent.<br>";
}
}
"Age is nothing more than an inaccurate number bestowed upon each of us at birth as just another means for others to judge and classify us- sulfericacid