ik heb het script hier gebruikt van ik geloof bas en het werkt prima alleen wil ik er twee dingen op uitbreiden als dat kan.

- ik wil graag maar 12 thumbs per pagina en de rest op een nieuwe pagina, hoe doe ik dit?
- ik wil graag de fotos op volgorde getoond hebben, dit moet in een array dat weet ik maar ik kom er niet uit.

dit is het script.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>|| Fotoalbums ||</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="system/main.css" type="text/css" rel="stylesheet">
</head>

<style>
body {
background-image: url(../logo.jpg);
background-repeat: no-repeat;
background-position: center top;
}
</style>
<body>
<a href="../intro.php">Home</a><br><br>

<?


Function Numdirs($dir)
{

if(!$dir)
$dir = ".";

$handle = opendir($dir);
while($file = readdir($handle))
{
if(is_dir("$dir/$file") && $file != "thumbs" && $file != "." && $file != ".." && $file != "system")
$numdirs++;
}
return $numdirs;
}

Function NumPics($dir)
{
$handle = opendir($dir);
while($file = readdir($handle))
{
$filetype = substr($file,-3,3);
if ($filetype == "jpg" || $filetype == "JPG" )
$numpics++;
}
return $numpics;
}

function ThumbAvail($file)
{
$fp = popen("./jhead -st - '$file' 2>&1", "r");
while (!feof($fp)) {
$buf .= fread($fp, 1024);
}

if(strstr($buf,"thumbnail"))
return 0;
else
return 1;
}

Function ImgSize($file)
{
$fp = popen("./jhead '$file' 2>&1", "r");
while (!feof($fp)) {
$buf .= fread($fp, 1024);
}

//Resolution : 1536 x 2048
eregi("Resolution.* ([0-9]{1,}) x ([0-9]{1,})[^0-9]",$buf, $res);

$res[0] = trim(substr($res[0],12));

return $res;
}

Function GetNextName($name)
{

if(file_exists($name))
{
$handle = opendir('.');
while($file = readdir($handle))
{

$filetype = substr($file,-3,3);

if ($filetype == "jpg" || $filetype == "JPG" )
{
if($stop)
return($file);

if($file == $name)
$stop = 1;
}

}
}

}

Function GetPrevName($name)
{

if(file_exists($name))
{
$handle = opendir('.');
while($file = readdir($handle))
{

$filetype = substr($file,-3,3);

if ($filetype == "jpg" || $filetype == "JPG" )
{
if($file == $name)
return($oudefile);
else
$oudefile = $file;
}
}
}

}


Function CreateThumb($file)
{

if(!is_dir("thumbs"))
{
$res = @mkdir("thumbs",0777);

if(!$res)
{
echo "Geen rechten om thumbnails aan te maken.";
exit();
}
else
chmod("thumbs",0777);
}

//set_time_limit (30);

$imagehw = GetImageSize("$file");
$src_width = $imagehw[0];
$src_height = $imagehw[1];

// orrigineel
//$src_width > $src_height ? $dest_width = 100 : $dest_width = 75;
$src_width > $src_height ? $dest_width = 75 : $dest_width = 50;

$tmp = $src_width / $dest_width;
$dest_height = $src_height / $tmp;

$src_img = imagecreatefromjpeg("$file");
$dst_img = imagecreatetruecolor($dest_width,$dest_height);

imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagejpeg($dst_img, "thumbs/$file", 75);
imagedestroy($src_img);
imagedestroy($dst_img);




}

if($dir == "")
$dir = ".";
chdir($dir);


