Автор: 0x7d26a
Дата сообщения: 17.05.2006 15:16
kozandr
Идею понял и наваял вот такой скрипт:
Код: #!/usr/bin/perl -w
#Coded by 0x7d26a
#Config:
$htdocsdir = "htdocs";
$nscript = "search.pl";
#EndConfig
print "Content-Type: text/html\n\n";
&parse_form;
print <<HCODZ;
<html>
<title>Search in $htdocsdir</title>
<body style="text-align:center">
<br><br><br><br><br><br>
<table cellpadding="2" cellspacing="1" style="border:1 solid #306DA5">
<form method="POST" action=$nscript>
<tr><td colspan=2 style="color:#0f37b9;text-align:center;
background-color:#dddddd;border:1px solid #306DA5">-----==xXx==-----</td></tr>
<tr><td>Path:</td><td><input name="a" size=20 value="$FORM{a}"></td></tr>
<tr><td>File:</td><td><input name="b" size=20 value="$FORM{b}"></td></tr>
<tr><td colspan=2 style="text-align:center"><input type="submit" value=" Search "></td></tr>
<input type="hidden" name="match" value=1>
</form>
HCODZ
if ($FORM{'match'} == 1)
{
$path = $FORM{'a'};
$file = $FORM{'b'};
print "<tr><td colspan=2>Results:</td></tr>\n";
opendir(ED, $path);
foreach $name (sort readdir(ED))
{
$line = "$path/$name";
if(-d $line)
{
$line = "$line/$htdocsdir/$file";
if(-e $line)
{
print "<tr><td colspan=2 style=\"color:#0f37b9\">$line</td></tr>\n";
}
}
}
closedir(ED);
print "</table>\n</body>\n</html>\n";
}
else
{
print "</table>\n</body>\n</html>\n";
}
sub parse_form
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}