[19293] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | # Need to specify the full path of Perl above
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | use strict;
|
---|
| 6 |
|
---|
| 7 |
|
---|
[33011] | 8 | BEGIN {
|
---|
| 9 | # On Ubuntu 18.04, gsdlCGI.pm can't be found as the cgi folder is not among @INC paths.
|
---|
| 10 | # Ensure gsdlCGI.pm is available in @INC by adding the cgi folder to it.
|
---|
| 11 | # For GS2:
|
---|
| 12 | my $gsdl_cgi_path = $ENV{'GSDLHOME'} . "/cgi-bin";
|
---|
| 13 | # For GS3:
|
---|
| 14 | $gsdl_cgi_path = $ENV{'GSDL3HOME'} . "/WEB-INF" . "/cgi" if defined $ENV{'GSDL3HOME'};
|
---|
| 15 |
|
---|
| 16 | my $found_cgi_path = 0;
|
---|
| 17 | foreach my $inc_path (@INC) {
|
---|
| 18 | if($inc_path eq $gsdl_cgi_path) {
|
---|
| 19 | $found_cgi_path = 1;
|
---|
| 20 | last;
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 | if(!$found_cgi_path) {
|
---|
| 24 | unshift (@INC, $gsdl_cgi_path);
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 |
|
---|
[19293] | 29 | # Set this to 1 to work around IIS 6 craziness
|
---|
| 30 | my $iis6_mode = 0;
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | # IIS 6: for some reason, IIS runs this script with the working directory set to the Greenstone
|
---|
| 34 | # directory rather than the cgi-bin directory, causing lots of stuff to fail
|
---|
| 35 | if ($iis6_mode)
|
---|
| 36 | {
|
---|
[24872] | 37 | # Change into cgi-bin\<OS> directory
|
---|
[19293] | 38 | chdir("cgi-bin");
|
---|
[24872] | 39 | if(defined $ENV{'GSDLARCH'}) {
|
---|
| 40 | chdir($ENV{'GSDLOS'}.$ENV{'GSDLARCH'});
|
---|
| 41 | } else {
|
---|
| 42 | chdir($ENV{'GSDLOS'});
|
---|
| 43 | }
|
---|
[19293] | 44 | }
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | # We use require and an eval here (instead of "use") to catch any errors loading the module (for IIS)
|
---|
| 48 | eval("require \"gsdlCGI.pm\"");
|
---|
| 49 | if ($@)
|
---|
| 50 | {
|
---|
| 51 | print STDOUT "Content-type:text/plain\n\n";
|
---|
| 52 | print STDOUT "ERROR: $@\n";
|
---|
| 53 | exit 0;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | sub main
|
---|
| 59 | {
|
---|
| 60 | my $gsdl_cgi = new gsdlCGI();
|
---|
| 61 |
|
---|
| 62 | # Load the Greenstone modules that we need to use
|
---|
| 63 | $gsdl_cgi->setup_gsdl();
|
---|
| 64 |
|
---|
| 65 | my $gsdlhome = $ENV{'GSDLHOME'};
|
---|
| 66 | $gsdl_cgi->checked_chdir($gsdlhome);
|
---|
| 67 |
|
---|
| 68 | require cgiactions::imageaction;
|
---|
| 69 |
|
---|
| 70 | $gsdl_cgi->parse_cgi_args();
|
---|
| 71 |
|
---|
| 72 | # We don't want the gsdlCGI module to return errors and warnings in XML
|
---|
| 73 | $gsdl_cgi->{'xml'} = 0;
|
---|
| 74 |
|
---|
| 75 | my $action = new imageaction($gsdl_cgi,$iis6_mode);
|
---|
| 76 |
|
---|
| 77 | $action->do_action();
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | &main();
|
---|