$Gal = "misc"; //title
$thumb = "//tmp//thumb"; //thumbs directory name
$thumbwidth = 200;
$imagequality = 200;
$cols = 6; //number of columns
$vi = "Click me!"; //text for "See image"
$sname = "lah.php"; //name of this file
$isz = ""; //text for "Size"
$msgnav = ""; //text for "Showing Gallery"
$msgcp = ""; //text for "Image"
$msgof = "of "; //text for "of"
$msgback = "Back to gallery listing"; //text for "Return to Gallery"
if (isset($_GET['iid'])) {
$_GET['iid'];
} elseif (isset($_POST['iid'])) {
$_POST['iid'];
}
$files = array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (eregi("\.jpe?g$", $file) ||
eregi("\.gif$", $file) ||
eregi("\.png$", $file)) {
$files[] = $file;
}
}
}
closedir($handle);
}
sort($files);
if (!is_dir($thumb)) {
mkdir($thumb, 0755);
}
$i = 0;
$th = array();
$iw = array();
$ih = array();
$ifs = array();
foreach ($files as $image) {
$thumbimage = $thumb."/".$image;
$thumb_exists = file_exists($thumbimage);
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$type = $size[2];
if (!$thumb_exists) {
set_time_limit(30);
switch ($type) {
case 1 :
$im = ImageCreateFromGIF($image);
break;
case 2 :
$im = ImageCreateFromJPEG($image);
break;
case 3 :
$im = ImageCreateFromPNG($image);
break;
}
$newwidth = $thumbwidth;
$newheight = ($newwidth / $width) * $height;
$im2 = ImageCreateTrueColor($newwidth,$newheight);
ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$new height,$width,$height);
switch ($type) {
case 1:
ImageGIF($im2, $thumbimage);
break;
case 2:
ImageJpeg($im2, $thumbimage, $imagequality);
break;
case 3:
ImagePNG($im2, $thumbimage);
break;
imagedestroy($im);
imagedestroy($im2);
}
}
$th[$i] = $thumbimage;
$iw[$i] = $width;
$ih[$i] = $height;
$ifs[$i] = round((@filesize($image)/1024), 1);
$i++;
}
echo "
Gallery of \"$Gal\"
";
echo "
";
if (!isset($iid)) {
$rows = round(count($th)/$cols);
if (($rows * $cols) < (count($th))) {
$rows++;
}
for ($i = 1; $i <= $rows; $i++) {
echo "";
for ($j = 1; $j <= $cols; $j++) {
$td = (($i - 1) * $cols) + $j;
$iu = ($td - 1);
if (isset($th[$iu])) {
$op = "";
$op .= "\n\n | \n";
echo $op;
} else {
echo "\n
| \n";
}
}
echo "
\n";
}
} else {
$iid2 = $iid+1;
$tot = count($th);
$op = "";
$op .= "\n\n $msgnav $Gal :: $msgcp $iid2 $msgof $tot | \n
\n\n";
$op .= "\n\n \n";
$op .= " \n";
//$op .= " $isz: $iw[$iid] x $ih[$iid]\n";
$op .= " $ifs[$iid] Kb.\n";
$op .= " \n \n | \n
\n";
$op .= "\n\n |
";
echo $op;
}
echo "
";
?>