#!/usr/bin/perl #- Configurable Variables ---------------------------------------------------# $swish = "/usr/local/bin/swish-e"; $swishcgi = "/home/board/public_html/unixboard/search.cgi"; $index = "/home/board/public_html/unixboard/search/index"; $config = "/home/board/public_html/unixboard/search/search.conf"; #- Main Program -------------------------------------------------------------# &parse_form_data (*FORM); #if ($FORM{'keyword'} =~ /\w+/) { # push (@query, $FORM{'keyword'}); # } $FORM{'keyword'} =~ s/\;//g; $FORM{'keyword'} =~ s/\[//g; $FORM{'keyword'} =~ s/\]//g; $FORM{'keyword'} =~ s/\>//g; $FORM{'keyword'} =~ s/\) { chop; if ($_ eq "err: no results") {&search_error("对不起,找不到"$query"");} if ($_ eq "err: could not open index file") {&search_error("Could not open SWISH Index File $index");} if ($_ eq "err: no search words specified") {&search_error("Please Enter at least one Search Word");} if ($_ eq "err: a word is too common") {&search_error("One of your search terms is too common, please try again");} next if /^\D/; $count++; push(@results, $_); } &html_header("搜索结果"); print < 您寻找 $query, 找到 $count 个


\n"; &html_trailer; } #Subroutine for print a generic HTML header. sub html_header { $document_title = $_[0]; print < $document_title

$document_title

HTML_Header } #Subroutine for printing a generic HTML trailer. sub html_trailer { print < HTML_Trailer exit; } #Subroutine for printing error messages. sub search_error { &html_header("搜索错误"); $error_message = $_[0]; print "

\n$error_message

\n"; &html_trailer; }