Skip to main content.
home | support | download

Back to List Archive

Can I Use Perl Script from SWISH 1.1.1 with SWISH-E?

From: Eric Haymaker <ehaymaker(at)not-real.aphelioninc.com>
Date: Wed Jul 14 1999 - 13:29:56 GMT
Is there any reason I cannot use the same perl script that had been used
with SWISH 1.1.1 with the newest version of  SWISH-E?   I have SWISH-E up
and running in all aspects except that I have yet to get the search results
to display on a an web page.  If I type a word in the search form and click
the button, the web page says "Documents found:" but no documents are
listed.  If I do NOT type anything in the search form and click the button,
the web page comes up, but does not say "Documents found:".  I'm including
the perl script below to which I changed the swish path to include SWISH-E:


#!/usr/local/bin/perl

# REQUIRED

# Firstly check the path to PERL executable in the first line of the script.

$swish_path =  '/export/home/www/swish-e'; # path to SWISH executable


# You should carefully set configuration options in your `swish.conf' file.
# Search imports `IndexName' and `IndexPointer' values and
# its behaviour considerably depends on `ReplaceRules' settings.

############################################################################


# YOUR CHOICE

%form = ( 'ipath', '/export/home/aphelion/www2/index.abc);#default `Search
path'

$bgcolor =     '"#ffffff"'; # background color
$textcolor =   'black';  # text color on `bgcolor' background
$atextcolor =  'white';  # text color on `linkcolor' background and
    # activ link color
$headercolor = 'maroon'; # headers color
$linkcolor =   'blue';  # links color and alternate background
$alinkcolor =  'lime';  # links color on `linkcolor' background
$vlinkcolor =  'navy';  # visited links color

############################################################################
#####

# YOU SHOULD NOT ALTER THE REST OF THE SCRIPT

read( STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } );
@pairs = split( /&/, $buffer );

foreach $pair( @pairs )
{
  ( $name, $value ) = split( /=/, $pair );

  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;

  $form{ $name } = $value;
}

open( RES, ( $form{ 'terms' } ) ?
  "$swish_path -f $form{ 'ipath' } -m 50 -t HBthe -w $form{ 'terms' } |" :
  "$swish_path -f $form{ 'ipath' } -m 1 -w 0 |" );

_1: while( <RES> )
{
  $Name = $1 if /^# Name: (.*)$/o;
  $Pointer = $1 if /^# Pointer: (.*)$/o;
  last _1 if defined( $Name ) && defined( $Pointer );
  $error = $1 if /^err: (.*)$/o;
  $error = 'Invalid search words' if /^options:/o;
}

$hc = "FONT COLOR=$headercolor";
$atc = "FONT COLOR=$atextcolor";
$alc = "FONT COLOR=$alinkcolor";

$_ = <<EOP;
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<head>
<title>PETRO PAGES Search</title>
</head>

<body TEXT="black" BGCOLOR="#ffffff" LINK="blue" VLINK="navy" ALINK="white">

<p align="center"><img SRC="http://www.mysite.com/gfx/pplogo.jpg" ALT="The"
Pages
Online Guide" WIDTH="442" HEIGHT="103" BORDER="0"> </p>

EOP

s/VALUE=.$form{ 'ipath' }./$& CHECKED/o;

print;

if( $error )
{
  print "<BR><$hc><B>Error:</B></FONT> $error<BR><BR><BR>\n";
}
elsif( $form{ 'terms' } )
{
  print "<BR><$hc><B>Documents found:</B></FONT> &nbsp; <SMALL>(red <FONT
COLOR=red>&para;</FONT> sign shows confidence in the match, best match
first)</SMALL><BR><BR>\n";

  while( <RES> )
  {
    print "<FONT SIZE=\"+0\" COLOR=\"".( $1 > 99 ? 'red' : 'black' ).
        "\"><B>&para;</B></FONT> <A HREF=\"$2\">$3</A> <BR>"
      if /^([0-9]*) +([^ ]*) +.([^\"]*). +([0-9]*)/o;
    print "No documents found<BR>\n" if /^err/o;
  }
  print "<BR>\n";
}
else
{
  print <<EOP;
    <UL>
    </UL>
EOP
}

print <<EOP;
<p align="left"><font face="Arial"><small>Find the products and suppliers
you need through
any of our three search methods.<br>
<strong>1.</strong> Use our search engine to find the page on our site that
you need.<br>
</font></p>

<table border="0" cellpadding="0" cellspacing="0" width="705" height="141"
style="border: medium">
  <tr>
    <td height="1" style="border: medium" width="705" valign="top"><form
METHOD="POST"
    ACTION="http://www.mywebsite.com/search.cgi">
      <font COLOR="maroon"><p></font><font
face="Arial"><big><big><big>1.</big></big></big></font><font
      COLOR="maroon"> <font face="Arial">Search Words</font>:&nbsp;</font>
<input TYPE="text"
      NAME="terms" SIZE="45" VALUE> <font COLOR="blue"><input TYPE="submit"
VALUE=" Do Search "
      ALIGN="top"
      style="background-color: rgb(0,0,0); color: rgb(255,255,255);
font-family: sans-serif; font-size: 12pt; font-weight: bold"></font><br>
      <font COLOR="maroon">&nbsp; <font face="Arial">Search
by:</font></font> <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input
      TYPE="radio" NAME="ipath" VALUE="/export/home/www/index.abc" CHECKED>
<small><font
      face="Arial">Product Categories (approximately 5,000 categories - a
list of suppliers for
      each) <br>

      </p>
    </form>
    </td>
  </tr>
</table>

</CENTER>
</BODY>
</HTML>

EOP

__END__
Received on Wed Jul 14 06:26:22 1999