#!/usr/local/bin/perl
#searchpartic.pl
#copyright CSNET written by Brian Maguire 


# Define the location of the database
$DATABASE="/export/home/www/mirroreddns/secure/partnerdata.list";

# Define the path to cgiparse
$CGIPATH="/export/home/httpd/cgi-bin/";





@query = ($grade_level,$student_number,$country,$language);

# Do the search only if a query was entered
if (length(query)>0) {	
  print <<EOM;
Search for <B>@query</B> yields these entries:
<PRE>
EOM

#Inform user if search is unsuccessful
$answer = `grep -i @query $DATABASE`;
if (!$answer) { print "Search was unsuccessful\n" ;}
else { print $answer\n" ; }

}
#=====================================================================
# GENERAL PURPOSE (BOILERPLATE) ROUTINES
#=====================================================================

sub LocalReadParse
# from Steven Brenner's cgi-lib.pl v1.14
{
  local (*in) = @_ if @_;
  local ($i, $key, $val);

  # Read in text
  if (&LocalMethGet)
  {
    $in = $ENV{'QUERY_STRING'};
  }
  elsif (&LocalMethPost)
  {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  }

  @in = split(/[&;]/,$in);

  foreach $i (0 .. $#in)
  {
    # Convert plusses to spaces
    $in[$i] =~ s/\+/ /g;

    # Split into key and value
    # splits on the first =
    ($key, $val) = split(/=/,$in[$i],2);

    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/%(..)/pack("c",hex($1))/ge;

    # Associate key and value
    # \0 is the multiple separator
    $in{$key} .= "\0" if (defined($in{$key}));
    $in{$key} .= $val;
  }
  return scalar(@in);
}

sub LocalMethGet
# from Steven Brenner's cgi-lib.pl v1.14
# true if this cgi call was using the GET request, false otherwise
{
  return ($ENV{'REQUEST_METHOD'} eq "GET");
}

sub LocalMethPost
# from Steven Brenner's cgi-lib.pl v1.14
# true if this cgi call was using the POST request, false otherwise
{
  return ($ENV{'REQUEST_METHOD'} eq "POST");
}

sub PrintHeader
{
  print "Content-type: text/html\n\n";
  return;
}


