#!/usr/bin/perl #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; $FORM{$name}= $value; } } $keyword=$FORM{keyword}; print "Content-type: text/html\n\n"; print "

Here are the files we found

\n\n"; chdir("/usr/local/etc/httpd"); opendir(DIR, "."); while($file = readdir(DIR)) { next if ($file !~ /.htm/); open(FILE, $file); $foundone = 0; $title = ""; while () { if (/$keyword/i) { $foundone = 1; } if (//) { chop; $title = $_; $title =~ s/<TITLE>//g; $title =~ s/<\TITLE>//g; } } if ($title eq "") { $title = $file; } if($foundone) { print "<A HREF=/$file>$title</A><BR>"; $listed=1; } close(FILE);