#!/usr/bin/perl
#
# posts data to the secure communications dealy
# returns key that customer can use to access the data

$| = 1;

my $DATADIR = '/usr/local/fci/securepost/data';
my $ARCHDIR = '/usr/local/fci/securepost/archive';

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

my $buffer;
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (!$buffer) {
	print "What?\n";
	exit 1;
}

$key = sprintf ("%x%x%x%x%x", (rand)*1000000, (rand)*1000000, (rand)*1000000, (rand)*1000000, (rand)*1000000);

open (OUT, ">$DATADIR/$key") || die "$DATADIR/$key: $!";
print OUT $buffer;
close (OUT);

unlink ("$DATADIR/$key.lock");
print "$key";
