Changeset 15170 for gsdl/trunk


Ignore:
Timestamp:
2008-04-02T18:23:41+13:00 (16 years ago)
Author:
ak19
Message:

2 changes: 1. added file-exists command and matching routine file_exists; 2. modified

Location:
gsdl/trunk/cgi-bin
Files:
2 edited

Legend:

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

    r14260 r15170  
     1#!/usr/bin/perl -w
    12#!perl -w
    23# Need to specify the full path of Perl above
     
    3637my $mail_smtp_server = "smtp.server";  # Set this appropriately
    3738
    38 
    3939sub main
    4040{
     
    121121    elsif ($cmd eq "upload-collection-file") {
    122122    &upload_collection_file($gsdl_cgi, $username, $timestamp);
    123     }
     123    }
     124    elsif ($cmd eq "file-exists") {
     125    &file_exists($gsdl_cgi);
     126    }   
    124127    else {
    125128    $gsdl_cgi->generate_error("Unrecognised command: '$cmd'");
    126129    }
    127130}
    128 
    129131
    130132sub authenticate_user
     
    511513}
    512514
     515# Method that will check if the given file exists
     516# No error message: all messages generated are OK messages
     517# This method will simply state whether the file exists or does not exist.
     518sub file_exists
     519{
     520    my ($gsdl_cgi, $username, $timestamp) = @_;
     521
     522    my ($gsdl_cgi) = @_;
     523
     524    my $collection = $gsdl_cgi->clean_param("c");
     525    if ((!defined $collection) || ($collection =~ m/^\s*$/)) {
     526    $gsdl_cgi->generate_error("No collection specified.");
     527    }
     528    my $file = $gsdl_cgi->clean_param("file");
     529    if ((!defined $file) || ($file =~ m/^\s*$/)) {
     530    $gsdl_cgi->generate_error("No file specified.");
     531    }
     532    $file =~ s/\|/&util::get_dirsep()/eg;  # Convert the '|' characters into whatever is right for this OS
     533   
     534    # Not necessary: checking whether the user is authenticated to query existance of the file
     535    #&authenticate_user($gsdl_cgi, $username, $collection);
     536
     537    my $gsdlhome = $ENV{'GSDLHOME'};
     538    my $collection_directory = &util::filename_cat($gsdlhome, "collect", $collection);
     539    $gsdl_cgi->checked_chdir($collection_directory);
     540
     541    # Check that the collection file exists
     542    if (-e $file) {
     543    $gsdl_cgi->generate_ok_message("File $file exists.");
     544    } else {
     545    $gsdl_cgi->generate_ok_message("File $file does not exist.");
     546    }
     547}
    513548
    514549sub download_collection_file
     
    746781    &lock_collection($gsdl_cgi, $username, $collection) unless ($script eq "mkcol.pl");
    747782
    748     # Last argument is the collection name, except for explode_metadata_database.pl
     783    # Last argument is the collection name, except for explode_metadata_database.pl and
     784    # replace_srcdoc_with_html (where there's a "file" option followed by the filename. These two preceed the collection name)
    749785    my $perl_args = $collection;
    750     if ($script eq "explode_metadata_database.pl") {
     786    if ($script eq "explode_metadata_database.pl" || $script eq "replace_srcdoc_with_html.pl") {
    751787    # Last argument is the file to be exploded
    752788    my $file = $gsdl_cgi->clean_param("file");
     
    755791    }
    756792    $gsdl_cgi->delete("file");
    757     $perl_args = $file;
     793    $file =~ s/ /\\ /g; # escape all spaces in filename with a backslash, i.e. "\ "
     794    $perl_args = $file;
    758795    }
    759796
  • gsdl/trunk/cgi-bin/gsdlsite.cfg

    r14026 r15170  
    44
    55# points to the GSDLHOME directory
    6 gsdlhome    **GSDLHOME**
     6gsdlhome     "/research/ak19/Greenstone2SVN/gsdl"
    77
    88# this is the http address of GSDLHOME
    99# if your webservers DocumentRoot is set to $GSDLHOME
    1010# then httpprefix can remain commented out
    11 #httpprefix  /gsdl
     11httpprefix  /gsdlsvn
    1212
    1313# this is the http address of the directory which
     
    1515# if your webservers DocumentRoot is set to $GSDLHOME
    1616# then httpimg will be /images
    17 httpimg     /images
     17httpimg     /gsdlsvn/images
    1818
    1919# should contain the http address of this cgi script. This
Note: See TracChangeset for help on using the changeset viewer.