#!/usr/bin/perl -T $ENV{PATH} = "/bin:/usr/bin"; print "Content-type:text/html\n\n"; 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; $FORM{$name} = $value; } print "Man Page: $FORM{'topic'}\n"; print "\n"; # The only allowed topics will be words that are alphanumeric # (a-zA-Z0-9). Dashes and periods are also allowed; spaces # are not. if ($FORM{'topic'} =~ /^([\w\-\.]+)$/) { $topic = $1; } else { dienice("Bad topic: $FORM{'topic'}"); } print "

$topic

\n"; @out = `/usr/bin/man $topic`; # now print pre tags so the output is preformatted. print "
\n";

foreach $i (@out) {
# man pages are formatted with nroff, so we have to remove the 
# nroff control characters from them with this substitution:
    $i =~ s/.\cH//g;;
    
    # now print the line
    print $i;
}
print "
\n"; print "\n"; sub dienice { my($errmsg) = @_; print "

Error

\n"; print "$errmsg

\n"; print "\n"; exit; }