#!/usr/local/bin/perl
#- Configurable Variables ---------------------------------------------------#
#Path to SWISH-E executable
$swish = "/usr/local/bin/swish-e";
#Path to this CGI script
$swishcgi = "/cgi-bin/searchres.cgi";
#Path to the SWISH-E index
$index = "/local/largo2/wwwpages/cgi-bin/index.swish-e";
#Path to the SWISH-E configuration file
$config = "/opt/swish/swish-e/ConfigFiles/SwishTest.conf";
#- Main Program -------------------------------------------------------------#
#Parse the form data
&parse_form_data (*FORM);
#Construct a simple query
$query = $FORM{'query'};
$results = $FORM{'results'};
if ($query) {
&search_parse;
}else{
&search_error("You must enter a keyword or phrase in one or more of the text boxes");
}
#- Subroutines ---------------------------------------------------------------#
#Subroutine for checking and parsing the incoming form data.
sub parse_form_data {
local (*FORM_DATA) = @_;
local ($request_method, $query_string, @key_value_pairs, $key_value, $key, $value);
$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
&search_error ("Forms must use either GET or POST.");
}
@key_value_pairs = split (/&/, $query_string);
foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
if (defined ($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
}
}
}
#Subroutine for constructing the Swish-E search request and formating the results.
sub search_parse {
#Create your SWISH-E query command
$count=0;
open(SWISH, "$swish -w $query -m $results -f $index|");
#Check for errors
while (
Your Search for $query, returned $count Items