#!/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";
}
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'},"ChatterBox version 1.0" ));
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'},"$name @ $time: $message")),
}
print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'},""));
print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'}," http://sulfericacid.perlmonk.org" ));
print start_form(), table(
Tr(
td("Name: "),
td(
textfield(
-name => 'name',
-size => 40
)
)
),
Tr(
td("Message: "),
td(
textfield(
-name => 'message',
-size => 100
)
)
),
qq(),
qq(chat logs),
if ( param() ) {
my $name = param('name');
my $message = param('message');
my $cnt;
open( LOG, "$file" );
$cnt = ;
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;
}