#!/usr/local/bin/perl print "HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n"; print "Entry acknowledge\n"; print "

Your contribution has been entered!

\n"; print "Thanks for signing the course logbook.

"; print "Do you want to see the current entries?"; print "


\n"; $guestbook = "/user/www/data/test/guest.txt"; # ------------------------------------------------------------ # Begin main structure # Get input read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split up @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value;} # ------------------------------------------------------------ # Check for blank fields and give a note to the fact. #&blank_response_name unless ($FORM{'myname'} =~ /[^\r\t\n\f]/); # # Write to guestbook file open (OUTFILE, ">>$guestbook"); # Find date @timelist = localtime (time()); $timelist[4] = $timelist[4] + 1; $curdate = join(" ",@timelist[3,4,5,2,1,0]); chop ($curdate); print OUTFILE ("On ", $curdate, "
"); # Write name form if ($FORM{'myname'} =~ /[^\r\t\n\f]/){ $formname = "myname"; &replace_chars; print OUTFILE "$FORM{'myname'}";} else {print OUTFILE "Anonymous";} # Get tag for the accessing machine $machine = $ENV{REMOTE_HOST}; $addr = $ENV{REMOTE_ADDR}; print OUTFILE ("
from ", $machine, "address ", $addr, "
"); # Write output form if ($FORM{'comment'} =~ /[^\r\t\n\f]/){ print OUTFILE "

Wrote:
"; $formname = "comment"; &replace_chars; print OUTFILE "$FORM{'comment'}";} else {print OUTFILE "

No comment";} print OUTFILE "


\n"; close (OUTFILE); # # ----------------------------------------------------------- print "\n"; sub replace_chars { # Remove CRLF, replace with
$FORM{$formname} =~ s/\r\n/
/g; # Remove return, replace with
$FORM{$formname} =~ s/\r/
/g; # Remove newline(s), replace with
$FORM{$formname} =~ s/\n\n/
/g; $FORM{$formname} =~ s/\n/
/g; # Replace Norwegian specials with proper HTML sequences $FORM{$formname} =~ s/æ/æ/g; $FORM{$formname} =~ s/ø/ø/g; $FORM{$formname} =~ s/å/å/g; $FORM{$formname} =~ s/Æ/Æ/g; $FORM{$formname} =~ s/Ø/Ø/g; $FORM{$formname} =~ s/Å/Å/g; $FORM{$formname} =~ s/\{/æ/g; $FORM{$formname} =~ s/\|/ø/g; $FORM{$formname} =~ s/\}/å/g; $FORM{$formname} =~ s/\[/Æ/g; $FORM{$formname} =~ s/\\/Ø/g; $FORM{$formname} =~ s/\]/Å/g;}