http://www.whiteskies.co.uk/New%20Gallery/teste.php
The problem is the pic, it should open up the directory and pic a random file inside and display it. Only problem, it doesnt always sort it in the same order, which i dont understand. anyway, heres my code, its messy and is probably hard to follow.
Code: Select all
<link href="http://www.whiteskies.co.uk/whiteskies.css" rel="stylesheet" type="text/css"> <?
$myDirectory = opendir(".");
while($entryName = readdir($myDirectory))
{
$dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount = count($dirArray);
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=\"small\">\n");
print("<TR><TH>Filename</TH><th>Filetype</th><th>filesize</th><TH>Pic</TH></TR>\n");
for($index=2; $index< $indexCount-2; $index++)
{
print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
print("<td>");
print(filetype($dirArray[$index]));
print("</td>");
print("<td>");
print(filesize($dirArray[$index]));
print("</td>");
print("<td>");
if(is_dir($dirArray[$index])) {
$picDirectory = opendir("$dirArray[$index]");
while($file = readdir($picDirectory))
{
$image[$i]=$file;
$picount = count($image);
sort($image);
}
$i = rand(3,$picount);
echo "i = $i";
echo "<img src=\"tncreate.php?dirname=$dirArray[$index]&filename=$image[$i]\">";
closedir($picDirectory);
}
Else {echo "Show Thumbnail Failed!";
}
print("</td>");
print("</TR>\n");
}
print("</TABLE>\n");
?>