#! /usr/local/bin/perl # Oregon Country Fair Guestbook (ocfgbook.cgi) by k_rogers@efn.org $filename = "ocfgbook.html"; $filename_url = "http://www.efn.org/~ocf/ocfgbook.html"; $date = `/usr/bin/date`; chop ($date); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Enter our tags and sections into an associative array %sections = ( "A","COMMENTS", "B","QUESTIONS",); open (FILE,"$filename") || die "can\'t open $filename: $!\n"; while () { $raw_data .= $_; } close(FILE); undef $/; @proc_data = split(/\n/,$raw_data); open (FILE,">$filename"); foreach $line (@proc_data) { print FILE "$line\n"; foreach $tag (keys(%sections)) { if ( ($FORM{section} eq $sections{$tag}) && ($line =~ //) ) { print FILE "
$date $FORM{realname} "; if ($FORM{username} ne "") { print FILE "$FORM{username}\n"; } else { print FILE "\n"; } print FILE "
$FORM{where}\n

\n"; if ($FORM{userurl} ne "") { print FILE "$FORM{userurl}

\n"; } if ($FORM{affiliation} ne "") { print FILE "Fair Affiliation: $FORM{affiliation}\n

\n"; } if ($FORM{how} ne "") { print FILE "Heard about this page from: $FORM{how}\n

\n"; } print FILE "$FORM{comments}
\n


\n"; } } } close (FILE); print "Location: $filename_url\n\n";