#!/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 ########################################### # Change the below line to how many characters a word can be before it's split up $Text::Wrap::columns = 15; # swear words my @words = ("bad words go here"); # saved name list my @list = ("Sulfericacid", "sulfericacid", "Sulfy", "Sulfer", "sulfy", "sulfer", "admin", "Admin", "webmaster", "Webmaster", "administrator", "Administrator"); my $url = "/cgi-bin/scripts/chat/v2/chat.pl"; ## Change the above line to the full URL of the chat script my $imagedir = "/scripts/chat/v2/images"; # location of image directory (emoticons) ## Change the above line to the full URL of the /images/ folder for the chat script my $ip = "66.47.159.11"; ## Change to the administrator IP address my $chathelp = "scripts/chat/v2/chathelp.html"; my $log = "cgi-bin/scripts/chat/v2/log.pl"; ## Change the two above lines to point to the chathelp.html and log.pl files my $pagead = "www.mypage.com"; ########################################## # 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; 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 Administrator"; 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/$2<\/a>/gi; $message =~ s/\[(ftp:\/\/.+)\]/$1<\/a>/gi; $message =~ s/\[(https:\/\/.+)\]/$1<\/a>/gi; my $info = join ( '~~', $name, $message, $ENV{REMOTE_ADDR}); $chat{$cnt} = $info; 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 = wrap('', '', $name); $message =~ s/$_/****/g for @words; # say goodbye to swear words next if ($message =~ /\[http:\/\/|https:\/\/\ftp:\/\/\|.+\]/); $message = wrap('', '', $message); $message =~ s#:\)##g; # happy emoticon $message =~ s#:\(##g; # sad emoticon $message =~ s#:p##g; # tongue1 emoticon $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 emoticon $message =~ s#\*devil\*##g;# devil emoticon $message =~ s#\*love\*##g; # love emoticon $message =~ s#\*sleep\*##g;# sleep emoticon $message =~ s#\*conf\*##g;# sleep emoticon 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 $message\n")), }} else { if (grep { $name eq $_ } @list) { print Tr(td({-width=>'700'},"<$name> $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 script.
ALL exit; } } close(BANNED); print <<"ALL";
Name:
Message:


ALL