Ignore:
Timestamp:
2007-07-25T13:37:52+12:00 (17 years ago)
Author:
oranfry
Message:

merged selected changes to the gsdl trunk since r14217 into the 2.74 branch

Location:
gsdl/branches/gsdl-2.74/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gsdl/branches/gsdl-2.74/cgi-bin/gliserver.pl

    r14025 r14270  
    11#!perl -w
    2 
    32# Need to specify the full path of Perl above
    43
    54
    6 use gsdlCGI;
    75use strict;
     6
     7
     8# Set this to 1 to work around IIS 6 craziness
     9my $iis6_mode = 0;
     10
     11
     12# IIS 6: for some reason, IIS runs this script with the working directory set to the Greenstone
     13#   directory rather than the cgi-bin directory, causing lots of stuff to fail
     14if ($iis6_mode)
     15{
     16    # Change into cgi-bin directory
     17    chdir("cgi-bin");
     18}
     19
     20
     21# We use require and an eval here (instead of "use") to catch any errors loading the module (for IIS)
     22eval("require \"gsdlCGI.pm\"");
     23if ($@)
     24{
     25    print STDOUT "Content-type:text/plain\n\n";
     26    print STDOUT "ERROR: $@\n";
     27    exit 0;
     28}
    829
    930
     
    109130sub authenticate_user
    110131{
    111    
    112132    my $gsdl_cgi = shift(@_);
    113133    my $username = shift(@_);
     
    244264    my $installation_status = "";
    245265
     266    print STDOUT "Content-type:text/plain\n\n";
     267
    246268    # Check that Java is installed and accessible
    247269    my $java = $gsdl_cgi->get_java_path();
    248270    my $java_command = "$java -version 2>&1";
     271
     272    # IIS 6: redirecting output from STDERR to STDOUT just doesn't work, so we have to let it go
     273    #   directly out to the page
     274    if ($iis6_mode)
     275    {
     276    $java_command = "java -version";
     277    }
     278
    249279    my $java_output = `$java_command`;
    250280    my $java_status = $?;
     
    265295
    266296    if ($installation_ok) {
    267     $gsdl_cgi->generate_ok_message($installation_status . "\nInstallation OK!");
     297    print STDOUT $installation_status . "\nInstallation OK!";
    268298    }
    269299    else {
    270     $gsdl_cgi->generate_error($installation_status);
     300    print STDOUT $installation_status;
    271301    }
    272302}
     
    563593    }
    564594
    565     print STDOUT "Content-type:text/plain\n\n";
    566595    foreach my $cgi_arg_name ($gsdl_cgi->param) {
    567596    my $cgi_arg_value = $gsdl_cgi->clean_param($cgi_arg_name) || "";
     
    575604    }
    576605
     606    print STDOUT "Content-type:text/plain\n\n";
     607
    577608    my $perl_command = "perl -S $script $perl_args 2>&1";
     609
     610    # IIS 6: redirecting output from STDERR to STDOUT just doesn't work, so we have to let it go
     611    #   directly out to the page
     612    if ($iis6_mode)
     613    {
     614    $perl_command = "perl -S $script $perl_args";
     615    }
     616
    578617    my $perl_output = `$perl_command`;
    579618    my $perl_status = $?;
     
    582621    }
    583622
    584     print STDOUT "Content-type:text/plain\n\n";
    585     print STDOUT $perl_output;
    586 
     623    if (defined($perl_output))
     624    {
     625    print STDOUT $perl_output;
     626    }
    587627}
    588628
     
    728768    }
    729769
     770    print STDOUT "Content-type:text/plain\n\n";
     771
    730772    my $perl_command = "perl -S $script $perl_args 2>&1";
     773
     774    # IIS 6: redirecting output from STDERR to STDOUT just doesn't work, so we have to let it go
     775    #   directly out to the page
     776    if ($iis6_mode)
     777    {
     778    $perl_command = "perl -S $script $perl_args";
     779    }
     780
    731781    if (!open(PIN, "$perl_command |")) {
    732782    $gsdl_cgi->generate_error("Unable to execute command: $perl_command");
    733783    }
    734784
    735     print STDOUT "Content-type:text/plain\n\n";
    736785    while (defined (my $perl_output_line = <PIN>)) {
    737786    print STDOUT $perl_output_line;
     
    799848
    800849    # Read the uploaded data and write it out to file
     850    # We have to pass the size of the uploaded data in the "fs" argument because IIS 6 seems to be
     851    #   completely incapable of working this out otherwise (causing the old code to crash)
    801852    my $buf;
    802853    my $num_bytes = 0;
     854    my $num_bytes_remaining = $gsdl_cgi->clean_param("fs");
     855    my $bytes_to_read = $num_bytes_remaining;
     856    if ($bytes_to_read > 1024) { $bytes_to_read = 1024; }
    803857    binmode(FOUT);
    804     while (read(STDIN, $buf, 1024) > 0) {
     858    while (read(STDIN, $buf, $bytes_to_read) > 0) {
    805859    print FOUT $buf;
    806860    $num_bytes += length($buf);
     861    $num_bytes_remaining -= length($buf);
     862    $bytes_to_read = $num_bytes_remaining;
     863    if ($bytes_to_read > 1024) { $bytes_to_read = 1024; }
    807864    }
    808865    close(FOUT);
  • gsdl/branches/gsdl-2.74/cgi-bin/gsdlCGI.pm

    r14024 r14270  
    101101    print STDOUT $full_mess;
    102102
    103     die $full_mess;
     103    exit 0;
    104104}
    105105
Note: See TracChangeset for help on using the changeset viewer.