| Current File : //var/wcp4/serenocl/public_html/file/dn.cgi |
#!/usr/bin/perl
my ($tmp, $tmp1, $file, $user, $fielend, $opt, $filename, $filepath, $filesize, $buffer);
@pairs = split(/&/, $ENV{'QUERY_STRING'});
($tmp,$user) = split(/=/, $pairs[0]);
($tmp1,$filename) = split(/=/, $pairs[1]);
if($tmp ne "user") { exit;}
if ($user eq "") { exit;}
if($tmp1 ne "file") { exit;}
if ($filename eq "") { exit;}
($tmp,$fileend) = split(/\./, $filename);
if ($fileend eq "sql") {
$opt = "mysql/";
} elsif ($fileend eq "tgz") {
$opt = "web/";
} else {
exit;
}
$filepath="/export/home/$user/backup/$opt";
$file="$filepath$filename";
if (-e $file) {
$filesize = -s $file;
print "type: application/download\n";
print "Content-Transfer-Encoding: binary\n";
print "Content-length: $filesize\n";
print "Content-Disposition: attachment; filename=$filename\n";
if ($fileend eq "sql") {
print "Content-type: application/x-sql\n\n";
} elsif ($fileend eq "tgz") {
print "Content-type: application/x-tar\n\n";
}
open (DLF, $file) || die "Cannot open $file: $!\n";
flock (DLF,2);
{
binmode DLF;
local $/ = \4096;
print while <DLF>;
}
flock (DLF,8);
close (DLF);
exit;
}