CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Search Script Problem.

 



Devs
Deleted

May 17, 2000, 12:15 PM

Post #1 of 2 (461 views)
Search Script Problem. Can't Post

Hi could anyone please help me out? I'm trying to get a simple search script to run on my site (www.webcounter.co.uk) I just keep on getting an 'Internal Server Error' when I test it? I've set the form action to = <form action="http://www.uksearcher.com/cgi-bin/searchem.cgi" method="POST">

And chmoded it to 755.

Below is the script...

#!/usr/bin/perl

#######################################################################
# SearchEm Version 1.0 #
# Copyright 1999 by Matt Riffle All Rights Reserved. #
# Initial Full Release: 3/6/99 This Release: 3/6/99 #
# Riffnet Scripts Archive http://scripts.riffnet.com/ #
#######################################################################
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. It is included in #
# this distribution in the file "license.txt". #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #
# 02111-1307, USA. #
#######################################################################

%engines = (
"metacrawler", "http://search.metacrawler.com/crawler?general=XXXX&method=0&cat=uk&target=metaworld&redirect=web&rpp=20&hpe=10&region=0&timeout=0&sort=0&format=beta99&theme=classic&refer=mc-searc h",
"altavista", "http://www.altavista.co.uk/cgi-bin/query?pg=q&sc=on&q=XXXX&kl=XX&what=uk",
"excite", "http://www.excite.co.uk/search.gw?lang=en&look=excite_uk&search=XXXX&c=web.uknp",
"infoseek", "http://www.infoseek.com/Titles?qt=XXXX&oq=site%3Auk&rf=0&col=WW&sv=UK&cat=RES",
"looksmart", "http://www.looksmart.co.uk/r_search?look=&pin=000517x4c529b67247432d1d61&isp=UK&key=XXXX&search=us686888%3Bus325798",
"lycos", "http://www.lycos.co.uk/cgi-bin/pursuit?matchmode=and&mtemp=main.sites&etemp=error&query=XXXX&cat=brit",
"searchuk", "http://uk.searchengine.com/cgi-bin/search?search=XXXX&related=0&d=2&g=0&w=0&y=1&z=0",
"yahoo", "http://uk.search.yahoo.com/search/ukie?p=XXXX&y=y"
"netscape", "http://directory.netscape.com/cgi-bin/search?cp=nsiwidsrc&utf8=1&search=XXXX&all=no&cat=Regional%2FEurope%2FUnited_Kingdom",
);

&parse;
&gotosearch;

sub parse {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
if ($name ne "searchwords") {
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
}
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/<([^>]|\n)*>//g;
$IN{$name} = $value;
}
}

sub gotosearch {
my $swords = $IN{'searchwords'};
my $engine = $engines{$IN{'engines'}};
if (!$engine) { &error(1); }
if (!$swords) { &error(2); }
$engine =~ s/XXXX/$swords/;
print "Location: $engine \n\n";
}

sub error {
print "Content-type: text/html \n\n";
if ($_[0] == 2) {
print "ERROR! MUST ENTER SEARCH WORDS!\n";
} elsif ($_[0] == 1) {
print "ERROR! MUST SELECT SEARCH ENGINE!\n";
} else {
print "UNKNOWN ERROR!\n";
}
exit;
}




perlkid
stranger

May 19, 2000, 12:51 AM

Post #2 of 2 (461 views)
Re: Search Script Problem. [In reply to] Can't Post

  
Ok Devs,

I looked and looked at this one and it just looks fine. The last thing I looked for is an @ that's not escaped. ex \@. But I didn't find that, So just try changing to \ in the meta crawler engine url.

If that doesn't do a thing than email me and I'll take a look at it.

perlkid

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives