#!/usr/bin/perl

print "Content-type: text/html\n\n" ;

&ReadParse(*input);

$file = $input{"file"};

$file =~ s/[^a-z0-9\.\-]//g;




open(READIN,$file);
print<<__EOQ__;
<HTML>
<HEAD>
<TITLE>$title</TITLE>
</HEAD>
<BODY  BGCOLOR="#FFFFFF">       
	<FONT FACE="arial,helvetica,sans-serif">
__EOQ__



while($nextline = <READIN>){
	print $nextline;
}

print<<__EOQ__;
</FONT>

<div align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF = "index.html">back</A><BR>
</div>


__EOQ__

    close READIN;











sub ReadParse {
  local (*in) = @_ if @_;
  local ($i, $key, $val);
  # Read in text
  if ($ENV{'REQUEST_METHOD'} eq "GET") {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  }
  @in = split(/&/,$in);
  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;
    # Split into key and value.  
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/%(..)/pack("c",hex($1))/ge;
    # Associate key and value
    $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;
  }
  return length($in); 
}


