<?php
	require("__include-common.php");
	require("../account/__logincheck.php");
	if ($_SESSION['photo_open_path'] == '') {
		header("Location: index.php");
	}
	if (empty($_SESSION['photo'])) {
		header("Location: index.php");
	}
	if (empty($_SESSION['photo_img_count'])) {
		header("Location: index.php");
	}
	if ($_SESSION['photo_img_count'] < 1) {
		header("Location: index.php");
	}
	$open_path = $_SESSION['photo_open_path'];
	if (defined("photo_LIMITED_IMAGES_FOLDER") and photo_LIMITED_IMAGES_FOLDER <> '') {
		if ($_SESSION['システム管理者'] <> 'YES' or photo_LIMITED_ADMIN_NOLIMIT <> 'YES') {
			$len = strlen(photo_LIMITED_IMAGES_FOLDER);
			if (substr($open_path, 0, $len) <> photo_LIMITED_IMAGES_FOLDER) {
				header("Location: index.php");
			}
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<title>MyHome Photo Galleria Lightbox</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<!-- http://galleria.aino.se/ -->
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script src="galleria/src/galleria.js"></script>
<script src="galleria/src/themes/lightbox/galleria.lightbox.js"></script>
<script>
document.onkeydown = keyPress;
$('.images').galleria();
function keyPress( e ) {
	e = e || window.event;
	if (e.keyCode == 27) {		// ESC ：Exit, Return
		history.back();
		return false;
	}
	return true;			// その他 (ファンクションキーなどを有効にするため)
}
</script>
</head>
<body>
<div class="images">
<?php
	$img_count = $_SESSION['photo_img_count'];
	for ($ix = 0; $ix < $img_count; $ix++) {
		$img_file = $open_path.'/'.$_SESSION['photo'][$ix]['file'];
		if ($_SESSION['photo'][$ix]['type'] == 'video') {
			$img = 'video-jpeg.php?file='.urlencode($img_file).'&ss='.$_SESSION['video_thumb_ss'];
		} else {
			$img = 'img-view.php?img='.urlencode($img_file);
		}
?>
		<img src="<?= $img ?>" title="<?= $_SESSION['photo'][$ix]['file'] ?>"/>
<?
	}
?>
</div>
</body>
</html>