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