Here's the error:
Here's the line:
and Here's the full code:
For the life of me, I can't replicate this error and it only happens once in awhile. Usually fixing it includes clearing the cache and cookies and then it never comes back. However, I've found one case where it happens time and time again. Unfortunately the machine is in the UK so I can't see exactly what the user is doing. Can someone help end this madness?? What if I remove the -wT, will that fix it?
Thanks,
- MT
Code:
Use of unititialized value in -3 at line 11
Here's the line:
Code:
$currentFolder =~ s/\%20/ /gi unless (-e $currentDirectory);
and Here's the full code:
Code:
#!/usr/bin/perl -wT
use integer;
print "Content-type: text/html\n\n";
my $currentFolder = $ENV{"QUERY_STRING"}?substr($ENV{"QUERY_STRING"},17):"";
my $currentDirectory;
my $length = length($currentFolder);
if ($length > 0) {
$currentFolder =~ s/\%20/ /gi unless (-e $currentDirectory);
$currentDirectory = "/var/[URL unfurl="true"]www/html/ftpfiles"[/URL] . $currentFolder . "/";
}
else {
$currentDirectory = "/var/[URL unfurl="true"]www/html/ftpfiles/";[/URL]
}
opendir (FTPDIR, $currentDirectory) || dienice($!);
sub dienice {
print "<div style=\"color:red;\">Error ",$_[0],"</div>";
print $currentDirectory;
exit;
}
my @folderContents = readdir (FTPDIR);
closedir (FTPDIR);
print <<"HTML code";
<html>
<head>
<title>Untitled Document</title>
<link href=../ftpStyle.css rel=stylesheet type=text/css>
<script src=../jsLibFTP.js></script>
</head>
<body>
<table width=100% border=0 cellspacing=2 cellpadding=0>
<tr align=left valign=top>
<td width=2%><a href=../cgi-bin/listFiles.cgi><img src=../images/icon_arrowPrev.gif width=20 height=22 border=0></a></td>
<td width=98%><a href=../cgi-bin/listFiles.cgi>Return To Main Directory</a></td>
</tr>
</table>
<table width=80% border=0 align=center cellpadding=0 cellspacing=0>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_gray_corner_tl.gif width=19 height=20></td>
<td background=../images/box_gray_side_t.gif><img src=../images/box_gray_side_t.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_gray_corner_tr.gif width=19 height=20></td>
</tr>
<tr align=center valign=top>
<td background=../images/box_gray_side_l.gif><img src=../images/box_gray_side_l.gif width=19 height=2></td>
<td bgcolor=#f2f2f2>
<table width=100% border=0 cellspacing=5 cellpadding=0>
<tr valign=top>
<td width=3% align=center> </td>
<td width=70% class=tableHeader>Name</td>
<td width=17% class=tableHeader>Date</td>
<td width=10% class=tableHeader>Size</td>
</tr>
<tr valign=top>
<td align=center><img src=../images/icon_folderOpen.gif width=27 height=22></td>
<td><b>$currentFolder</b></td>
<td> </td>
<td> </td>
</tr>
HTML code
if (@folderContents) {
foreach my $indivFile (@folderContents) {
next if $indivFile=~m/^\.+$/;
my $fullUnit = $indivFile;
# escape the following "."
my ($name, $extension) = split (/\./ , $indivFile);
if ($extension) {
my $adjustedLink = $fullUnit;
## my @info = stat("/var/[URL unfurl="true"]www/html/ftpfiles/$fullUnit");[/URL]
my $funkyChicken = "/var/[URL unfurl="true"]www/html/ftpfiles".[/URL] $currentFolder . "/" . $adjustedLink;
my @info = stat($funkyChicken);
$adjustedLink =~ s/ /\%20/gi;
$currentDirectory =~ s/ /\%20/gi;
my $biteSize = $info[7];
my $fileSize = $biteSize/1024;
@date=localtime $info[9];
$date[5]+=1900; $date[4]++;
$extension = lc ($extension);
print "<tr valign=top>\n";
print "<td align=center><img src=../images/icon_" . $extension . ".gif width=18 height=22></td>\n";
print "<td><a href=fileDownload.cgi?fileName=" . $currentDirectory . $adjustedLink . ">$fullUnit<a></td>\n";
print "<td>";
printf "%02d/%02d/%04d %02d:%02d:%02d",@date[4,3,5,2,1,0];
print "</td>\n";
print "<td>" . $fileSize . "k</td>\n";
print "</tr>";
}
else {
my $adjustedLink = $fullUnit;
$adjustedLink =~ s/ /\%20/gi;
$currentFolder =~ s/ /\%20/gi;
$adjustedLink = $currentFolder . "/" . $adjustedLink;
print "<tr valign=top>\n";
print "<td align=center><img src=../images/icon_.gif width=20 height=22></td>\n";
print "<td><a href=listFiles.cgi?currentDirectory=" . $adjustedLink . ">$fullUnit<a></td>\n";
print "<td>---</td>\n";
print "<td>---</td>\n";
print "</tr>";
}
}
}
print <<"HTML code";
</table>
<br>
<br>
</td>
<td background=../images/box_gray_side_r.gif><img src=../images/box_gray_side_r.gif width=19 height=2></td>
</tr>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_gray_corner_bl.gif width=19 height=20></td>
<td background=../images/box_gray_side_b.gif><img src=../images/box_gray_side_b.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_gray_corner_br.gif width=19 height=20></td>
</tr>
</table>
<br>
<div align="center" class="legalText"><i>If you suspect that a file is missing or that that a specific directory/file listing is incorrect, please contact <a href="mailto:matt.torbin\@peigenesis.com?subject=FTP Site Comments">Matt Torbin</a></i></div>
<br><br>
</body>
</html>
HTML code
For the life of me, I can't replicate this error and it only happens once in awhile. Usually fixing it includes clearing the cache and cookies and then it never comes back. However, I've found one case where it happens time and time again. Unfortunately the machine is in the UK so I can't see exactly what the user is doing. Can someone help end this madness?? What if I remove the -wT, will that fix it?
Thanks,
- MT