#!/usr/local/bin/perl

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

$outfile = $ENV{"QUERY_STRING"};
$slashpos = index($outfile,"/");
if (($outfile eq "") || ($slashpos > -1)) {
	$Dat =  `date +'%y%m%d%H%M%S'`;
	chop($Dat);
	$outfile = "../RView/SYNOPTICS/DESC/" . $Dat . ".txt";
	$Weboutfile = "../RView/SYNOPTICS/DESC/" . $Dat . ".txt";
}
else {
	$Weboutfile = "../RView/SYNOPTICS/DESC/".$outfile;
	$outfile = "../RView/SYNOPTICS/DESC/".$outfile;
}

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

unlink($outfile);
open(OUT, "> ". $outfile) || die "ERROR creating file";
print OUT $buffer;
close(OUT);

#print $ENV{"REMOTE_HOST"};
print $Weboutfile;

exit 0;
