:) :( :P :O *hug* *flower* ;) *evil* *love* *yawn* *test* *conf* #### if (param()) { my $username = param("name"); my $message = param("message"); my $time = localtime(); my $ip = $ENV{REMOTE_ADDR}; ### # add their information to the db ### my $data = qq(INSERT INTO chat (username, ip, date, message) VALUES (?,?,?,?)); my $sth = $dbh->prepare($data); $sth->execute("$username","$ip","$time","$message") or die $dbh->errstr; print "success!

"; } #foreach (@a) { print "$_
"; } #### # print chat #### my $data = qq(SELECT id, username, ip, date, message FROM chat ORDER BY id DESC LIMIT 10); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($id, $username, $ip, $date, $message); $sth->bind_columns(\$id, \$username, \$ip, \$date, \$message); ###### # Because we need to reverse our SELECT we need to store it in @keep ###### my @keep; my @keep_after_swear_words; while ($sth->fetch) { push(@keep, "$username$message$date$ip"); } ####### # connecting to the DB again so we can filter swear words ####### my $data = qq(SELECT id, word FROM swears); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($id, $badword); $sth->bind_columns(\$id, \$badword); foreach my $line (reverse @keep) { my ($username, $message, $date, $ip) = split(//, $line); #print "user: $username
message: $message
date: $date
ip: $ip

"; while ($sth->fetch) { push (@badwords, $badword); } #print "message: $message
"; #push(@keep_after_swear_words, "$username$message$date$ip"); } foreach my $line (@keep) { $line =~ s/\b$_\b/ **** /gi for @badwords; } #################### # connecting to the DB again so we can filter emoticons #################### my $data = qq(SELECT id, name, location, face FROM emoticons); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($id, $name, $location, $face); $sth->bind_columns(\$id, \$name, \$location, \$face); while($sth->fetch) { push (@emoticons, "$name$location$face"); } foreach my $line (reverse @keep) { my ($username, $message, $date, $ip) = split(//, $line); foreach my $emoticon (@emoticons) { my ($name, $location, $face) = split(//, $emoticon); if ($face) { $message =~ s/\b\Q$face\E\b/ \Q$name\E /gi; print "$face
"; } #message =~ s/$face/ $name /gi; # print "$emoticon
"; } if ($message =~ m|^/me|i) { $message =~ s|^/me||i; print qq($username $message
); } else { print qq($username: $message
); } }