#!/usr/athena/bin/perl -w

# This program takes in search terms and search engine from the 
# footer of http://stuff.mit.edu
#
# The search engine options ($engine) are searching within stuff.mit.edu, 
# the MIT people directory, web.mit.edu, and Google.
#
# jtu Aug 22 2005
#

# CGI mod is needed to parse arguments
use CGI qw(:standard);  

### Grab the two variables passed in -- what to search for, and in what context
my $terms = param("search_terms");
my $engine = param("search_where");

### Redirect to the appropriate search engine and site based off $engine.
### If none is specified (which should never happen), return home.

if ($engine eq "stuff.mit.edu") {
  print "Location: http://search.mit.edu/search?q=$terms&btnG=Search+stuff.mit.edu&site=mit&client=mit&proxystylesheet=mit&output=xml_no_dtd&as_dt=i&as_sitesearch=stuff.mit.edu\n\n";
}

elsif ($engine eq "MITdir") {
  print "Location: http://web.mit.edu/bin/cgicso?query=$terms\n\n";
}

elsif ($engine eq "web.mit.edu") {
  print "Location: http://search.mit.edu/search?client=mit&site=mit&output=xml_no_dtd&proxystylesheet=mithome&as_q=$terms\n\n";
}

elsif ($engine eq "Google") {
  print "Location: http://www.google.com/search?q=$terms\n\n";
}

else {
  print "Location: http://stuff.mit.edu\n\n";
}
