diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2006-08-25 20:58:36 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2006-08-25 20:58:36 +0000 |
commit | 20bca15319377c827a3388d521a3fc1f4ccde483 (patch) | |
tree | e2a98409f4c72c589e45b209fbb5c93d830116a5 | |
parent | 439020ef8b72a3a941342652d1aac45dae31c6d9 (diff) | |
download | sitesummary-20bca15319377c827a3388d521a3fc1f4ccde483.tar.gz sitesummary-20bca15319377c827a3388d521a3fc1f4ccde483.tar.bz2 sitesummary-20bca15319377c827a3388d521a3fc1f4ccde483.tar.xz |
Track file system name, to recognize gpg encrypted files.
-rw-r--r-- | sitesummary-collector.cgi | 15 |
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; |