include_once("./_common.php");
// 불법접속을 할 수 없도록 세션에 아무값이나 저장하여 hidden 으로 넘겨서 다음 페이지에서 비교함
$token = md5(uniqid(rand(), true));
set_session("ss_token", $token);
$rand = rand(4, 6);
$norobot_key = substr($token, 0, $rand);
set_session('ss_norobot_key', $norobot_key);
// 오늘 본 상품 저장 시작
// tv 는 today view 약자
$saved = false;
$tv_idx = (int)get_session("ss_tv_idx");
if ($tv_idx > 0) {
for ($i=1; $i<=$tv_idx; $i++) {
if (get_session("ss_tv[$i]") == $it_id) {
$saved = true;
break;
}
}
}
if (!$saved) {
$tv_idx++;
set_session("ss_tv_idx", $tv_idx);
set_session("ss_tv[$tv_idx]", $it_id);
}
// 오늘 본 상품 저장 끝
// 조회수 증가
if ($_COOKIE[ck_it_id] != $it_id) {
sql_query(" update $g4[yc4_item_table] set it_hit = it_hit + 1 where it_id = '$it_id' "); // 1증가
setcookie("ck_it_id", $it_id, time() + 3600, $config[cf_cookie_dir], $config[cf_cookie_domain]); // 1시간동안 저장
}
// 분류사용, 상품사용하는 상품의 정보를 얻음
$sql = " select a.*,
b.ca_name,
b.ca_use
from $g4[yc4_item_table] a,
$g4[yc4_category_table] b
where a.it_id = '$it_id'
and a.ca_id = b.ca_id ";
$it = sql_fetch($sql);
if (!$it[it_id])
alert("자료가 없습니다.");
if (!($it[ca_use] && $it[it_use])) {
if (!$is_admin)
alert("판매가능한 상품이 아닙니다.");
}
// 분류 테이블에서 분류 상단, 하단 코드를 얻음
$sql = " select ca_include_head, ca_include_tail
from $g4[yc4_category_table]
where ca_id = '$it[ca_id]' ";
$ca = sql_fetch($sql);
$g4[title] = "상품 상세보기 : $it[ca_name] - $it[it_name] ";
// 분류 상단 코드가 있으면 출력하고 없으면 기본 상단 코드 출력
if ($ca[ca_include_head])
@include_once($ca[ca_include_head]);
else
include_once("./_head.php");
// 분류 위치
// HOME > 1단계 > 2단계 ... > 6단계 분류
$ca_id = $it[ca_id];
include "$g4[shop_path]/navigation1.inc.php";
$himg = "$g4[path]/data/item/{$it_id}_h";
if (file_exists($himg))
echo "
";
// 상단 HTML
echo stripslashes($it[it_head_html]);
if ($is_admin)
echo "

";
// 이 분류에 속한 하위분류 출력
include "$g4[shop_path]/listcategory.inc.php";
// 이전 상품보기
$sql = " select it_id, it_name from $g4[yc4_item_table]
where it_id > '$it_id'
and SUBSTRING(ca_id,1,4) = '".substr($it[ca_id],0,4)."'
and it_use = '1'
order by it_id asc
limit 1 ";
$row = sql_fetch($sql);
if ($row[it_id]) {
$prev_title = "[이전상품보기] $row[it_name]";
$prev_href = "";
} else {
$prev_title = "[이전상품없음]";
$prev_href = "";
}
// 다음 상품보기
$sql = " select it_id, it_name from $g4[yc4_item_table]
where it_id < '$it_id'
and SUBSTRING(ca_id,1,4) = '".substr($it[ca_id],0,4)."'
and it_use = '1'
order by it_id desc
limit 1 ";
$row = sql_fetch($sql);
if ($row[it_id]) {
$next_title = "[다음상품보기] $row[it_name]";
$next_href = "";
} else {
$next_title = "[다음상품없음]";
$next_href = "";
}
// 관련상품의 갯수를 얻음
$sql = " select count(*) as cnt
from $g4[yc4_item_relation_table] a
left join $g4[yc4_item_table] b on (a.it_id2=b.it_id and b.it_use='1')
where a.it_id = '$it[it_id]' ";
$row = sql_fetch($sql);
$item_relation_count = $row[cnt];
?>
// 하단 HTML
echo stripslashes($it[it_tail_html]);
$timg = "$g4[path]/data/item/{$it_id}_t";
if (file_exists($timg))
echo "
";
if ($ca[ca_include_tail])
@include_once($ca[ca_include_tail]);
else
include_once("./_tail.php");
?>