Hi all
This may be hard for you to understand.......
I got a gallery script that reads a Gallery folder and shows the pics as thmbnails it also picks up anyother folders within the main Gallery folder and makes a link to a gallery for that folder.
But the problem is anypics in the main gallery folder show as thumbnails and they open a larger view when clicked,
But the folders within the main gallery folder just show the thumbnails and when clicked it dont show the larger pic!
You can see the script at
http://www.simplygaming.co.uk/?temp_view=gallery.php
Here is the Code for the script.....
<? // Image listing script
$title='Downloads';
$showfilenames=0;
$openwindow=0; // open in popup, 1 = true, 0 = false
$showimagesize=1;
$thumbnails=1;
$browse=1;
$filetypes='jpg|gif|png|zip';
$fadethumbs=1;
$rootdir='./gallery'; // directory to show images in, '.' will show images in the same dir as the file.
$os="NIX"; // Operating System, set as "WIN" if you are using Windows, otherwise leave as "NIX"
$tdcolor="FFFFFF"; // main td color
$tdovercolor="CCCCCC"; // td mouseover color
$bordercolor="ffffff"; // table border color
$textcolor="000000"; // td text color
$tablewidth='95%'; // width of the table.. you might want to change this to fit your layout better.
$imconvert='/usr/local/bin/convert';
////
// To use file descriptions, save a plain text file named FILENAME.EXT.desc , with the description in it
// for example, to have a description for beach.jpg, you would save your description file as beach.jpg.desc
// .desc files will NOT be listed by this script, even if you have $filetypes set to '.'
function cleanData($data) {
// removes characters that break things ;]
$data = ereg_replace("-","",$data);
$data = ereg_replace(" ","",$data);
$data = ereg_replace('.','',$data);
$data = ereg_replace('\'','',$data);
return $data;
}
if (!$gamedir == "") {
$rootdir = "$gamedir";
}
$showdir = ereg_replace("../","",$showdir);
if ($showdir) { $listdir = $rootdir.ereg_replace("./","",$showdir); } else { $listdir = $rootdir; }
$handle=@opendir($listdir);
if (!$handle) { echo "No Downloads ('.$listdir.'), dying."; exit(); }
while (($file = readdir($handle))!==false) {
$filearray[count($filearray)] = $file;
}
asort($filearray); closedir($handle);
$filecount=0;
foreach ($filearray as $file) {
$name = split(".",$file);
if ((eregi($filetypes,$name[count($name)-1]) == true) && (eregi("thumb",$file) == false)) { $filecount++; }
}
if (!$title) $title = 'Listing all available images in '.$listdir;
$title.=' ('.$filecount.' files)';
echo '
<script language="JavaScript">
function openl(img,nw,nh) {';
if ($openwindow == 1) { echo '
window.open("gallery.php?x=view&img=" + img, nw+nh, "toolbar=no,menubar=no,location=no,scrollbars=no,resize=no,width=" + nw + ",height=" + nh);'; }
else { echo 'document.location=img;'; }
echo '}</script>
<table border="1" cellpadding="0" cellspacing="0" width="95%" borderColor="#000000">
<tr><td colspan="3" bgcolor="#336699" align="center"><font face="verdana" size="2" color="#FFFFFF"><b>'.$title.'</b></font></td></tr>';
if ($x == "view") {
echo '<div align="center">
<a href="javascript:history.go(-1)"><font face="verdana" size="1" color="'.$textcolor.'"><b>[ Go Back << ]</b></a><br><br></font>
<img src="./'.$listdir.'/'.$img.'"><BR>---';
}
if ($os == "WIN") {
$tmp = split('/',$SCRIPT_NAME);
$docroot = @ereg_replace($tmp[count($tmp)-1],'',$SCRIPT_NAME);
} else {
$tmp = split('/',$SCRIPT_FILENAME);
$docroot = @ereg_replace($tmp[count($tmp)-1],'',$SCRIPT_FILENAME);
}
@chdir($docroot.$listdir);
if (($browse==1) && ($os != "WIN")) {
if ($showdir) {
$updir = split("/",$showdir);
$tmp = count($updir)-1;
$i=0;
while ($i<$tmp) {
$back.=$updir[$i].'/';
$i++;
}
$back = substr($back,0,strlen($back)-1);
echo '<tr><td colspan="3" bgcolor="'.$tdcolor.'" align="center"><font face="verdana" size="2" color="'.$textcolor.'"><b><a href="?temp_view=gallery.php">« Back to the Main Gallery</a></b></font></td></tr>';
}
foreach ($filearray as $file) {
if (is_dir($file) && $file != '.' && $file != '..') {
// count files
$tmphandle=@opendir($file);
$subfilecount=0;
while (($tmpfile = readdir($tmphandle))!==false) {
$tmpname = split("\.",$tmpfile);
if ((eregi($filetypes,$tmpname[count($tmpname)-1]) == true) && (eregi("thumb",$tmpfile) == false)) {
$subfilecount++; }
}
closedir($tmphandle);
echo '<tr><td colspan="3" bgcolor="'.$tdcolor.'" align="left"><font face="verdana" size="1" color="'.$textcolor.'"><b><a href="?temp_view=gallery.php&showdir='.$showdir.'/'.$file.'">'.$file.'</a> ('.$subfilecount.' Pictures)</b></font></td></tr>';
}
}
}
foreach ($filearray as $file) {
$name = split(".",$file);
if (eregi($filetypes,$name[count($name)-1]) == true) {
if (eregi("zip",$name[count($name)-1]) == true) {
$fimage="1";
} else {
$image="2";
}
$file_size = filesize($file);
if ($file_size >= 1073741824) {
$file_size = round($file_size / 1073741824 * 100) / 100 . "g";
} elseif ($file_size >= 1048576) {
$file_size = round($file_size / 1048576 * 100) / 100 . "m";
} elseif ($file_size >= 1024) {
$file_size = round($file_size / 1024 * 100) / 100 . "k";
} else {
$file_size = $file_size . "b";
}
unset($fileinfo);
if (file_exists($file.'.desc')) {
if ($showfilenames == 1) $fileinfo = '<b>'.$file.'</b><br>';
$fdesc = fopen ($file.'.desc',r);
$fileinfo .= fread ($fdesc, filesize ($file.'.desc'));
fclose ($fdesc);
} else {
$fileinfo = '<b>'.$file.'</b> ';
}
if ($size = @getimagesize($file)) {
$nw = $size[0] + 23;
$nh = $size[1] + 40;
}
if ($showimagesize == 1) {
$imagesize = $size[0].'x'.$size[1];
}
if ($file != '.' && $file != '..' && !ereg('.desc',$file) && !ereg('thumb',$file)) {
echo '<tr>';
if ($thumbnails==1) {
if ($imconvert && !file_exists($name[0].'_thumb.gif')) exec($imconvert.' -quality 70 -geometry 80X60 '.$docroot.$listdir.'/'.$file.' '.$docroot.$listdir.'/'.$name[0].'_thumb.gif');
if (file_exists($name[0].'_thumb.gif')) {
$thumbnailimg = $listdir.'/'.$name[0].'_thumb.gif';
} else { $thumbnailimg = $listdir.'/'.$file; }
if ($fimage =="") {
// fade effect toggle
if ($fadethumbs == 1) {
echo '<td valign="top" bgcolor="'.$tdcolor.'" style="cursor: hand" onclick="openl(\'./?temp_view=gallery.php&x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')" onmouseover="a'.cleanData($file).'.filters.alpha.opacity=\'100\';" onmouseout="a'.cleanData($file).'.filters.alpha.opacity=\'20\';" width="80"><img style="filter:alpha(opacity=40);" id="a'.cleanData($file).'" src="'.$thumbnailimg.'" width="80" height="70"></td>';
} else { echo '<td valign="top" bgcolor="'.$tdcolor.'" style="cursor: hand" onclick="openl(\'./?temp_view=gallery.php&x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')" width="80"><img id="a'.cleanData($file).'" src="'.$thumbnailimg.'" width="80" height="60"></td>'; }
}
} else {
// fade effect toggle
if ($fadethumbs == 1) {
echo '<td valign="top" bgcolor="'.$tdcolor.'" style="cursor: hand" onclick="openl(../gallery.php?x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')" onmouseover="a'.cleanData($file).'.filters.alpha.opacity=\'100\';" onmouseout="a'.cleanData($file).'.filters.alpha.opacity=\'20\';" width="80"><img style="filter:alpha(opacity=40);" id="a'.cleanData($file).'" src="'.$fimage.'" width="80" height="70"></td>';
} else { echo '<td valign="top" bgcolor="'.$tdcolor.'" style="cursor: hand" onclick="openl(\'./?temp_view=gallery.php&x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')" width="80"><img id="a'.cleanData($file).'" src="'.$fimage.'" width="80" height="60"></td>'; }
}
if (!$fimage =="1") {
$tdwidth = $tablewidth - 130;
echo '<td valign="top" width="90" bgcolor="'.$tdcolor.'" align="right" style="cursor: default;"><font face="verdana" size="1" color="'.$textcolor.'">'.$file_size.' '.$name[count($name)-1].' <br>'.$imagesize.' </font></td>
<td width="'.$tdwidth.'" valign="top" bgcolor="'.$tdcolor.'" onclick="openl(\'./?temp_view=gallery.php&x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')" style="padding-left: 8;">
<font face="verdana" size="1" color="'.$textcolor.'"><a style="color: '.$textcolor.'; cursor: hand; text-decoration: none;" href="javascript:openl(\'./?temp_view=gallery.php&x=view&img='.$file.'\',\''.$nw.'\',\''.$nh.'\')">'.$fileinfo.'</a></font></td>
</tr>';
} else {
$tdwidth = $tablewidth - 130;
echo '<td valign="top" width="90" bgcolor="'.$tdcolor.'" align="right" style="cursor: default;"><font face="verdana" size="1" color="'.$textcolor.'">'.$file_size.' <br> Zip File </font></td>
<td width="'.$tdwidth.'" valign="top" bgcolor="'.$tdcolor.'" onclick="openl(\'./'.$listdir.'/'.$file.'\',\''.$nw.'\',\''.$nh.'\')" style="padding-left: 8;" colspan="2">
<font face="verdana" size="1" color="'.$textcolor.'"><a style="color: '.$textcolor.'; cursor: hand; text-decoration: none;" href="javascript:openl(\'./'.$listdir.'/'.$file.'\',\''.$nw.'\',\''.$nh.'\')">'.$fileinfo.'</a></font></td>
</tr>';
}
}
}
}
echo '</table>';
@chdir($docroot);
?>