#!/usr/bin/perl -w # # Chatterbox version 2.0 # use strict; use warnings; use POSIX; use CGI qw(:standard start_table end_table); use CGI::Carp qw(fatalsToBrowser); use lib ""; use DB_File; use Text::Wrap; $Text::Wrap::columns = 15; my %chat; my %chatorder; ########################################### # Configuration section ########################################### $Text::Wrap::columns = 15; my @words = (bad words removed so you don't see them); my @list = ("Sulfericacid", "sulfericacid", "Sulfy", "Sulfer", "sulfy +", "sulfer", "admin", "Admin", "webmaster", "Webmaster", "administrat +or", "Administrator"); my $url = "http://sulfericacid.perlmonk.org/chat/chat.pl"; ## Change the above line to the full URL of the chat script my $imagedir = "http://sulfericacid.perlmonk.org/chat/images"; + # location of image directory (emoticons) ## Change the above line to the full URL of the /images/ folder for th +e chat script my $ip = "66.47.159.11"; ## Change to the administrator IP address my $chathelp = "chat/chathelp.html"; my $log = "chat/log.pl"; ## Change the two above lines to point to the chathelp.html and log.pl + files my $pagead = "http://sulfericacid.perlmonk.org"; ########################################## # Please do not edit below this line ########################################## my $redirect = param('location'); my $chat = "chat.db"; # location of database my $file = "count.txt"; # location of count file my $banned = "banned.txt"; # location of banned IP list tie %chat, "DB_File", "$chat", O_CREAT|O_RDWR, 0644, $DB_BTREE or die "Cannot open file 'chat': $!\n"; print header, start_html('sulfericacid.perlmonk.org -Oil of vitrol - A +cid cleanup for code on the web'); my $js=""; my $name = param('name'); my $message = param('message'); my $cnt; ## Get the user information if (param) { if ($name ne "") { if (grep { $name eq $_ } @list and $ENV{REMOTE_ADDR} ne "$ip" ) { print "You are not authorized to post as the Adminis +trator"; exit; } if ($message ne "") { open( LOG, "$file" ); # open count log for ID $cnt = ; close(LOG); $cnt++; open( LOG, "> $file" ); print LOG $cnt; close(LOG); $name =~ s/"; print "document.location.href=\"$redirect\";"; print ""; } else { print ""; } } else { print ""; } } # Start printing everything out my $cnt = 0; foreach (keys %chat) { $cnt++; } print qq[(chat help) ]; print "(chat logs)"; print start_table; print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'},"ChatterBox version 1.73\n" )); print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'},"\n")); for (grep defined($_), (keys %chat)[-10..-1]) { my ( $name, $message, $userip) = split /~~/, $chat{$_}; #$name =~ s/$_/****/g for @words; # say goodbye to swear words $name =~ s[\b$_\b][****]sgi for @words; # say goodbye to swear words $name = wrap('', '', $name); #$message =~ s/$_/****/g for @words; # say goodbye to swear words $message =~ s[\b$_\b][****]sgi for @words; # say goodbye to swear word +s $message = wrap('', '', $message); $message =~ s#:\)##g; # happy emoticon $message =~ s#:\(##g; # sad emoticon $message =~ s#:p##g; # tongue1 emotic +on $message =~ s#:o##g; # oh emoticon $message =~ s#:O##g; # oh1 emoticon $message =~ s#\*hug\*##g; # hug emoticon $message =~ s#\*flower\*##g; # flower + emoticon $message =~ s#\*wink\*##g; # wink emoti +con $message =~ s#\*devil\*##g;# devil emot +icon $message =~ s#\*love\*##g; # love emot +icon $message =~ s#\*sleep\*##g;# sleep emot +icon $message =~ s#\*conf\*##g;# sleep em +oticon if ($message =~ m/(^\/me)/) { $name = "$name"; $message =~ s/$1//; $message = "$message<\i>"; if (grep { $name eq "$_" } @list) { print Tr(td({-width=>'700'},"$name $message\n")), } else { print Tr(td({-width=>'700'},"$name< +font size=2> $message\n")), }} else { if (grep { $name eq $_ } @list) { print Tr(td({-width=>'700'},"<$name>< +/font> $message\n")), } else { print Tr(td({-width=>'700'},"<$name> + $message\n")), } } } print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'},"")); print Tr(td({-height=>'5', width=>'700', bgcolor=>'#BBCCEE'},"

$pagead\n" )); print ""; my $location = join("", "http://", $ENV{'SERVER_NAME'}, $ENV{'REQUEST_ +URI'}); open(BANNED, "<$banned") or die "Cannot open $banned because: $!"; while() { chomp; if ($_ eq $ENV{REMOTE_ADDR}) { print <<"ALL";
Your IP has been banned, you are not allowed to use this scri +pt.
ALL exit; } } close(BANNED); print <<"ALL";
Name:
Message:


ALL