#!/usr/local/bin/perl # # susi-grep.pl: unified search index # Version 0.1 # Date: Thu Jan 6 09:44:55 GMT 1994 # # Martijn Koster (m.koster@nexor.co.uk) package susi; # adjust this for your site. $hostname = `hostname` =~/victor/ ? 'localweb' : 'web'; $hostname .= '.nexor.co.uk'; &main'debug("susi: hostname for local redirection = $hostname"); # adjust this to your preference # the single space in the URL is replaced with the query string %servers = ( 'ALIWEB', "http://web.nexor.co.uk/aliwebsimple? ", 'W3 Catalog at NEXOR', "http://$hostname/w3catalog? ", 'W3 Catalog', 'http://cui_www.unige.ch/w3catalog? ', 'Sinbad', "http://$hostname/sinbadgw/read:mak/sinbad/index.db? ", 'RBSE', 'http://rbse.jsc.nasa.gov/htbin/urlsearch? ', 'JumpStation', 'http://www.stir.ac.uk/jsbin/h1_js? ', 'WWW Nomad', 'http://www.rns.com/cgi-bin/parse?Topic= ', 'Archie', "http://$hostname/archieplex/server=archie.doc.ic.ac.uk/type=substring/order=host? ", 'WAIS', 'wais://cnidr.org:210/directory-of-servers? ', 'Windows Archive', 'gopher://micros.hensa.ac.uk/77/%2bgopher/%2bmicros/%2bibmpc/%2bwin/%2bwais/index? ', 'Mac Archive', "http://$hostname/mac-archive-find/grep? ", 'RFC Index', "http://$hostname/rfcindex? ", 'ID Index', "http://$hostname/idindex? ", ); @fields = ('service', 'query'); @requiredfields = ('service', 'query'); sub main'do_susi { local($query) = @_; $query ? &search($query) : &dialog; } sub dialog { &main'MIME_header('ok', 'text/html'); print <<'DIALOG'; SUSI Search

SUSI Search

This is a simple unified search interface for several search engines in the Web.
Search term:

Search Engine:


Martijn Koster
DIALOG } sub search { local($query) = @_; local(@terms) = split('&', $query); for(@terms) { local($tag, $value) = split('=', $_, 2); &main'error('bad_request', "Unknown tag: '$tag'. ") if (! grep(/^$tag$/, @fields)); $value =~ s/\+/ /g; $value =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; &main'error('bad_request', "Duplicate tag: '$tag'.") if ($tags{$tag}); $tags{$tag} = $value; } # some specific checking to supply useful error messages # prevents user problems being reported as internal problems # There might be a better facility for this in Plexus 3.0 if ($tags{'query'} eq '') { print 'Please specify a search term.'; return; } # make sure required tags are there for (@requiredfields) { &main'error('bad_request', "Missing required tag '$_'.

\n" . 'You probably have an browser that cannot handle forms properly.') if (!$tags{$_}); } &main'error('bad_request', "Please specify a search term.") if (!$query); $service = $tags{'service'}; # lookup what the user filled in $url = $servers{$service}; &main'error('bad_request', "Unknown Server '$service'. \n") if (!$url); $query = $tags{'query'}; $url =~ s/\s/$query/; &main'add_header(*main'out_headers, "Location: $url"); &main'MIME_header('found', 'text/html'); print "This document has moved to $service"; return; }