As you probably already know; I am a newbie at this little PHP thing. I finally found a script after a very long time that will auto generate thumbnails from a given folder, and doesn't require MYSQL knowledge (whatever that thing is). The only problem now is the sorting.
I am planning on numbering photos 001, 002, 003 etc. and I want it to display the last number first so that when I add 045, it appears first; followed by 044, 043, etc. The author of the script helped me narrow down where this "sort" code needs to go; but all this may as well be Japanese backwards. I was told it needs to be an array, then reversed. If anyone can help me with this I would greatly appreciate it!
This is where the sort array should be (I guess)
Line 58-60:
if ($handle = opendir("albums/$picdir")) {
while (false !== ($file = readdir($handle))) {
Here is the full code:
<?php
global $bg_color;
$file="bin/bpa.ini";
$fp = fopen($file,"r");
$title = trim(fgets($fp, 4096));
$title_font = trim(fgets($fp, 4096));
$title_size = trim(fgets($fp, 4096));
$title_bold = trim(fgets($fp, 4096));
$title_color = trim(fgets($fp, 4096));
$bg_color = trim(fgets($fp, 4096));
$caption_font = trim(fgets($fp, 4096));
$caption_size = trim(fgets($fp, 4096));
$caption_bold = trim(fgets($fp, 4096));
$caption_color = trim(fgets($fp, 4096));
$caption_rollover = trim(fgets($fp, 4096));
$thumbnail_width = trim(fgets($fp, 4096));
$thumbnails_per_row = trim(fgets($fp, 4096));
$show_dimensions = trim(fgets($fp, 4096));
$show_filename = trim(fgets($fp, 4096));
fclose($fp);
echo "<body link=\"$caption_color\" vlink=\"$caption_color\" alink=\"$caption_rollover\" text=\"$title_color\" bgcolor=\"$bg_color\">";
echo "<style fprolloverstyle>A:hover {color: $caption_rollover;}</style>";
$picdir = trim($_GET["folder"]);
//////////////////////////
$column_width = 100 / $thumbnails_per_row; // Figures out percentage of screen each column should take up
$rowcount = 0;
echo "<center>";
echo "<font face=\"$title_font\" size=\"$title_size\">";
if ($title_bold == "checked") {
echo "<b>"; }
echo "$title</font>";
if ($title_bold == "checked") {
echo "</b>"; }
echo "<table border='0' cellpadding='5' cellspacing='5' style='border-collapse: collapse' width='100%' id='AutoNumber1'>";
echo "<tr>";
if ($handle = opendir("albums/$picdir")) {
while (false !== ($file = readdir($handle))) {
$pos = strrpos($file, "."); // finds the position of the right-most period in the file name (the extension)
$ext = substr($file, $pos, 5); // puts the file's extension into $ext
$ext = strtolower($ext); // converts the extension to all lowercase
if ($ext == ".jpg" || $ext == ".jpeg" || $ext == ".gif" || $ext == ".png") { // only show image if it is a valid graphics file
echo "<td align='center' width=$column_width>";
echo "<font face='$caption_font' size='$caption_size' color='$caption_color'>";
if ($caption_bold == "checked") {
echo "<b>"; }
$size = getimagesize ("albums/$picdir/$file");
$image_ratio = $size[1] / $size[0];
$thumb_height = $thumbnail_width * $image_ratio;
echo "<a href=\"bin/view.php?image=$picdir/$file";
echo "&bg=$bg_color\" target='_self' style=\"text-decoration: none\">";
echo "<img border=0 src ='albums/$picdir/$file' width='$thumbnail_width' height='$thumb_height'><br>";
if ($show_dimensions="checked")
echo "</a>";
echo "</td>";
$rowcount++;
if ($rowcount >= $thumbnails_per_row)
{
echo "</tr>";
echo "<tr>";
$rowcount=0;
}
}
}
closedir($handle);
}
// Close out the table
echo "</tr>";
echo "</table>";
echo "<p>";
echo "<input type=\"button\" value=\"Go Back\" onclick=\"history.go(-1)\">";
echo "<br>";
echo "</center>";
echo "</font>";
?>