Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Time and date in shoutbox

by Woekaah (Initiate)
on Sep 05, 2005 at 09:40 UTC ( [id://489180]=perlquestion: print w/replies, xml ) Need Help??

Woekaah has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I'm trying to putt in the date and time of posting a message in the shoutbox that I'm using, it is a modifyed version of Chatterbox 2.0. I've tryed all kinds of ways to get it in there but had no succes, so maybe one of you can do the job. It must be somewhere in the join section I guess. Thanks in advance. I've tryed to get it looking like this
<12|07|2005~23|56|47~Woekaah> Message

Below is the script (sorry for the messy markup, cut and paste don't always look that smooth):

#!/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 = 100; my %chat; my %chatorder; ########################################### # Configuration section ########################################### $Text::Wrap::columns = 100; my @words = ("scheldwoordenlijst"); my @list = ("Webmaster"); my $url = "http://www.provider.nl/cgi-bin/shout/chat.pl"; ## Change the above line to the full URL of the chat script my $imagedir = "http://www.provider.nl/shoutbox/emoticons"; # + location of image directory (emoticons) ## Change the above line to the full URL of the /images/ folder for th +e chat script my $ip = ""; ## Change to the administrator IP address my $chathelp = "http://www.provider.nl/shoutbox/chathelp.html"; my $log = "http://www.provider.nl/cgi-bin/shout/log.pl"; ## Change the two above lines to point to the chathelp.html and log.pl + files my $pagead = "Typ je naam en je bericht hieronder"; ########################################## # 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="<script langauge=\"Javascript\"> document.write('<form><input type=button value=\"Refresh\" onClick=\"w +indow.location.reload()\"></form>');</script></noscript></noscript>"; my $name = param('Naam'); 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 "<font color=red>Je hebt geen rechten om als Administrator te +posten</font>"; exit; } if ($message ne "") { open( LOG, "$file" ); # open count log for ID $cnt = <LOG>; close(LOG); $cnt++; open( LOG, "> $file" ); print LOG $cnt; close(LOG); $name =~ s/</&lt\;/g; # removing exploit $name =~ s/~/\&#126\;/g; # database splitting $message =~ s/</&lt\;/g; # removing exploit $message =~ s/~/\&#126\;/g; # database splitting my $info = join ( '~~', $name, $message, $ENV{REMOTE_ADDR}); $chat{$cnt} = $info; print "<SCRIPT LANGUAGE=\"JAVASCRIPT\">"; print "document.location.href=\"$redirect\";"; print "</SCRIPT>"; } else { print "<SCRIPT LANGUAGE=\"JAVASCRIPT\">"; print "document.location.href=\"$redirect\";"; print "</SCRIPT>"; } } else { print "<SCRIPT LANGUAGE=\"JAVASCRIPT\">"; print "document.location.href=\"$redirect\";"; print "</SCRIPT>"; } } # Start printing everything out my $cnt = 0; foreach (keys %chat) { $cnt++; } print start_table; print Tr(td({-height=>'5', width=>'450', bgcolor=>'#FF6600'},"<font si +ze=2><b><center>Shouts</center></b></font>\n" )); for (grep defined($_), (keys %chat)[-50..-1]) { my ( $name, $message, $userip) = split /~~/, $chat{$_}; $name =~ s/$_/oeps/g for @words; # say goodbye to swear words $name = wrap('', '', $name); $message =~ s/$_/oeps/g for @words; # say goodbye to swear words $message = wrap('', '', $message); $message =~ s#:01:#<img src="$imagedir/01.gif">#g; $message =~ s#:02:#<img src="$imagedir/02.gif">#g; $message =~ s#:03:#<img src="$imagedir/03.gif">#g; $message =~ s#:04:#<img src="$imagedir/04.gif">#g; $message =~ s#:05:#<img src="$imagedir/05.gif">#g; $message =~ s#:06:#<img src="$imagedir/06.gif">#g; $message =~ s#:07:#<img src="$imagedir/07.gif">#g; $message =~ s#:08:#<img src="$imagedir/08.gif">#g; $message =~ s#:09:#<img src="$imagedir/09.gif">#g; $message =~ s#:10:#<img src="$imagedir/10.gif">#g; if ($message =~ m/(^\/me)/) { $name = "<i>$name"; $message =~ s/$1//; $message = "$message<\i>"; if (grep { $name eq "<i>$_" } @list) { print Tr(td({-width=>'550'},"<font size=2 color=yellow>$name</font +><font size=2> $message</font><hr color=#FF0000 noshade size=1>\n")), } else { print Tr(td({-width=>'550'},"<font size=2 color=yellow>$name</font +><font size=2> $message</font><hr color=#FF0000 noshade size=1>\n")), }} else { if (grep { $name eq $_ } @list) { print Tr(td({-width=>'550'},"<font size=2 color=yellow>&lt;$name&g +t;</font><font size=2> $message</font><hr color=#FF0000 noshade size= +1>\n")), } else { print Tr(td({-width=>'550'},"<font size=2 color=yellow>&lt;$name&g +t;</font><font size=2> $message</font><hr color=#FF0000 noshade size= +1>\n")), } } } print Tr(td({-height=>'5', width=>'550', bgcolor=>'#FF6600'},"<font si +ze=1><p align=center><b>$pagead</b></font>\n" )); print "</table>"; my $location = join("", "http://", $ENV{'SERVER_NAME'}, $ENV{'REQUEST_ +URI'}); open(BANNED, "<$banned") or die "Cannot open $banned because: $!"; while(<BANNED>) { chomp; if ($_ eq $ENV{REMOTE_ADDR}) { print <<"ALL"; <table width="20"> <td>Jou IP adres is verbannen, je mag geen gebruik maken van deze + box.</td> </table> ALL exit; } } close(BANNED);

Edit by holli - added code and readmore tags

Replies are listed 'Best First'.
Re: Time and date in shoutbox
by Jaap (Curate) on Sep 05, 2005 at 11:20 UTC
    Hi Woekaah,

    I see this is your first post here.
    Monks here are very much more likely to help you if you show us what you tried yourself, where it went wrong and what exactly you don't understand.

    Since this is your first post, i'll give you some hints:
    1. Find the line that prints the username and message. (it might look like print Tr(td({-width=>550'}, ...)
    2. Create a date string
    3. Put it in the print statement.
      Hi all, I've done it in Javascript, and that work oke so the "problem" is solved.
      Anyway, thanks for the advice.

      Regards, John

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://489180]
Approved by holli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-24 07:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found