aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sitesummary-collector.cgi15
1 files changed, 13 insertions, 2 deletions
diff --git a/sitesummary-collector.cgi b/sitesummary-collector.cgi
index 5318dac..26e00f3 100644
--- a/sitesummary-collector.cgi
+++ b/sitesummary-collector.cgi
@@ -25,11 +25,12 @@ if (exists $ENV{REQUEST_METHOD} && $ENV{REQUEST_METHOD} ne "POST")
# Extract post data, handle both simple and multipart way
my @entry;
+my $filename = "unknown";
if (exists $ENV{CONTENT_TYPE} && $ENV{CONTENT_TYPE} =~ m%multipart/form-data%){
my $query = new CGI;
my $fh = $query->upload("sitesummary");
if ($fh) {
- my $filename = $query->param("sitesummary");
+ $filename = $query->param("sitesummary");
my $type = $query->uploadInfo($filename)->{'Content-Type'};
if ("application/octet-stream" ne $type) {
print "Only 'application/octet-stream' is supported (not $type)!";
@@ -63,7 +64,17 @@ EOF
my ($peeripaddr, $peername) = get_peerinfo(\*STDIN);
my $timestamp = strftime("%Y-%m-%dT%H:%M:%S", gmtime());
-open(SITESUMMARY, ">$basedir/tmpstorage/storage-$peeripaddr-$timestamp") or die "Unable to write to storage";
+if ($filename =~ m/.tar.gz$/) {
+ $filename = "sitesummary.tar.gz";
+} elsif ($filename =~ m/.tar.gz.gpg$/) {
+ $filename = "sitesummary.tar.gz.gpg";
+} else {
+ die "Unhandled file type '$filename'"
+}
+
+my $savefile = "$basedir/tmpstorage/$peeripaddr-$timestamp-$filename";
+
+open(SITESUMMARY, ">$savefile") or die "Unable to write to $savefile";
print SITESUMMARY @entry;
close SITESUMMARY;