#!/usr/bin/perl -w
# The following code deals with the form data
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
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;
$value =~ s/["]//gi;
$value =~ s/[+]/ /gi;
$FORM{$name} = $value;
}
}
$keyword=$FORM{keyword};
chdir("/home/1008/gnicoll/www.abernyte.net/public_html");
opendir(DIR, ".");
print "Content-type: text/html\n\n";
print"";
print"
";
print"";
print"";
print"";
print" | ";
print" | ";
print"
";
print"";
print"
";
print"";
print"";
print"";
print"![]() |
";
print"";
print"";
print"";
print"| Search Results - Your Search for the keyword(s)
$keyword returned the following results: |
";
print"";
print"";
print"";
print"Noogle
Home
Documentation
Credits
FAQ
Quiz ";
print"
";
print" | ";
print" | ";
print" | ";
print" | ";
print"Search Results | ";
print"
";
print"";
print" | ";
print" | ";
print"";
print"";
print"";
print"";
while($file = readdir(DIR))
{
next if ($file !~ /.html/);
open(FILE, $file);
$foundone = 0;
$title = "";
while ()
{
if (/$keyword/i)
{
$foundone = 1;
}
if(//)
{
chop;
$title = $_;
$title =~ s///g;
$title =~ s/<\/title>//g;
}
if(//)
{
chop;
$title = $_;
$title =~ s///g;
$title =~ s/<\/TITLE>//g;
}
if($title eq "")
{
$title = $file;
}
if(///g;
}
if(///g;
}
if($content eq "")
{
$content = "No Meta-tag page information available";
}
if($author eq "")
{
$author = "No Meta-tag author information available";
}
$count++ while /$keyword/ig;
}
if($foundone)
{
print "$title ";
print"";
print"";
print"Results: $count occurrence(s) of the word(s) \"$keyword\"
on this page. Page Description: $content Page Author: $author URL:http://www.ally.nu/$file | ";
print" ";
print" ";
print" ";
$count = 0;
$listed=1;
}
close(FILE);
}
if($listed ne 1)
{print " Sorry, your search returned $foundone results. Search
Again?";}
else
{print "
Do you want a new search?";}
print"
| ";
print"
";
print"";
print"
";
print"
";
print"";
print"";
print"";
print"";
print"![]() |
";
print"";
print"";
print"";
print"| ";
print" |
HTML>";
closedir(DIR);
exit;