\n";
foreach $f (@filelist) {
if( $f eq '..back' ) {
$up_level = $GLOBAL{'UP_LEVEL'};
#$formated_content = "
$f
\n\n";
#$formated_content = "$f
\n\n";
$formated_content = "$f
\n\n";
next;
}
if( !$f ) {
next;
}
if( -d $f ) {
$f = "$f/";
}
$foo++;
if ($foo eq 5) {
$formated_content .= '| $f | \n";
$foo = 0;
}
else {
$formated_content .= '$f\n";
}
#$formated_content .= '- $f
\n";
}
#$formated_content .= "\n";
$formated_content .= " |
\n";
$formated_content;
} # end of format_html_output
sub show_dir_content {
local($dir) = @_;
local($files, $f_files);
$dir = './' if (!$dir); # default to cgi dir
$files = read_dir($dir);
$f_files = format_html_output($files);
print_header();
print "
File UpLoad
File to Upload
\ \;
Comments, questions or problems? mail to $authorurl
";
exit;
} # end of show_dir_content
sub show_file_not_found {
print_header();
print "Not FoundNot Found
The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it. Connection closed by foreign host.\n"
;
exit;
} # show_file_not_found
sub start_download {
local($target_file) = @_;
local($file_name);
$target_file =~ s/^\/|^\\|\s//;
if( -d $target_file ) { show_dir_content("./$target_file"); }
# check if file exists , though this is not likely to happen
if ( ! -e "./$target_file") { show_file_not_found(); }
# get file name
$file_name = $target_file;
$file_name =~ s/.+\/([^\/]+)$/$1/; # for PC system
$file_name =~ s/.+\\([^\\]+)$/$1/; # for Unix system
# start download
print "Content-Type: application/x-unknown\n";
print "Content-Disposition: attachment; fillename=$file_name\n\n";
print read_file($target_file);
1;
} # end of start_download
sub show_upload_failed {
local($reason) = @_;
print_header();
print "Upload FailedUpload Failed
The requested object was not uploaded to the server.
Reason : $reason. The server may have decided not let you write to the directory specified. Please contact the web master for this prob
lem. Connection closed by foreign host.\n";
exit;
} # end of show_upload_failed
sub show_upload_success {
local($uploaded_file) = @_;
local(@status_list) ;
# @status_list = stat($uploaded_file);
$file_stats = `ls -la $uploaded_file`;
@status_list = split(/\s+/, $file_stats); # bug fix in v00.01
print_header();
#foreach $s ( @status_list ) { print "==$s==
\n"; }
print "
File UpLoaded
File Transfer Successful
Remote File Name : $GLOBAL{'FILE_NAME'}
File Name : $filename
Location : $upload_dir
File Size : $status_list[4]
Local Time: $status_list[5] $status_list[6] $status_list[7]
Back
";
exit;
} # end of show_upload_success
sub handle_upload {
if( !$GLOBAL{'FILE_NAME'} ) { show_file_not_found(); }
# grep the file name , there is always a / in front of the file name
#$GLOBAL{'FILE_NAME'} =~ /.+\\([^\\]+)$|([^\/]+)$/;
$filename = $GLOBAL{'FILE_NAME'};
$filename =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/\1/;
if( $GLOBAL{'UPLOAD_DIR'} =~ /CURRENT/ ) { # change upload dir to current
$GLOBAL{'CURRENT_DIR'} =~ s/\s//g;
$upload_dir = $GLOBAL{'CURRENT_DIR'};
}
$write_file = $upload_dir.$filename;
open(ULFD,">$write_file") || show_upload_failed("$write_file $!");
print ULFD $GLOBAL{'FILE_CONTENT'};
close(ULFD);
show_upload_success($write_file);
1;
} # end of handle_upload
# end of script