Update of /cvsroot/sandweb/sandweb/bin
In directory usw-pr-cvs1:/tmp/cvs-serv31266/bin
Modified Files:
sandweb.cgi
Log Message:
moved download/mime detection code into the download method of
File.pm
hmm, get_mime_type would make a good method too, would compliment
get_file_type nicely ( knowing what's text and what's not is very
cool, but it would be even cooler to take a guess at filetype
based on MIME type and load a different icon, or be able to take
different user-defined actions ).
Index: sandweb.cgi
===================================================================
RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v
retrieving revision 1.101
retrieving revision 1.102
diff -U2 -r1.101 -r1.102
--- sandweb.cgi 2001/12/20 23:05:57 1.101
+++ sandweb.cgi 2001/12/20 23:11:38 1.102
@@ -691,31 +691,5 @@
}
elsif ( $file_command eq 'download' ) {
- open FILE,"< $users_dir/$username/$location/$filename";
- my @file = <FILE>;
- close FILE;
- my @file_split = split(/\./, $filename);
- my $file_extension = $file_split[$#file_split];
- my $content_type;
- open FILE,"< /usr/local/apache/conf/mime.types";
- my @mimes = <FILE>;
- close FILE;
- foreach my $mime_type (@mimes) {
- unless ( $mime_type =~ /^#/) {
- my @mime_string = split(/\s+/, $mime_type);
- if ($mime_string[1]) {
- if ( $file_extension eq $mime_string[1] ){
- $content_type = $mime_string[0];
- }
- }
- }
- }
- unless ($content_type) {
- $content_type = "binary/unknown";
- }
- print "content-type:$content_type\n\n";
- foreach my $line (@file) {
- print "$line";
- }
- exit 0;
+ $file->download();
}
else {
|