if($show == "")
{
if($dir == ".")
$showdir = "";
elseif(substr($dir,0,2) == "./")
$showdir = substr($dir,2,strlen($dir));
else
$showdir = $dir;

echo "<table border=0 cellpadding=3 cellspacing=0 width=80% align=center>\n\n";
if($showdir != "")
{
$lastslash = strrpos($dir,"/");
$tmpdir = substr($dir,0,$lastslash);
$back = "<a href=\"$PHP_SELF?dir=$tmpdir\">Terug naar de albums</a>";
}

echo "<tr><td align=right>$back</td></tr>";
echo "<tr class=row0><td align=center>$showdir</td></tr>";
echo "</table>";


$numdirs = NumDirs("");
if($numdirs)
{
//Eventuele dirs laten zien
echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 width=80% align=center>\n\n";
echo "<tr class=row0><td colspan=3>Albums</td></tr>\n";


$handle = opendir('.');
while($file = readdir($handle))
{
$bgclass == "row1" ? $bgclass = "row2" : $bgclass = "row1";
if(is_dir($file) && $file != "thumbs" && $file != "." && $file != ".." && $file != "system")
{
$numpics = Numpics($file);
$numdirs = Numdirs($file);

$shownumpics = "";
if($numpics)
$numpics == 1 ? $shownumpics = "1 foto" : $shownumpics = "$numpics foto's";

$shownumdirs = "";
if($numdirs)
$numdirs == 1 ? $shownumdirs = "1 subcategorie" : $shownumdirs = "$numdirs subcategorieen";

echo "<tr class=$bgclass><td align=center width=60><a href=\"$PHP_SELF?dir=$dir/$file\"><img src=system/arrow.gif border=0></a></td><td><a href=\"$PHP_SELF?dir=$dir/$file\">$file</a></td><td width=100 align=center>$shownumpics$numdiv $shownumdirs</td></tr>\n";
}

}

echo "</table>";
}


$numpics = NumPics(".");

if($numpics)
{
//Losse Foto's laten zien
echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 width=80% align=center>\n\n";
echo "<tr><td>";
echo "<table border=0 cellpadding=5 cellspacing=0 width=100%>\n\n";
//echo "<tr class=row0><td>Thumbnail</td><td>Filename</td><td>Filesize</td><td>Size</td></tr>\n";

$handle = opendir('.');
while($file = readdir($handle)) {


$filetype = substr($file,-3,3);

if ($filetype == "jpg" || $filetype == "JPG" )
{
$bgclass == "row1" ? $bgclass = "row2" : $bgclass = "row1";

$filesize = round(filesize($file)/1024);
$namelength= strlen($file)-4;
$file = substr($file,0,$namelength);

$imagehw = GetImageSize("$file.$filetype");
$width = $imagehw[0];
$height = $imagehw[1];


if(!file_exists("thumbs/$file.$filetype"))
CreateThumb("$file.$filetype");


if(!$width)
{
$imghw = ImgSize("$file.$filetype");
$width = $imghw[1];
$height = $imghw[2];
}

//-- edited by me..


if (!$count)
$count = 1;

if ($count == 1)
{
echo "<tr class=$bgclass>\n";
echo "<td align=center width=\"25%\" ><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=><a/></td>\n";
}
elseif ($count == 2)
echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
elseif ($count == 3)
echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
elseif ($count == 4)
{
echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
echo "</tr>\n";
$count = "0";
}




/*
echo "<tr class=$bgclass>\n";
echo "<td align=center width=100><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
echo "<td><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\">$file</a></td>\n";
echo "<td>$filesize kB</td>";
echo "<td>$width&nbspx&nbsp;$height</td>";
echo "</tr>";
*/

$count++;

$totalfilesize += $filesize;
$totalwidth += $width;
$totalheight += $height;
$numimg++;
}


}
}

if($numimg)
{
$avgwidth = round($totalwidth / $numimg);
$avgheight = round($totalheight / $numimg);
$avgfilesize = round($totalfilesize / $numimg);
$totalfilesize = round($totalfilesize / 1000,2);

echo "<tr class=row0><td colspan=4 align=center>Statistieken</td></tr>\n";
echo "<tr class=row1><td colspan=2>Totaal aantal foto's</td><td colspan=2>$numimg</td></tr>\n";
echo "<tr class=row2><td colspan=2>Gemiddelde foto</td><td colspan=2>$avgfilesize kB</td></tr>\n";
echo "<tr class=row1><td colspan=2>Gemiddelde afmetingen</td><td colspan=2>$avgwidth x $avgheight</td></tr>\n";
echo "<tr class=row2><td colspan=2>Totaal foto's</td><td colspan=2>$totalfilesize MB</td></tr>\n";
}


if ($dir != ".")
echo "</table></td></tr></table>";

}
elseif($show == "img")
{

$showfile = substr($file,0,-4);
echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 class=contenttable width=80% align=center>\n\n";


$nextimg = GetNextName($file);
if($nextimg)
$next = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$nextimg\">[ Volgende ]</a>";
$previmg = GetPrevName($file);
if($previmg)
$prev = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$previmg\">[ Vorige ]</a>";


if($nextimg)
$img = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$nextimg\"><img border=0 src=\"$dir/$file\"></a>";
else
$img = "<img src=\"$dir/$file\">";

$prev && $next ? $div = " | " : $div = "";
echo "<tr class=row0><td align=right><a href=\"$PHP_SELF?dir=$dir\">Terug naar de thumbs</a></td></tr>\n";
echo "<tr><td colspan=2 align=center>$prev$div$next</td></tr>\n";
echo "<tr class=row1><td colspan=2 align=center>$img</td></tr>";
echo "<tr><td colspan=2 align=center>$prev$div$next</td></tr>\n";

echo "</table>";



$lastslash = strrpos($HTTP_SERVER_VARS[SCRIPT_FILENAME],"/");
$root = substr($HTTP_SERVER_VARS[SCRIPT_FILENAME],0,$lastslash+1);





$fp = popen("$root/system/./jhead -se '$file' 2>&1", "r");
while (!feof($fp)) {
$buf .= fread($fp, 1024);
}



// echo $buf;
/*
if(!strstr($buf,"denied"))
{
$tmp = explode("\n",$buf);
for($i = 0; $i <= count($tmp); $i++)
{
if($tmp[$i] != "")
{
$tmp2 = explode(": ",$tmp[$i]);
$info[$i][key] = trim($tmp2[0]);
$info[$i][val] = trim($tmp2[1]);
}
}

echo "<table border=0 cellpadding=3 cellspacing=1 class=contenttable width=100%>\n\n";
echo "<tr><td height=20>&nbsp;</td></tr>\n";
echo "<tr class=row0><td colspan=2>Camera Instellingen</td></tr>\n";
for($i = 0; $i <= count($info); $i++)
{

if($info[$i][key] && $info[$i][val])
echo "<tr class=row1><td width=100>{$info[$i][key]}</td><td>{$info[$i][val]}</td></tr>\n";
elseif($info[$i][key] && !$info[$i][val])
echo "<tr class=row1><td colspan=2>{$info[$i][key]}</tr>\n";

}
}
echo "</table>";
*/
}

if ($dir == ".")
{
$path = "..";
$imgpath = "..";
//echo "</tr></table>";
}
else
{
$path = "../..";
$imgpath = "..";
}
?>
</body>
</html>

Reageren