#!/www/perl/bin/perl.exe -w # # filednload.pl # # File Download Utility # $server=$ENV{'SERVER_NAME'}; $browser=$ENV{'HTTP_USER_AGENT'}; $fileroot=$ENV{'DOCUMENT_ROOT'}; use CGI; use CGI::Carp qw(fatalsToBrowser); $cgiobject = new CGI; $dnloadfile = $cgiobject->param('filename'); $dnloaddir = $cgiobject->param('filedir'); $movecode = $cgiobject->param('movecode'); $usrcod = $cgiobject->param('usrcod'); $passwd = $cgiobject->param('passwd'); $userselect = $cgiobject->param('userselect'); $filekey = $cgiobject->param('filekey'); $program = "DBXDND"; $filename = $dnloadfile; $filename = lc($filename); $filepath = lc($fileroot . "/" . $movecode); $origpath = lc($filepath . "/" . $filename); $dnloadpath = $origpath; $flsiz = -s $origpath; print "Content-Type: application/octet-stream\n"; print "Content-Disposition:attachment filename=\"$filename\"\n"; print "Content-Length: $flsiz\n"; open (DLFILE,"<$origpath"); binmode DLFILE; binmode STDOUT; my $buffer = ''; while(read(DLFILE,$buffer,1024)) { print $buffer; } close DLFILE; $fileout=$fileroot . "/Temp/" . $usrcod . ".txt"; open (USER,">$fileout"); print USER "USRCOD=" . $usrcod . "\n"; print USER "PASSWD=" . $passwd . "\n"; print USER "BROWSER=" . $browser . "\n"; print USER "PROGRAM=" . $program . "\n"; print USER "FILENAME=" . $filename . "\n"; print USER "SERVER=" . $server . "\n"; print USER "DNLDDIR=" . $dnloaddir . "\n"; print USER "DNLDFILE=" . $dnloadfile . "\n"; print USER "DNLDPATH=" . $dnloadpath . "\n"; print USER "MOVECODE=" . $movecode . "\n"; print USER "USERSELECT=". $userselect . "\n"; print USER "FILEKEY=". $filekey . "\n"; close USER; print $cgiobject->redirect("http://" . $server . /cgi/cgi.exe?usrcod=" . $usrcod);