Last change
on this file since 29687 was 29076, checked in by kjdon, 10 years ago |
these changes were made in the pei-jones site and they look sensible so I am committing them.
|
-
Property svn:executable
set to
*
|
File size:
1.4 KB
|
Line | |
---|
1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use LWP::Simple;
|
---|
5 |
|
---|
6 | my $iis6_mode = 0;
|
---|
7 |
|
---|
8 | if($iis6_mode)
|
---|
9 | {
|
---|
10 | chdir("cgi-bin");
|
---|
11 | }
|
---|
12 |
|
---|
13 | eval("require \"gsdlCGI.pm\"");
|
---|
14 |
|
---|
15 | if($@){
|
---|
16 | print STDOUT "Content-type:text/plain\n\n";
|
---|
17 | print STDOUT "ERROR: $@\n";
|
---|
18 | exit 0;
|
---|
19 | }
|
---|
20 |
|
---|
21 | sub main{
|
---|
22 |
|
---|
23 | my $gsdl_cgi = new gsdlCGI();
|
---|
24 |
|
---|
25 | $gsdl_cgi->setup_gsdl();
|
---|
26 |
|
---|
27 | $gsdl_cgi->parse_cgi_args();
|
---|
28 |
|
---|
29 | $gsdl_cgi->{'xml'} = 0;
|
---|
30 |
|
---|
31 | my $filename = $gsdl_cgi->clean_param("filename");
|
---|
32 | my @fileholder;
|
---|
33 |
|
---|
34 | if(defined $filename){
|
---|
35 |
|
---|
36 | my $site = $gsdl_cgi->clean_param("site"); #site name
|
---|
37 | my $c = $gsdl_cgi->clean_param("c"); #collection name
|
---|
38 | my $assoc = $gsdl_cgi->clean_param("assoc"); #assocfilepath value
|
---|
39 |
|
---|
40 | if(!defined $site){
|
---|
41 | $gsdl_cgi->generate_error("No site specified.");
|
---|
42 | }
|
---|
43 |
|
---|
44 | my $collect_dir = $gsdl_cgi->get_collection_dir($site);
|
---|
45 |
|
---|
46 | my $dir = &util::filename_cat($collect_dir,$c,"index","assoc");
|
---|
47 |
|
---|
48 | my $download_file = &util::filename_cat($dir,$assoc,$filename);
|
---|
49 |
|
---|
50 | open(DOWNLOAD_FILE, "<$download_file") or die "Failed to open file $download_file\n $!";
|
---|
51 | binmode DOWNLOAD_FILE;
|
---|
52 | @fileholder = <DOWNLOAD_FILE>;
|
---|
53 |
|
---|
54 | my $size = -s $download_file;
|
---|
55 | close DOWNLOAD_FILE;
|
---|
56 |
|
---|
57 | print "Content-Type: image/jpeg\n";
|
---|
58 | print "Content-Length: $size\n";
|
---|
59 | print "Content-Disposition:attachment;filename=".$download_file."\n\n";
|
---|
60 | print @fileholder;
|
---|
61 |
|
---|
62 | }else{
|
---|
63 | $gsdl_cgi->generate_error("No filename specified.");
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | &main();
|
---|
Note:
See
TracBrowser
for help on using the repository browser.