From aa3443651adf659011fa6f1faf0368f792447756 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 Dec 2003 10:53:39 +0000 Subject: [PATCH] * Added the server side CGI scripts used for uploading to losser. svn path=/nixpkgs/trunk/; revision=566 --- nix-dist/server-side/cgi-bin/md5.pl | 21 +++++++++++++++++++++ nix-dist/server-side/cgi-bin/upload.pl | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 nix-dist/server-side/cgi-bin/md5.pl create mode 100755 nix-dist/server-side/cgi-bin/upload.pl diff --git a/nix-dist/server-side/cgi-bin/md5.pl b/nix-dist/server-side/cgi-bin/md5.pl new file mode 100755 index 00000000000..a998844410a --- /dev/null +++ b/nix-dist/server-side/cgi-bin/md5.pl @@ -0,0 +1,21 @@ +#! /usr/bin/perl -w + +use strict; +use FileHandle; +use File::Spec; +use Digest::MD5; + +my $path = $ENV{"PATH_INFO"}; + +# Sanitise path. +die unless $path =~ /^(\/[A-Za-z0-9-][A-Za-z0-9-\.]+)+$/; + +my $fullpath = "/home/eelco/public_html/nix/$path"; + +open FILE, "< $fullpath" or die "cannot open $fullpath"; +# !!! error checking +my $hash = Digest::MD5->new->addfile(*FILE)->hexdigest; +close FILE; + +print "Content-Type: text/plain\n\n"; +print "$hash"; diff --git a/nix-dist/server-side/cgi-bin/upload.pl b/nix-dist/server-side/cgi-bin/upload.pl new file mode 100755 index 00000000000..4d303c77d38 --- /dev/null +++ b/nix-dist/server-side/cgi-bin/upload.pl @@ -0,0 +1,23 @@ +#! /usr/bin/perl -w + +use strict; + +my $uploadpath = $ENV{"PATH_INFO"}; + +# Sanitise upload path. +die unless $uploadpath =~ /^(\/[A-Za-z0-9-][A-Za-z0-9-\.]+)+$/; + +my $dst = "/home/eelco/public_html/nix/$uploadpath"; +my $tmp = "${dst}_$$"; + +open OUT, ">$tmp" or die; +while () { + print OUT "$_" or die; +} +close OUT or die; + +rename $tmp, $dst or die; + +print "Content-Type: text/plain\n\n"; +print "upload succesful\n"; +print "upload path: $uploadpath\n";