Skip to main content.
home | support | download

Back to List Archive

Re: swish.cgi config question

From: Peggy Eaton <peaton(at)not-real.eosdata.gsfc.nasa.gov>
Date: Thu Dec 19 2002 - 20:40:06 GMT
Bill Moseley wrote:
> On Thu, 19 Dec 2002, Peggy Eaton wrote:
>>
>>I've read the documentation and searched the discussion list, but I'm 
>>not finding the info I need.  I've tried passing in the config file 
>>location using QUERY_STRING, but once a search is initiated, the script 
>>defaults are used, and I'm not crazy about having the directory location 
>>viewable by end users.  Any suggestions?
> 
> 
> Right, you do not want to pass any data that will be passed onto the shell
> or used to open a file.  You can do ?config=1 and then use that "1" to map
> to a specific config file.
> 
> I don't see why you couldn't test QUERY_STRING and set the config file
> location based on that, though.  You would have to show the changes you
> made so I can see what you are attempting.
> 

This idea seems a lot better than my initial approach.  I could just set 
up an array of possible config files and let my developers pick theirs 
by passing in the number corresponding to it.  But I'm having a problem 
with swish.cgi "remembering" the variable I'm passing in through 
QUERY_STRING.  I put the following code at the top of swish.cgi:

#-----------------------------------------------
my $buffer = $ENV{'QUERY_STRING'};

# Split the Name value pairs
my %pairs = split (/[&=]/, $buffer);
my $name="";
my $value="";
my %FORM;
foreach (%pairs)
{
      tr/+/ /;
      s/%(..)/pack("C",hex($1))/eg;
}

while(($name, $value) = each %pairs){
	next if ($name eq 'search_tags');
	push(my @search_tags, $value);
	$FORM{$name} = $value;
}
#-----------------------------------------------'

#     myconfig is passed in as a hidden form field
my $DEFAULT_CONFIG_FILE = $FORM{'myconfig'};
    $DEFAULT_CONFIG_FILE =~ s/%(..)/pack("C",hex($1))/eg;

I've verified that the $DEFAULT_CONFIG_FILE value is passed in 
correctly, but once a text string is entered for searching, the 
swish.cgi default configuration parameters are used.

> Can you use mod_perl? If so then you can use the same swish.cgi code in
> the server but use a PerlSetVar for different configs.  You just use
> different PerlSetVar directives within each <Location> directive.
> Different URLs look like they are running different scripts, but it's
> really the same code but with different configs.
> 
> If you use mod_perl you will have some very fast searches.  

I'm checking again with our sys admins to see if this is available for 
us now.  The last time I checked, they didn't want it used because of 
security problems.

>  
> 
> 

-- 
Peggy Eaton                   GSFC DAAC: http://daac.gsfc.nasa.gov/
     Web Curator               web-curator@daac.gsfc.nasa.gov
     MODIS Data Support        modis@daac.gsfc.nasa.gov
     ECS User Services         daac_usg@gsfcsrvr4.gsfcmo.ecs.nasa.gov

NASA Goddard Space Flight Center, Code 902, Greenbelt, MD 20771
     Phone: 1-301-614-5124     Fax: 1-301-614-5268
Received on Thu Dec 19 20:40:29 2002