<?php
/************************************************************************
 * This file is part of Windows Image Gallery.				*
 *									*
 * Windows Image Gallery is free software:				*
 * you can redistribute it and/or modify				*
 * it under the terms of the GNU General Public License as published by	*
 * the Free Software Foundation, either version 3 of the License, or	*
 * (at your option) any later version.					*
 *									*
 * Windows Image Gallery is distributed in the hope that it will be	*
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty	*
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	*
 * GNU General Public License for more details.				*
 *									*
 * You should have received a copy of the GNU General Public License	*
 * along with Windows Image Gallery.					*
 * If not, see <http://www.gnu.org/licenses>.				*
 ************************************************************************/

require('config.php');
$dir = $_GET['dir'];
$view =  $_GET['view'];
$filePath = "images/".$dir.'/';    //path to your images
$target_thumb = '_blank'; //The target page for the biger picture, '_blank' or make it emty '' for same page hyperlink
$filePaththumb = $filePath.'thumbs/';
$window_med_width = $image_med_width+60;
$window_med_height = $image_med_height+20;
include 'include/functions.php';


?>
	<p align="center">
		<a href="#" onClick="ajaxwin.load('ajax', 'gallery.php?dir=<?php echo $dir; ?>', '<?php echo $dir; ?>'); return false">Thumbnails</a> | 
		<a href="#" onClick="ajaxwin.load('ajax', 'gallery.php?dir=<?php echo $dir; ?>&view=detail', '<?php echo $dir; ?>'); return false">Details</a>
	</p>
<?php



if ($view == "detail") {
	echo "<table border='0' width='100%' cellspacing='0' cellpadding='0'>";
}




$string =array();
$dir = opendir($filePaththumb);
while ($file = readdir($dir)) {
	if (eregi("\.png",$file) || eregi("\.jpg",$file) || eregi("\.gif",$file) ) {
	$string[] = $file;
	}
}

while (sizeof($string) != 0){
	$img = array_pop($string);
?>

	<div id="<?php echo $img; ?>" style="display:none">
	<center><p style="height: 380px"><a href='<?php echo "$filePath$img"; ?>' target='<?php echo $target_thumb; ?>'><img src="<?php echo "$filePath$img"; ?>" width="<?php echo $image_med_width; ?>px" border="0"></a></p></center>
	</div>


	<?php
	if ($view == "detail") {
		?>
		<tr>
			<td>
				<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', '<?php echo $img; ?>', '<?php echo $img; ?>', 'width=<?php echo $window_med_width; ?>px,height=<?php echo $window_med_height;?>px,left=150px,top=80px,resize=0,scrolling=1'); return false">
				<img src='<?php echo "$filePaththumb$img"; ?>' hspace='1' vspace='1' border='0' width='<?php echo "$thumb_width_detail.px"; ?>'/></a>
			</td>
			<td>
				<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', '<?php echo $img; ?>', '<?php echo $img; ?>', 'width=<?php echo $window_med_width; ?>px,height=<?php echo $window_med_height;?>px,left=150px,top=80px,resize=0,scrolling=1'); return false">
				<?php echo $img; ?></a>
			</td>
			<td>
				<?php
				// outputs e.g.  somefile.txt was last changed: December 29 2002 22:16:23.
				echo date("F d Y H:i:s", filectime($filePath.$img));
				?>
			</td>
			<td width="140">
				<?php
				list($width, $height, $type, $attr) = getimagesize("$filePath$img");
				echo $width." X ".$height." Pixels";
				?>
			</td>
			<td width="100">

				<?php
				$imgsize = filesize("$filePath$img");
				$imgsize = $imgsize/1024;
				$imgsize = round($imgsize, 2);  
				echo $imgsize." KB";
				?>
			</td>
		</tr>
		<?php
	} else {
		?>
		<a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', '<?php echo $img; ?>', '<?php echo $img; ?>', 'width=<?php echo $window_med_width; ?>px,height=<?php echo $window_med_height;?>px,left=150px,top=80px,resize=0,scrolling=1'); return false">
		<img src='<?php echo "$filePaththumb$img"; ?>' hspace='5' vspace='5' border='0' width='<?php echo "$thumb_width.px"; ?>'/></a>
		<?php
	}
}



if ($view == "detail") {
	echo "</table>";
}



?>