<?php
	require("../__common__/__define_common.php");
	require("../__common__/include-common-all.php");
	require("../account/__logincheck.php");

	$file_name = $_GET['file'].'';
	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($file_name, 0, $len) <> photo_LIMITED_IMAGES_FOLDER) {
				exit;
			}
		}
	}
	if ($file_name == '') {
		exit;
	}
	if ($mime_type = is_video_filename($file_name)) {
		$file_SJIS = mb_convert_encoding($file_name, 'SJIS-win', 'UTF-8');
		$fp = fopen($file_SJIS, "rb");
		if ($fp) {
			if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
				$filename = mb_convert_encoding(substr($file_name,strrpos($file_name,'/')+1), 'SJIS-win', 'UTF-8');
			} else {
				$filename = urlencode(substr($file_name,strrpos($file_name,'/')+1));
			}
			header('Content-type: '.$mime_type.'; name='.$filename);
			header('Content-Disposition: inline; filename='.$filename);
			fpassthru($fp);
		}
	}
?>
