#!/usr/local/bin/perl
#      ↑Perl5のあるパスに修正する。

#ライブラリインクルード
use DBI;

#日本語コード変換らいぶらり
require Jcode;

#PL設定情報 DBデータの並び順番など連想配列
require '../../syssyssyssyssyssyssyssyssyssys/HP_Make/db_narabi.pl';

#==========================================================================
#   hiresphoto.cgi
#==========================================================================

	#引数のチェック
#	if($#ARGV != 2) {&Error};

	# 引き数パラメータの設定
	$syouhin_no		= $ARGV[0];  # 商品番号
    $gazou_no		= $ARGV[1];  #画像番号
    $REFERER_URL	= $ARGV[2];  #呼び出し元のURL
    $SNAME			= $ARGV[3];  #呼び出し元のSession NAME
    $SID			= $ARGV[4];  #呼び出し元のSession ID

	#DB接続
	$tmp = "DBI:mysql:" . $db_name . ":" . $host_name;
	$db = DBI->connect($tmp,$user,$pass);


	$SQL = "SELECT * FROM 商品データ WHERE 商品番号 = '$syouhin_no'";
	$sth = $db->prepare($SQL);
	if(!$sth->execute) { print (OUT "SQL失敗".$sth->errstr."<br>".$sth->err."<br>");}
	@gdata = $sth->fetchrow_array;
	$sth->finish;

	$sth_tmp = $db->prepare("SELECT `コメント` FROM `商品写真コメント` WHERE (商品番号 = '".$syouhin_no."') AND (写真番号 ='".$gazou_no."')");
	if(!$sth_tmp->execute) { print (OUT "SQL失敗1".$sthb->errstr."<br>".$sthb->err."<br>");}
	($comment) = $sth_tmp->fetchrow_array;
	$sth_tmp->finish;

	if($comment){
		$comment = "<div style='background-color:#F1CC4E;'>".$comment."</div><br>";
	}else{
		$comment = "";
	}

	#DB切断
	$db->disconnect;

	print "Content-type: text/html; charset=SJIS\n\n";
	print <<EOF;
<html>
<head>
<title>Hi Res Photo</title>
</head>
<body bgcolor="#ffff88">
<center>
EOF
	if($gazou_no==1){

		print "<img src='$HP_Addr/sys/HP_Make/mobile_resize.php?file=$HP_Addr/$gdata[$DB_Narabi{DB_Sub_Dir}]/Photos/".$gdata[$DB_Narabi{DB_Base_Photo_Name}].".jpg'><br><br>";

		print "<img src='$HP_Addr/$gdata[$DB_Narabi{DB_Sub_Dir}]/Photos/".$gdata[$DB_Narabi{DB_Base_Photo_Name}]."_120px.jpg'><br><br>";
	} else {

		print "<img src='$HP_Addr/sys/HP_Make/mobile_resize.php?file=$HP_Addr/$gdata[$DB_Narabi{DB_Sub_Dir}]/Photos/$gdata[$DB_Narabi{DB_Base_Photo_Name}]_$gazou_no.jpg'<br><br>";


#		print "<img src='$HP_Addr/$gdata[$DB_Narabi{DB_Sub_Dir}]/Photos/$gdata[$DB_Narabi{DB_Base_Photo_Name}]_".$gazou_no."_120px.jpg'><br><br>";
	}

	$comment = &Jcode'convert($comment,'sjis');
	print $comment;
	print "<a href='$REFERER_URL?$SNAME=$SID'>Back</a>";
	print <<EOF;
</center>
</body>
</html>
EOF

