<?php
	require("../__common__/__define_common.php");
	require("__define.php");
	require("../__common__/include-common-all.php");
	require("../__common__/include-common-html.php");
	require("../account/__logincheck.php");
	if ($_SESSION['システム管理者'] <> "YES") {
		exit;
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Language" content="ja">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="author" content="ok.2nd">
<title>JPEG: EXIF情報</title>
<link rel="stylesheet" href="<?= _STYLE_SHEET_FOLDER ?>/tools_common.css?20091105" type="text/css">
<style type="text/css">
#filename {
	color: #0000ff;
}
#exif p {
	line-height: 1.0;
	border-bottom: 1px solid #ffc080;
}
</style>
</head>
<body>
<?php
	if (($file = my_GET('path')) == '') {
		error_exit('パス指定がありません。');
	}
	echo '<h4>ファイル：<span id="filename">'.$file.'</span></h4>';
	$exif = @exif_read_data(myfile_ENCODE($file));
	if (!$exif) {
		error_exit('EXIF情報がありません。');
	}
	$ort = $exif['Orientation'];
	if (!$ort) {
		echo 'Orientation情報はありません。<br><br>';
	} else {
		echo 'Orientation = <b>'.$ort.'</b> : '.exif_ort_impli($ort).'<br>';
		// echo '<img src="image/exiforientation.jpg"><br>';
		// by http://www.nikep.net/srdpty/index.php?/archives/24-unknown.html
	}
	echo '<h4>《EXIF 全データ》</h4>';
	echo '<div id="exif">';
	foreach ($exif as $key=>$value) {
		echo '<p>'.$key.'=';
		if ($key == 'FileDateTime') {
			echo date('Y/m/d H:i:s', $value);
		} elseif ($key <> 'MakerNote') {
			if (is_array($value)) {
				echo '(<br>';
				foreach ($value as $k2=>$v2) {
					echo myfile_DECODE($k2).'='.myfile_DECODE($v2).'<br>';
				}
				echo ')';
			} else {
				echo myfile_DECODE($value);
			}
		}
		echo '</p>';
	}
function exif_ort_impli($ort) {
	$ort_impli = array(
		1 => 'nothing',
		2 => 'horizontal flip',
		3 => '180 rotate left',
		4 => 'vertical flip',
		5 => 'vertical flip + 90 rotate right',
		6 => '90 rotate right',
		7 => 'horizontal flip + 90 rotate right',
		8 => '90 rotate left'
		);
	return $ort_impli[$ort];
/*
	$ort	0th　Row	0th Column
	1	top		left side
	2	top		right side
	3	bottom		right side
	4	bottom		left side
	5	left		side top
	6	right		side top
	7	right		side bottom
	8	left		side bottom
	switch($ort) {
		case 1: // nothing
		break;
		case 2: // horizontal flip
			$image->flipImage($public,1);
		break;
		case 3: // 180 rotate left
			$image->rotateImage($public,180);
		break;
		case 4: // vertical flip
			$image->flipImage($public,2);
		break;
		case 5: // vertical flip + 90 rotate right
			$image->flipImage($public, 2);
			$image->rotateImage($public, -90);
		break;
		case 6: // 90 rotate right
			$image->rotateImage($public, -90);
		break;
		case 7: // horizontal flip + 90 rotate right
			$image->flipImage($public,1);	
			$image->rotateImage($public, -90);
		break;
		case 8:	// 90 rotate left
			$image->rotateImage($public, 90);
		break;
	}
*/
}
?>
