* Added the server side CGI scripts used for uploading to losser.
svn path=/nixpkgs/trunk/; revision=566
This commit is contained in:
parent
506a336bca
commit
aa3443651a
21
nix-dist/server-side/cgi-bin/md5.pl
Executable file
21
nix-dist/server-side/cgi-bin/md5.pl
Executable file
@ -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";
|
23
nix-dist/server-side/cgi-bin/upload.pl
Executable file
23
nix-dist/server-side/cgi-bin/upload.pl
Executable file
@ -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 (<STDIN>) {
|
||||
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";
|
Loading…
Reference in New Issue
Block a user