I have a script I've written. This is actually part of a larger script
that I use to display digital photos on a website at my domain.
However, this is the part of the script that doesn't work correctly:
<?
$dirname = ".";
print "<center>\n";
// Start
$subdirname = "current";
$eh = opendir($subdirname);
print "<tr>\n";
$count = 1;
$currentHeader = false;
while (gettype($subfile = readdir($eh)) != boolean)
{
$ext = substr($subfile, strlen($subfile) - 3, 3);
$ext = strtolower($ext);
if (!is_dir("$dirname/$subdirname/$subfile") && $ext == "jpg")
{
if ($currentHeader != true)
{
print "<table cellspacing='0' cellpadding='0'
bgcolor='$bgcolor' border='3'>\n";
print " <tr>\n";
print " <td align='center'>\n";
print " <h3>Current</h3>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
$currentHeader = true;
#We need to make a table for the thumbnails to appear in...
print " <table cellspacing='0' cellpadding='0'>\n";
}
print "<td>\n";
$subfilename = htmlspecialchars($subfile, ENT_QUOTES);
$filename = $dirname."/".$subdirname."/mini/mini-".$subfilename;
print "<a
href='".$dirname."/".$subdirname."/".$subfilename."'>\n";
print "<img src='$filename' width=100 height=100 alt=\"$subfile
\">\n";
print "</a>\n";
print "</td>\n";
$count++;
if ($count > 5)
{
print "</tr>\n";
print "<tr>\n";
$count = 1;
}
}
}
//if ($count == 1) print "Sorry, there are no images to display
here.<br><br>\n";
//
if (gettype($subfile = readdir($eh)) == boolean)
{
print "<table cellspacing='0' cellpadding='0' bgcolor='$bgcolor'
border='3'>\n";
print " <tr>\n";
print " <td align='center'>\n";
print " <h3>Current</h3>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "<b>Sorry, there are no available images to display
here.</b><br><br>\n";
}
print " </tr>";
print " </table\n";
print " <br>\n";
print " <br>\n";
// End
print " </center>\n";
print "<br>\n";
?>
What it's supposed to do is to show the "Current" heading and then any
pictures in the 'current' directory. If there aren't any pictures, it
should display the message "Sorry, there are no available images to
display here.". Instead, it displays both. In the 'current' directory
there will always be a directory called 'mini'. If only the mini
directory exists, then there are no current images. Can anyone help me
with this? If helpful, the URL of the page that uses this script is
http://www.espersunited.com/~michael/camera/ . Thank you for your help.
-Michael Sullivan-