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