source: tags/gsdl-2_53-distribution/gsdl/cgi-bin/download@ 9303

Last change on this file since 9303 was 9208, checked in by mdewsnip, 19 years ago

Changed to be executable.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1#!/usr/bin/perl -w
2
3use gsdlCGI;
4
5sub main
6{
7 my $gsdl_cgi = new gsdlCGI("+cmdline");
8
9 my $gsdlhome = $gsdl_cgi->get_config_info("gsdlhome");
10
11 my $col = $gsdl_cgi->clean_param("c");
12 if (!defined $col) {
13 $gsdl_cgi->generate_error("No collection specified.");
14 }
15
16 my $dir = $gsdl_cgi->clean_param("dir");
17 $dir = "\"\"" if ((!defined $dir) || ($dir eq "."));
18
19 my $accept_expr = $gsdl_cgi->clean_param("a");
20 if(($accept_expr eq "") || (!defined $accept_expr)) {
21 $accept_expr = "";
22 print "not using accept";
23 }
24 else {
25 $accept_expr = "-accept " . $accept_expr;
26 }
27
28 my $reject_expr = $gsdl_cgi->clean_param("r");
29 if(($reject_expr eq "") || (!defined $reject_expr)) {
30 $reject_expr = "";
31 print "not using reject";
32 }
33 else {
34 $reject_expr = "-reject " . $reject_expr;
35 }
36
37 if ($col =~ m/^\//) {
38 # leading / at start denotes special "cols" such as "/tmp"
39 $gsdl_cgi->checked_chdir("$gsdlhome");
40 $col =~ s/^\///;
41 }
42 else {
43 $gsdl_cgi->checked_chdir("$gsdlhome/collect");
44 }
45
46 `java -classpath $gsdlhome/bin/java/SignedGatherer.jar org.greenstone.gatherer.util.Zipup $gsdlhome/ $col $dir $accept_expr $reject_expr`;
47
48 my $pipe_cmd = "cat $col.zip"; # Unix specific
49
50 if (open(PIN,"$pipe_cmd |")) {
51 binmode(PIN);
52
53 my $buf;
54 my $num_bytes = 0;
55
56 print "Content-type:application/zip\n\n";
57
58 while (read(PIN,$buf,1024)>0) {
59 print STDOUT $buf;
60 $num_bytes += length($buf);
61 }
62
63 close(PIN);
64
65 my $status = $?;
66 }
67 else {
68 $gsdl_cgi->generate_error("Unable to pipe input from: $pipe_cmd");
69 }
70
71 unlink "$col.zip";
72}
73
74&main();
75
Note: See TracBrowser for help on using the repository browser.