#!/usr/local/bin/perl ($cmd,@param) = split(/\,/,$ENV{QUERY_STRING}); $testdir = 'c:/www/siteman/client/nyucfp/website/cfp20001'; $livedir = '/usr/local/ns-home/cfpweb'; $basehref = "http://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}"; $basehref =~ s/cgi\-bin\/[\x00-\xff]+//; $basehref =~ s/[\/]+$/\//; $out = "ADVANCED SEARCH
\n";
if ($cmd eq 'search') {
read(STDIN,$buffer,$ENV{CONTENT_LENGTH});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$form{$name} = $value;
}
if ($form{allscps}) {
$out .= "
Please wait while we access the main site search...
";
}
else {
if ($form{area} eq 'ALL') {
$q1 = ".html";
$q2 = ".html";
}
elsif ($form{area} =~ /^[A-Z]/) {
$q1 = "cour$form{area}";
$q2 = "$form{area}.html";
}
else {
$q1 = $form{area};
$q2 = $form{area};
}
opendir(FDIR,$testdir) || opendir(FDIR,$livedir) || die("can't open directory for search!");
@files = readdir(FDIR);
$hits = 1;
@words = split(/ /,$form{keywords});
foreach $file (@files) {
if (($file =~ $q1) || ($file =~ $q2)) {
if (open(FILE,"$testdir/$file") || open(FILE,"$livedir/$file")) {
$foundit = 0;
while ($nextline =
\n";
$hits++;
}
}
}
}
if ($hits == 1) {
$out .= "Sorry, no pages were found containing you search string.\n";
}
}
}
elsif ($cmd eq '') {
$out .= "
";
}
if (open(FILE,"$testdir/Resources.html") || open(FILE,"$livedir/Resources.html")) {
while ($nextline =
Keyword(s):
Area:
Search Keywords as Phrase
Search Entire SCPS Site