<?php
if (!defined('_GNUBOARD_')) exit; //개별 페이지 접근 불가

global $g5, $member;

//경매정보 라이브러리
include_once (G5_SKIN_PATH.'/board/auction/auction.lib.php');

// 추출하기
if(!$wset['rows']) {
	$wset['rows'] = 24;
}

// 추출하기
$list = apms_item_rows($wset);

$list_cnt = count($list); // 글수

$rank = apms_rank_offset($wset['rows'], $wset['page']);

// 새상품
$is_new = (isset($wset['new']) && $wset['new']) ? $wset['new'] : 'red';
$new_item = ($wset['newtime']) ? $wset['newtime'] : 24;

// DC
$is_dc = (isset($wset['dc']) && $wset['dc']) ? $wset['dc'] : 'orangered';

// 그림자
$shadow_in = '';
$shadow_out = (isset($wset['shadow']) && $wset['shadow']) ? apms_shadow($wset['shadow']) : '';
if($shadow_out && isset($wset['inshadow']) && $wset['inshadow']) {
	$shadow_in = '<div class="in-shadow">'.$shadow_out.'</div>';
	$shadow_out = '';
}

//$list_cnt = count($list);

include_once($list_skin_path.'/category.skin.php');
include_once(G5_PATH.'/mylib/rpc_grade.lib.php');
if(!function_exists('vpn_category_badge_html')) {
	function vpn_category_badge_html($spec_os) {
		$spec_os = trim((string)$spec_os);
		if ($spec_os === '') return '';
		$parts = explode('-', $spec_os);
		$cat = strtoupper($parts[0]);
		return '<span class="vpn-category-badge" style="display:inline-block;padding:1px 8px;border-radius:0;font-size:11px;font-weight:700;letter-spacing:.4px;background:#0891b2;color:#fff;margin-right:4px;vertical-align:middle;">'.htmlspecialchars($cat,ENT_QUOTES).'</span>';
	}
}
if(!function_exists('vpn_grade_badge_html')) {
	function vpn_grade_badge_html($grade) {
		$grade = strtoupper(trim((string)$grade));
		if ($grade === '') return '';
		$c = array('BASIC'=>'#6c757d','PLUS'=>'#0d6efd','PRO'=>'#198754','ULTRA'=>'#6f42c1','MAX'=>'#dc3545');
		$bg = isset($c[$grade]) ? $c[$grade] : '#555';
		return '<span class="vpn-grade-badge" style="display:inline-block;padding:1px 8px;border-radius:0;font-size:11px;font-weight:700;letter-spacing:.4px;background:'.htmlspecialchars($bg,ENT_QUOTES).';color:#fff;margin-right:4px;vertical-align:middle;">'.htmlspecialchars($grade,ENT_QUOTES).'</span>';
	}
}
?>

<style>
	.list-wrap { margin-right:<?php echo $minus_right;?>px; margin-bottom:<?php echo $minus_bottom;?>px; }
	.list-wrap .item-row { width:<?php echo apms_img_width($item);?>%; }
	.list-wrap .item-list { margin-right:<?php echo $gap_right;?>px; margin-bottom:<?php echo $gap_bottom;?>px; }
	.list-wrap .item-name { height:<?php echo $line_height;?>px; }
	.list-wrap .img-wrap { padding-bottom:<?php echo $img_h;?>%; }
	<?php if(_RESPONSIVE_) { // 반응형일 때만 작동 ?>
		<?php if($lg) { ?>
		@media (max-width:1199px) {
			.responsive .list-wrap .item-row { width:<?php echo apms_img_width($lg);?>%; }
		}
		<?php } ?>
		<?php if($md) { ?>
		@media (max-width:991px) {
			.responsive .list-wrap .item-row { width:<?php echo apms_img_width($md);?>%; }
		}
		<?php } ?>
		<?php if($sm) { ?>
		@media (max-width:767px) {
			.responsive .list-wrap .item-row { width:<?php echo apms_img_width($sm);?>%; }
		}
		<?php } ?>
		<?php if($xs) { ?>
		@media (max-width:480px) {
			.responsive .list-wrap .item-row { width:<?php echo apms_img_width($xs);?>%; }
		}
		<?php } ?>
	<?php } ?>
</style>

<style>
	.item-card {
		border: 1px solid #eee;
		border-radius: 0;
		background: #fff;
		box-shadow: 0 4px 6px rgba(0,0,0,0.02);
		transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
		overflow: hidden;
		display: flex;
		flex-direction: row;
		height: 135px; /* Fixed height matching image */
	}
	.item-card:hover {
		box-shadow: 0 10px 20px rgba(0,0,0,0.12);
		transform: translateY(-5px);
		border-color: #ddd;
	}
	.item-card .item-image {
		width: 135px;
		flex: 0 0 135px;
		height: 135px;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fbfbfb;
		overflow: hidden;
	}
	.item-card .item-image > a {
		width: 100%;
		height: 100%;
		display: block;
	}
	.item-card .item-image .img-wrap {
		height: 100% !important;
		padding-bottom: 0 !important;
	}
	.item-card .item-image .img-item {
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.item-card .item-image img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
	.item-card .item-content {
		flex: 1;
		padding: 7px 10px;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		min-width: 0;
		max-width: calc(100% - 135px);
		max-height: 135px;
		overflow: hidden;
	}
	.item-card .item-name {
		margin-bottom: 0;
		font-size: 15px;
		line-height: 1.3;
		display: none;
	}
	.item-name-overlay {
		position: absolute;
		top: 10px;
		left: 50%;
		transform: translateX(-50%);
		text-align: center;
		font-weight: bold;
		font-size: 16px;
		color: #fff;
		z-index: 5;
		text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
		white-space: nowrap;
	}

	.item-specs-table {
		width: 100%;
		margin: 0;
		border-collapse: collapse;
		font-size: 11px;
		color: #444;
		table-layout: auto;
	}
	.item-specs-table th, .item-specs-table td {
		padding: 0;
		border-bottom: 1px solid #f0f0f0;
		text-align: left;
		vertical-align: middle;
		line-height: 1.25;
	}
	.item-specs-table.vpn-item tr:not(:first-child) th,
	.item-specs-table.vpn-item tr:not(:first-child) td {
		padding: 0;
		line-height: 1.6;
	}
	.item-specs-table th {
		font-weight: 600;
		color: #777;
		font-size: 9px;
		text-transform: uppercase;
		letter-spacing: 0.3px;
		white-space: nowrap;
	}
	.item-specs-table th.spec-label {
		width: 1%;
		padding-right: 6px;
		white-space: nowrap;
	}
	.item-specs-table td {
		text-align: left;
		color: #222;
		font-weight: 500;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.item-specs-table .spec-full {
		text-align: left;
		padding: 1px 0;
		color: #111;
		font-weight: 700;
		font-size: 11px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.item-specs-table .spec-title-with-location {
		display: flex;
		align-items: center;
		gap: 8px;
		flex-wrap: nowrap;
	}
	.item-specs-table .spec-location {
		display: inline-flex;
		align-items: center;
		gap: 4px;
		font-size: 11px;
		font-weight: 500;
		color: #555;
		white-space: nowrap;
		flex-shrink: 0;
	}
	.item-specs-table tr:last-child th, .item-specs-table tr:last-child td {
		border-bottom: none;
	}

	.list-specs {
		flex: 1;
		min-height: 0;
		overflow: hidden;
	}

	/* Price Section */
	.item-card .item-price {
		margin-top: 0;
		padding-top: 3px;
		border-top: 2px solid #f0f0f0;
		text-align: left;
		flex-shrink: 0;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		min-width: 0;
		max-width: 100%;
	}
	.item-card .item-price b {
		font-size: 14px;
		font-weight: 700;
		color: #0063ff;
		letter-spacing: -0.3px;
	}
	.item-card .item-price small {
		font-size: 10px;
		color: #888;
		margin-left: 2px;
		font-weight: 400;
	}
	.item-card .item-price .item-sp {
		display: inline-block;
		margin-left: 3px;
		font-size: 9px;
		line-height: 1.2;
		padding: 1px 3px;
		border-radius: 2px;
		background: #f8f9fa;
		cursor: help;
	}
	.item-card .item-price .item-sp.blue {
		background: #e3f2fd;
		color: #1976d2;
	}
	.item-card .item-price .item-sp.green {
		background: #e8f5e9;
		color: #388e3c;
	}
	.item-card .item-price .item-sp.darkgray {
		background: #f5f5f5;
		color: #666;
	}
	.item-card .item-price .product-price-usage {
		margin-bottom: 4px;
	}

	.item-card .item-content .item-star {
		display: none;
	}
	.item-card .item-details {
		display: none;
	}

	.nation_flag_img2 {
		width: 20px;
		height: 14px;
		margin-left: 0;
		margin-right: 4px;
		vertical-align: middle;
		border-radius: 2px;
		box-shadow: 0 1px 2px rgba(0,0,0,0.1);
	}

	@media screen and (max-width: 991px) {
		.item-card {
			height: 120px;
		}
		.item-card .item-image {
			width: 120px;
			flex: 0 0 120px;
			height: 120px;
		}
		.item-card .item-content {
			max-height: 120px;
		}
		.item-specs-table {
			font-size: 11px;
		}
		.item-card .item-price b {
			font-size: 15px;
		}
	}

	@media screen and (max-width: 767px) {
		.item-card {
			height: 110px;
		}
		.item-card .item-image {
			width: 110px;
			flex: 0 0 110px;
			height: 110px;
		}
		.item-card .item-content {
			padding: 8px 10px;
			max-height: 110px;
		}
		.item-specs-table {
			font-size: 10px;
		}
		.item-specs-table th.spec-label {
			width: 42px;
		}
		.item-card .item-price b {
			font-size: 14px;
		}
		.nation_flag_img2 {
			width: 18px;
			height: 12px;
		}
	}
</style>

<?php
// 리스트
for ($i=0; $i < $list_cnt; $i++) {

	// 경매상품이면 상품상세페이지 URL이 다르므로 변경시켜 줌 convertUrl() 함수는 이 파일 하단에 있음 JSLEE {
	if ($list[$i]['ca_id'] == '20') {
		$list[$i]['href'] = convertUrl($list[$i]['href']);
	}
	// 경매상품이면 상품상세페이지 URL이 다르므로 변경시켜 줌 convertUrl() 함수는 이 파일 하단에 있음 JSLEE }

	// DC
	$cur_price = $dc_per = '';
	if($list[$i]['it_cust_price'] > 0 && $list[$i]['it_price'] > 0) {
		$cur_price = '<strike>&nbsp;'.number_format($list[$i]['it_cust_price']).'&nbsp;</strike>';
		$dc_per = round((($list[$i]['it_cust_price'] - $list[$i]['it_price']) / $list[$i]['it_cust_price']) * 100);
	}

	// 라벨
	$item_label = '';
	if($wset['rank']) {
		$rank_txt = ($rank < 4) ? 'Top'.$rank : $rank.'th';
		$item_label = '<div class="label-cap bg-red">'.$rank_txt.'</div>'; $rank++;
	} else if($dc_per || $list[$i]['it_type5']) {
		$item_label = '<div class="label-cap bg-red">DC</div>';
	} else if($list[$i]['it_type3'] || $list[$i]['pt_num'] >= (G5_SERVER_TIME - ($new_item * 3600))) {
		$item_label = '<div class="label-cap bg-'.$wset['new'].'">New</div>';
	}

	// 아이콘
	$item_icon = item_icon($list[$i]);
	$item_icon = ($item_icon) ? '<div class="label-tack">'.$item_icon.'</div>' : '';

	// 이미지
	// $img = apms_it_thumbnail($list[$i], $thumb_w, $thumb_h, false, true);

	// 경매정보 이미지 위에 표시 {
	if ($list[$i]['auction_on'] == '1') {

		$row1_tmp = sql_fetch(" select * from `{$g5['write_auction_table']}` where pcnum = '{$list[$i]['it_id']}' order by wr_id desc limit 1 ");
		get_info_auction($row1_tmp['wr_id'], $row1_tmp); // 이 함수 호출로 인해 최신의 경매상태정보를 변경시킴
		$row1 = sql_fetch(" select * from `{$g5['write_auction_table']}` where pcnum = '{$list[$i]['it_id']}' order by wr_id desc limit 1 ");
		$row2 = sql_fetch(" select * from `{$g5['write_auction_tender_table']}` where pcnum = '{$list[$i]['it_id']}' order by td_tender_point desc limit 1 ");

		if ($row2['td_tender_point'] === null || $row2['td_tender_point'] == 0) {

			$list[$i]['last_auction_price'] = $row1['wr_4']; // 경매 시작가
			$list[$i]['buy_it_now_price'] = $row1['wr_5']; // 경매 상한가 (즉구가)

			// 0=시작전, 1=진행중, 2=종료[낙찰], 3=종료[유찰]
			switch($row1['wr_8']) {
				case '0' : $od_status = '경매시작전'; $od_status_display = '<span style="color:silver">경매시작전</span>'; break;
				case '1' : $od_status = '경매진행중'; $od_status_display = '<span style="color:#66FF66">경매진행중</span>'; break;
				case '2' : $od_status = '경매종료[낙찰]'; $od_status_display = '<span style="color:#FFFF66">경매종료[낙찰]</span>'; break;
				case '3' : $od_status = '경매종료[유찰]'; $od_status_display = '<span style="color:silver">경매종료[유찰]</span>'; break;
				default  : $od_status = '경매취소'; $od_status_display = '<span style="color:silver">경매취소</span>'; break;
			}
			$list[$i]['last_auction_status'] = $od_status; // 경매 진행상태
			$list[$i]['last_auction_status_display'] = $od_status_display; // 경매 진행상태
			$list[$i]['rpc_rental_hours'] = (int)(isset($row1['rpc_rental_hours']) ? $row1['rpc_rental_hours'] : $row1['rpc_rental_days']);
			if($list[$i]['rpc_rental_hours'] < 1) {
				$list[$i]['rpc_rental_hours'] = 1;
			}
			$list[$i]['rpc_rental_days'] = $list[$i]['rpc_rental_hours']; // 경매 대여기간(시간)

			// 경매시작일시 주어진 시간 변수 (예: "2024-07-16 12:23:15")
			$auction_term_start = $row1['wr_1']; // 경매시작일시
			// 현재 시간
			$current_time = new DateTime();
			// 주어진 시간을 DateTime 객체로 변환
			$auction_term_start_dt = new DateTime($auction_term_start);
			// 두 시간의 차이 계산
			$interval = $current_time->diff($auction_term_start_dt);
			// 경과한 시간 형식 지정
			$auction_term_start_display = '';
			$start_display_flag = true;
			if ($interval->y > 0) {
				$auction_term_start_display .= $interval->y . '년 ';
				$start_display_flag = false;
			}
			if ($interval->m > 0) {
				$auction_term_start_display .= $interval->m . '개월 ';
				$start_display_flag = false;
			}
			if ($interval->d > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->d . '일 ';
				$start_display_flag = false;
			}
			if ($interval->h > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->h . '시간 ';
			}
			if ($interval->i > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->i . '분 ';
			}
			if ($interval->s > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->s . '초 ';
			}
			// 경과한 시간이 없다면 "0초" 표시
			if (empty($auction_term_start_display)) {
				$auction_term_start_display = '0초';
			}
			if ($start_display_flag) {
				if ((strtotime($auction_term_start)-G5_SERVER_TIME) < 0) {
					$term_start_tail_display = "경과";
				} else {
					$term_start_tail_display = "남음";
				}
			} else {
				if ((strtotime($auction_term_start)-G5_SERVER_TIME) < 0) {
					$term_start_tail_display = "이상 경과";
				} else {
					$term_start_tail_display = "이상 남음";
				}
			}

			// 경매종료일시 주어진 시간 변수 (예: "2024-07-16 12:23:15")
			$auction_term_stop = $row1['wr_2']; // 경매종료일시
			// 현재 시간
			$current_time = new DateTime();
			// 주어진 시간을 DateTime 객체로 변환
			$auction_term_stop_dt = new DateTime($auction_term_stop);
			// 두 시간의 차이 계산
			$interval = $current_time->diff($auction_term_stop_dt);
			// 경과한 시간 형식 지정
			$auction_term_stop_display = '';
			$stop_display_flag = true;
			if ($interval->y > 0) {
				$auction_term_stop_display .= $interval->y . '년 ';
				$stop_display_flag = false;
			}
			if ($interval->m > 0) {
				$auction_term_stop_display .= $interval->m . '개월 ';
				$stop_display_flag = false;
			}
			if ($interval->d > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->d . '일 ';
				$stop_display_flag = false;
			}
			if ($interval->h > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->h . '시간 ';
			}
			if ($interval->i > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->i . '분 ';
			}
			if ($interval->s > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->s . '초 ';
			}
			// 경과한 시간이 없다면 "0초" 표시
			if (empty($auction_term_stop_display)) {
				$auction_term_stop_display = '0초';
			}
			if ($stop_display_flag) {
				if ((strtotime($auction_term_stop)-G5_SERVER_TIME) < 0) {
					$term_stop_tail_display = "경과";
				} else {
					$term_stop_tail_display = "남음";
				}
			} else {
				if ((strtotime($auction_term_stop)-G5_SERVER_TIME) < 0) {
					$term_stop_tail_display = "이상 경과";
				} else {
					$term_stop_tail_display = "이상 남음";
				}
			}
			$list[$i]['rpc_auction_expire_remaintime'] = $auction_term_stop_display . $term_stop_tail_display; // 경매 종료시간

			$list[$i]['rpc_auction_expire_date'] = $row1['wr_2']; // 경매 종료시간

			$list[$i]['rpc_auction_term_stop'] = strtotime($auction_term_stop) * 1000; // 자바스크립트에서 사용할 밀리초 단위 시간

		} else {

			$list[$i]['last_auction_price'] = $row2['td_tender_point']; // 경매 시작가
			$list[$i]['buy_it_now_price'] = $row1['wr_5']; // 경매 상한가 (즉구가)

			// 0=시작전, 1=진행중, 2=종료[낙찰], 3=종료[유찰]
			switch($row2['td_status']) {
				case '0' : $od_status = '경매시작전'; $od_status_display = '<span style="color:silver">경매시작전</span>'; break;
				case '1' : $od_status = '경매진행중'; $od_status_display = '<span style="color:#66FF66">경매진행중</span>'; break;
				case '2' : $od_status = '경매종료[낙찰]'; $od_status_display = '<span style="color:#FFFF66">경매종료[낙찰]</span>'; break;
				case '3' : $od_status = '경매종료[유찰]'; $od_status_display = '<span style="color:silver">경매종료[유찰]</span>'; break;
				default  : $od_status = '경매취소'; $od_status_display = '<span style="color:silver">경매취소</span>'; break;
			}
			$list[$i]['last_auction_status'] = $od_status; // 경매 진행상태
			$list[$i]['last_auction_status_display'] = $od_status_display; // 경매 진행상태
			$list[$i]['rpc_rental_hours'] = (int)(isset($row1['rpc_rental_hours']) ? $row1['rpc_rental_hours'] : $row1['rpc_rental_days']);
			if($list[$i]['rpc_rental_hours'] < 1) {
				$list[$i]['rpc_rental_hours'] = 1;
			}
			$list[$i]['rpc_rental_days'] = $list[$i]['rpc_rental_hours']; // 경매 대여기간(시간)

			// 경매시작일시 주어진 시간 변수 (예: "2024-07-16 12:23:15")
			$auction_term_start = $row1['wr_1']; // 경매시작일시
			// 현재 시간
			$current_time = new DateTime();
			// 주어진 시간을 DateTime 객체로 변환
			$auction_term_start_dt = new DateTime($auction_term_start);
			// 두 시간의 차이 계산
			$interval = $current_time->diff($auction_term_start_dt);
			// 경과한 시간 형식 지정
			$auction_term_start_display = '';
			$start_display_flag = true;
			if ($interval->y > 0) {
				$auction_term_start_display .= $interval->y . '년 ';
				$start_display_flag = false;
			}
			if ($interval->m > 0) {
				$auction_term_start_display .= $interval->m . '개월 ';
				$start_display_flag = false;
			}
			if ($interval->d > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->d . '일 ';
				$start_display_flag = false;
			}
			if ($interval->h > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->h . '시간 ';
			}
			if ($interval->i > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->i . '분 ';
			}
			if ($interval->s > 0 && $start_display_flag) {
				$auction_term_start_display .= $interval->s . '초 ';
			}
			// 경과한 시간이 없다면 "0초" 표시
			if (empty($auction_term_start_display)) {
				$auction_term_start_display = '0초';
			}
			if ($start_display_flag) {
				if ((strtotime($auction_term_start)-G5_SERVER_TIME) < 0) {
					$term_start_tail_display = "경과";
				} else {
					$term_start_tail_display = "남음";
				}
			} else {
				if ((strtotime($auction_term_start)-G5_SERVER_TIME) < 0) {
					$term_start_tail_display = "이상 경과";
				} else {
					$term_start_tail_display = "이상 남음";
				}
			}

			// 경매종료일시 주어진 시간 변수 (예: "2024-07-16 12:23:15")
			$auction_term_stop = $row1['wr_2']; // 경매종료일시
			// 현재 시간
			$current_time = new DateTime();
			// 주어진 시간을 DateTime 객체로 변환
			$auction_term_stop_dt = new DateTime($auction_term_stop);
			// 두 시간의 차이 계산
			$interval = $current_time->diff($auction_term_stop_dt);
			// 경과한 시간 형식 지정
			$auction_term_stop_display = '';
			$stop_display_flag = true;
			if ($interval->y > 0) {
				$auction_term_stop_display .= $interval->y . '년 ';
				$stop_display_flag = false;
			}
			if ($interval->m > 0) {
				$auction_term_stop_display .= $interval->m . '개월 ';
				$stop_display_flag = false;
			}
			if ($interval->d > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->d . '일 ';
				$stop_display_flag = false;
			}
			if ($interval->h > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->h . '시간 ';
			}
			if ($interval->i > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->i . '분 ';
			}
			if ($interval->s > 0 && $stop_display_flag) {
				$auction_term_stop_display .= $interval->s . '초 ';
			}
			// 경과한 시간이 없다면 "0초" 표시
			if (empty($auction_term_stop_display)) {
				$auction_term_stop_display = '0초';
			}
			if ($stop_display_flag) {
				if ((strtotime($auction_term_stop)-G5_SERVER_TIME) < 0) {
					$term_stop_tail_display = "경과";
				} else {
					$term_stop_tail_display = "남음";
				}
			} else {
				if ((strtotime($auction_term_stop)-G5_SERVER_TIME) < 0) {
					$term_stop_tail_display = "이상 경과";
				} else {
					$term_stop_tail_display = "이상 남음";
				}
			}
			$list[$i]['rpc_auction_expire_remaintime'] = $auction_term_stop_display . $term_stop_tail_display; // 경매 종료시간

			$list[$i]['rpc_auction_expire_date'] = $row1['wr_2']; // 경매 종료시간

			$list[$i]['rpc_auction_term_stop'] = strtotime($auction_term_stop) * 1000; // 자바스크립트에서 사용할 밀리초 단위 시간

		}
	}
	// 경매정보 이미지 위에 표시 }

?>
	<div class="item-row">
		<div class="item-list item-card">
			<div class="item-image">
				<a href="<?php echo $list[$i]['href'];?>">
					<div class="img-wrap">
						<?php echo $shadow_in;?>
						<?php echo $item_label;?>
						<?php echo $item_icon;?>
						<div class="img-item">
							<img src="<?php echo $list[$i]['img']['src'];?>" alt="<?php echo $list[$i]['img']['alt'];?>">
							<?php if ($list[$i]['rpc_auction_expire_date']) { ?>
								<div class="overlay-text" style="position: absolute; top: 13px; left: 50%; transform: translate(-50%, -50%); font-size: 1rem; font-weight: bold; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:left; width:98%; background:rgba(0,0,0,0.25); padding:2px 5px;">
									<?php echo $list[$i]['last_auction_status_display']?>
								</div>
								<div class="overlay-text" style="position: absolute; top: 13px; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 1rem; font-weight: bold; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:right; width:98%; padding:2px 5px;">
									<span class="auction_remain_timer" data-expire-time="<?php echo $list[$i]['rpc_auction_term_stop'] ?>" style='font-weight:normal; font-size:0.9rem;'></span>
								</div>
								<!-- <div class="overlay-text" style="position: absolute; top: 35px; left: 50%; transform: translate(-50%, -50%); color: silver; font-size: 0.9rem; font-weight: normal; text-shadow: 2px 2px 4px rgba(0, 0, 0, 1); white-space: nowrap; text-align:center; width:98%;">
									<?php
										$auction_hours = (int)(isset($list[$i]['rpc_rental_hours']) ? $list[$i]['rpc_rental_hours'] : $list[$i]['rpc_rental_days']);
										echo "즉시구매가 " . number_format($list[$i]['buy_it_now_price']) . " Point / " . apms_contract_hours_text($auction_hours);
									?>
								</div> -->
								<div class="overlay-text" style="position: absolute; bottom: -10px; left: 50%; transform: translate(-50%, -50%); color: silver; font-size: 0.9rem; font-weight: normal; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:left; width:98%; padding:2px 5px;">
									<?php echo get_pt_seller_name($list[$i]['pt_id']); ?>
								</div>
								<div class="overlay-text" style="position: absolute; bottom: -10px; left: 50%; transform: translate(-50%, -50%); color: silver; font-size: 0.9rem; font-weight: normal; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:right; width:98%; padding:2px 5px;">
									<?php //echo "매너온도 " . get_pt_manner_temperature($list[$i]['pt_id']); ?>
									<?php echo apms_get_star($list[$i]['it_use_avg'], $wset['star']); //평균별점 ?>
								</div>
							<?php } else { ?>
								<div class="overlay-text" style="position: absolute; bottom: -10px; left: 50%; transform: translate(-50%, -50%); color: silver; font-size: 0.9rem; font-weight: normal; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:left; width:98%; padding:2px 5px;">
									<?php echo get_pt_seller_name($list[$i]['pt_id']); ?>
								</div>
								<div class="overlay-text" style="position: absolute; bottom: -10px; left: 50%; transform: translate(-50%, -50%); color: silver; font-size: 0.9rem; font-weight: normal; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); white-space: nowrap; text-align:right; width:98%; padding:2px 5px;">
									<?php //echo "매너온도 " . get_pt_manner_temperature($list[$i]['pt_id']); ?>
									<?php echo apms_get_star($list[$i]['it_use_avg'], $wset['star']); //평균별점 ?>
								</div>
							<?php } ?>
						</div>
					</div>
				</a>
				<?php echo $shadow_out;?>
			</div>
			<div class="item-content">
				<?php if($wset['star']) { ?>
					<div class="item-star">
						<?php echo apms_get_star($list[$i]['it_use_avg'], $wset['star']); //평균별점 ?>
					</div>
				<?php } ?>

				<div class="list-specs">
					<a href="<?php echo $list[$i]['href'];?>">
						<?php
						$headers = ["", "CPU", "GPU", "RAM", "SSD", "HDD", "USB"];
						$rows = [];

							$result_api_data = sql_query("SELECT * FROM {$g5['g5_shop_item_table']} WHERE it_id='{$list[$i]['it_id']}' ORDER BY it_id DESC LIMIT 1");
							while($api_data = sql_fetch_array($result_api_data)){
								$it_id = $api_data['it_id'];
								$it_origin_mgr_from_api = $api_data['it_origin_mgr_from_api'];
								$M_storeid = explode("Ž",$api_data['it_origin_mgr_from_api'])[0]." ".explode("Ž",$api_data['it_origin_mgr_from_api'])[1];
								$M_storename = explode("Ž",$api_data['it_origin_mgr_from_api'])[2];

								// JSON 데이터
								$jsonData_it_spec_remote_sw = $api_data['it_spec_remote_sw'];

								// JSON 데이터를 배열로 디코드
								$dataArray_it_spec_remote_sw = json_decode($jsonData_it_spec_remote_sw, true);

								$remote_ip_country_code = strtolower($dataArray_it_spec_remote_sw[0]['RemoteIP_CountryCode__0']);
								$remote_ip_country_name = $dataArray_it_spec_remote_sw[0]['RemoteIP_CountryName__0'];
								$remote_ip_city_name = $dataArray_it_spec_remote_sw[0]['RemoteIP_City__0'];
								$remote_ip_country_flag = "<img src='" . G5_DATA_URL . "/item/img_nation_flag/svg/{$remote_ip_country_code}.svg' class='nation_flag_img2'>";

								//$it_spec_cpu_arr = explode("Ž", trim(str_ireplace(array("(R)", "(TM)", "Intel", "AMD", "with Radeon Graphics", "with Radeon Vega Graphics", "CPU", "Core ", " Cores", "Eight-Processor"), array("", "", "", "", "", "", "", "", "C", ""), $api_data['it_spec_cpu'])));
								$it_spec_cpu_arr = explode("Ž", trim(str_ireplace(array("(R)", "(TM)", "with Radeon Graphics", "with Radeon Vega Graphics", "CPU", "Core ", "Eight-Processor"), array("", "", "", "", "", "", ""), $api_data['it_spec_cpu'])));
								if (count($it_spec_cpu_arr) == 1) {
									$it_spec_cpu = $it_spec_cpu_arr[0];
								} else if (count($it_spec_cpu_arr) == 2) {
									$it_spec_cpu = "[Dual] " . $it_spec_cpu_arr[0];
								} else if (count($it_spec_cpu_arr) == 3) {
									$it_spec_cpu = "[Triple] " . $it_spec_cpu_arr[0];
								} else if (count($it_spec_cpu_arr) == 4) {
									$it_spec_cpu = "[Quad] " . $it_spec_cpu_arr[0];
								}
								if (stripos($it_spec_cpu, 'intel') !== false) {
									$logo_cpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_intel.png' class='cpu_logo_img2'>";
								} else if (stripos($it_spec_cpu, 'amd') !== false) {
									$logo_cpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_amd.png' class='cpu_logo_img2'>";
								} else {
									$logo_cpu = "";
								}

								// CPU 데이터
								$cpu_data = $api_data['it_spec_cpu'];
								$it_billing_plan = isset($api_data['it_billing_plan']) ? $api_data['it_billing_plan'] : ''; // Billing plan added by AI
								$it_billing_traffic_cost = isset($api_data['it_billing_traffic_cost']) ? $api_data['it_billing_traffic_cost'] : 0;
								$it_billing_time_cost = isset($api_data['it_billing_time_cost']) ? $api_data['it_billing_time_cost'] : 0;

								// 정규식을 사용하여 괄호 속에 "Cores"라는 단어가 포함된 숫자를 추출
								if (preg_match('/\((\d+) Cores\)/', $cpu_data, $matches)) {
									// 추출된 숫자를 $cpu_core 변수에 저장
									$cpu_core = $matches[1];
								} else {
									// "Cores"가 포함된 문자열이 없는 경우
									$cpu_core = null;
								}
								$it_spec_mainboard = $api_data['it_spec_mainboard'];
								$it_spec_ram = $api_data['it_spec_ram'];
								$it_spec_ram_type = $api_data['it_spec_ram_type'];
								//$SSDinfo = $api_data['SSDinfo'];
								$it_spec_ssd =  $api_data['it_spec_ssd'] === "0 GB" ? "<div style='width:100%; min-width:40px; text-align:left;'>Not installed</div>" : $api_data['it_spec_ssd'];
								$it_spec_ssd_type = $api_data['it_spec_ssd_type'];
								//$SSD = $api_data['SSD'];
								//$HDDinfo = $api_data['HDDinfo'];
								$it_spec_hdd = $api_data['it_spec_hdd'] === "0 GB" ? "<div style='width:100%; min-width:40px; text-align:left;'>Not installed</div>" : $api_data['it_spec_hdd'];
								$it_spec_hdd_type = $api_data['it_spec_hdd_type'];
								//$HDD = $api_data['HDD'];
								$it_spec_gpu_arr = explode("Ž", trim(str_ireplace(array("(R)", "(TM)"), array("", ""), $api_data['it_spec_gpu'])));
								if (count($it_spec_gpu_arr) == 1) {
									$it_spec_gpu = $it_spec_gpu_arr[0];
								} else if (count($it_spec_gpu_arr) > 1) {
									if ((strpos($it_spec_gpu_arr[0], "NVIDIA") !== false) || (strpos($it_spec_gpu_arr[0], "AMD") !== false)) {
										$it_spec_gpu = $it_spec_gpu_arr[0];
									} else if ((strpos($it_spec_gpu_arr[1], "NVIDIA") !== false) || (strpos($it_spec_gpu_arr[1], "AMD") !== false)) {
										$it_spec_gpu = $it_spec_gpu_arr[1];
									} else {
										$it_spec_gpu = $it_spec_gpu_arr[0] . "<br>" . $it_spec_gpu_arr[1];
									}
								}
								if (stripos($it_spec_gpu, 'nvidia') !== false) {
									$logo_gpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_nvidia.png' class='gpu_logo_img2'>";
								}
								if (stripos($it_spec_gpu, 'quadro') !== false) {
									$logo_gpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_nvidia_quadro.png' class='gpu_logo_img2'>";
								} else if (stripos($it_spec_gpu, 'geforce') !== false) {
									$logo_gpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_nvidia_geforce.png' class='gpu_logo_img2'>";
								}

								if (stripos($it_spec_gpu, 'radeon') !== false) {
									$logo_gpu = "<img src='" . G5_DATA_URL . "/item/img_logo/logo_amd_radeon.png' class='gpu_logo_img2'>";
								} else {
									$logo_gpu = "";
								}

								//$gpu_ram = $api_data['gpu_ram'];

								//$it_spec_os = trim(str_ireplace(array("Microsoft", "Windows", "(64Bit)"), array("", "Win", ""), $api_data['it_spec_os']));
								$it_spec_os = trim($api_data['it_spec_os']);
								if (stripos($it_spec_os, 'Windows 11') !== false || stripos($it_spec_os, 'Windows11') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/Windows11.png' class='os_img2'>";
								} else if (stripos($it_spec_os, 'Windows 10') !== false || stripos($it_spec_os, 'Windows10') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/Windows10.png' class='os_img2'>";
								} else if (stripos($it_spec_os, 'Windows 8') !== false || stripos($it_spec_os, 'Windows8') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/Windows8.png' class='os_img2'>";
								} else if (stripos($it_spec_os, 'Windows 7') !== false || stripos($it_spec_os, 'Windows7') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/Windows7.png' class='os_img2'>";
								} else if (stripos($it_spec_os, 'Windows Server 2016') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/WindowsServer2016.png' class='os_img2'>";
								} else if (stripos($it_spec_os, 'Windows Server 2016') !== false) {
									$it_spec_os = (stripos($it_spec_os, 'Microsoft') !== false) ? $it_spec_os : "Microsoft " . $it_spec_os;
									$OS_flag = "<img src='" . G5_DATA_URL . "/item/img_os/WindowsServer2016.png' class='os_img2'>";
								} else {
									$OS_flag = "";
								}

								$rantal_fee_type = $api_data['rantal_fee_type'];
								$rental_fee = $api_data['rental_fee'];
								$rental_setting_fee = $api_data['rental_setting_fee'];
								$rental_fee_first_daily = round(($rental_fee + $rental_setting_fee) / 30);
								$rental_fee_ext_daily = round(($rental_fee) / 30);
								$rental_stat = $api_data['rental_stat'];
								$client_number = $api_data['client_number'];
								$cpu_clock = $api_data['cpu_clock'];
								$AppVer = $api_data['AppVer'];

								// Initialize the array
								$it_spec_device_arr = [];

								// Check if $it_spec_keyboard is not empty and add to array
								if (!empty(trim($api_data['it_spec_keyboard']))) {
									$it_spec_device_arr[] = "KEYBOARD";
								}

								// Check if $it_spec_mouse is not empty and add to array
								if (!empty(trim($api_data['it_spec_mouse']))) {
									$it_spec_device_arr[] = "MOUSE";
								}

								// Join array elements with a comma if there are multiple elements
								$it_spec_devices = (count($it_spec_device_arr) > 0) ? implode(', ', $it_spec_device_arr) : "-";

								$is_vpn_item = false;
								if ((stripos(trim($api_data['it_name']), 'VPN') === 0) || (stripos(trim($list[$i]['it_name']), 'VPN') === 0)) {
									$is_vpn_item = true;
								}
							?>
							<table class="item-specs-table<?php echo $is_vpn_item ? ' vpn-item' : ''; ?>">
							<?php
									// Location string - only country name without city

							if($is_vpn_item){
								$location_str = !empty(trim($remote_ip_country_name)) ? $remote_ip_country_flag . " " . $remote_ip_country_name : "";
								$product_name = $list[$i]['it_name'];
								$_grade_badge = vpn_category_badge_html(isset($api_data['it_spec_os']) ? $api_data['it_spec_os'] : '').vpn_grade_badge_html(isset($api_data['it_spec_grade']) ? $api_data['it_spec_grade'] : '');
								echo "<tr><td colspan='4' class='spec-full' style='padding-bottom:2px;'><div class='spec-title-with-location'><span style='font-weight:700;'>{$_grade_badge}{$product_name}</span>";
								if(!empty($location_str)) echo "<span class='spec-location'>{$location_str}</span>";
								echo "</div></td></tr>";
								$_v_labels = array();
								if (function_exists('apms_allowed_pricing_units_from_item')) {
									$_v_allowed = apms_allowed_pricing_units_from_item($api_data);
									if (!empty($_v_allowed['hour']))  $_v_labels[] = '1시간';
									if (!empty($_v_allowed['day']))   $_v_labels[] = '1일';
									if (!empty($_v_allowed['month'])) $_v_labels[] = '1개월';
									if (!empty($_v_allowed['year']))  $_v_labels[] = '1년';
									if (!empty($_v_allowed['usage'])) $_v_labels[] = '종량제';
								}
								$_v_plan_str = !empty($_v_labels) ? implode(' / ', $_v_labels) . ' 이용권' : '-';
								$_v_max_hours = function_exists('apms_buy_qty_to_hours') ? (int)apms_buy_qty_to_hours($api_data['it_buy_max_qty']) : 0;
								$_v_max_text  = ($_v_max_hours > 0 && function_exists('apms_contract_hours_text')) ? '최대 '.apms_contract_hours_text($_v_max_hours) : '최대 365일';
								$_v_setup = isset($api_data['it_install_price']) ? (int)$api_data['it_install_price'] : 0;
								$_v_setup_str = $_v_setup > 0 ? number_format($_v_setup).' P' : '없음';
								echo "<tr><th class='spec-label'>요금제</th><td colspan='3'>{$_v_plan_str}</td></tr>";
								echo "<tr><th class='spec-label'>주문기간</th><td colspan='3'>{$_v_max_text}</td></tr>";
								echo "<tr><th class='spec-label'>개통비</th><td colspan='3'>{$_v_setup_str}</td></tr>";
								echo "<tr><th class='spec-label'>프로토콜</th><td colspan='3'>IKEv2 <span style='color:#888;font-size:10px;'>Win / Mac / Linux / Android / iOS</span></td></tr>";

							} else {
								$location_str = !empty(trim($remote_ip_country_name)) ? $remote_ip_country_flag . " " . $remote_ip_country_name : "";
								$product_name = $list[$i]['it_name'];
								$_rpc_cur_grade = isset($api_data['it_spec_grade']) ? (string)$api_data['it_spec_grade'] : '';
								$_rpc_grade = rpc_ensure_grade(
									$api_data['it_id'],
									$_rpc_cur_grade,
									$api_data['it_spec_cpu'],
									$api_data['it_spec_ram'],
									$api_data['it_spec_ssd'],
									$api_data['it_spec_hdd']
								);
								$_grade_badge = rpc_category_badge_html($list[$i]['ca_id']).rpc_grade_badge_html($_rpc_grade);
								$_rpc_setup_fee = isset($api_data['it_install_price']) ? (int)$api_data['it_install_price'] : 0;
								$_rpc_setup_str = $_rpc_setup_fee > 0 ? number_format($_rpc_setup_fee).' P' : '없음';
								echo "<tr><td colspan='4' class='spec-full' style='padding-bottom:2px;'><div class='spec-title-with-location'><span style='font-weight:700;'>{$_grade_badge}{$product_name}</span>";
								if(!empty($location_str)) echo "<span class='spec-location'>{$location_str}</span>";
								echo "</div></td></tr>";
								echo "<tr><th class='spec-label'>CPU</th><td colspan='3'>{$it_spec_cpu}</td></tr>";
								echo "<tr><th class='spec-label'>GPU</th><td colspan='3'>{$it_spec_gpu}</td></tr>";
								$hdd_empty = (stripos($it_spec_hdd, '0') !== false || stripos($it_spec_hdd, 'Not installed') !== false || empty($it_spec_hdd));
								$usb_empty = ($it_spec_devices == '-' || empty($it_spec_devices));
								$_hdd_part = (!$hdd_empty) ? " <span style='color:#888;font-weight:500;margin-left:8px;margin-right:2px;'>HDD</span> {$it_spec_hdd}" : '';
								$_usb_part = (!$usb_empty) ? " <span style='color:#888;font-weight:500;margin-left:8px;margin-right:2px;'>USB</span> {$it_spec_devices}" : '';
								echo "<tr><th class='spec-label'>RAM</th><td colspan='3'>{$it_spec_ram} <span style='color:#888;font-weight:500;margin-left:6px;margin-right:2px;'>SSD</span> {$it_spec_ssd}{$_hdd_part}{$_usb_part}</td></tr>";
							}
							}
							?>
						</table>
					</a>
				</div>

				<div class="item-price en">
					<?php if($list[$i]['it_tel_inq']) { ?>
						<b>Call</b>
					<?php
					} else if ($is_vpn_item && $it_billing_plan == 'usage') {
					?>
						<div class="product-price-usage" style="display:block; line-height:1.4; margin-top:0px; text-align:left;">
							<b><?php echo number_format($it_billing_traffic_cost); ?> P</b><small> / GB</small>
							<span style="color:#aaa; font-weight:normal;">+</span>
							<b><?php echo number_format($it_billing_time_cost); ?> P</b><small> / 시간</small>
						</div>
						<div class="item-sp darkgray" style="margin-top:5px; text-align:left;">
							<i class="fa fa-clock-o"></i> 유효기간 없음 (No Expiration)
						</div>
					<?php } else { ?>
						<?php echo $cur_price;?>
						<?php if ($list[$i]['ca_id'] == '20') { ?>
						<b><?php echo number_format($list[$i]['last_auction_price']);?> P</b><small>/최종입찰</small>
						<span class="item-sp blue">
							<i class="fa fa-tags"></i>
							<?php echo round((1 - ($list[$i]['last_auction_price'] / $list[$i]['buy_it_now_price'])) * 100) . "% 할인";?>
						</span>
						<?php if(isset($_rpc_setup_fee) && $_rpc_setup_fee > 0): ?>
						<span style="float:right;font-size:10px;color:#888;font-weight:500;margin-top:2px;">설치비/개통비&nbsp;<b style="color:#555;"><?php echo $_rpc_setup_str; ?></b></span>
						<?php endif; ?>
					<?php } else { ?>
						<?php
							$vpn_hourly_price = isset($api_data['it_is_hour_sale_price']) ? (int)$api_data['it_is_hour_sale_price'] : 0;
							if ($vpn_hourly_price <= 0) {
								$vpn_hourly_price = (int)$list[$i]['it_price'];
							}
							if ($vpn_hourly_price < 0) {
								$vpn_hourly_price = 0;
							}
						?>
						<b><?php echo number_format($vpn_hourly_price);?> P</b><small>/1시간</small>
						<?php if ((float)$list[$i]['it_buy_min_qty'] < 1.0) { ?>
							<span class="item-sp blue" title="최소 1시간 이상 주문 가능">
								<i class="fa fa-bolt"></i>1시간 주문가능
							</span>
						<?php } else { ?>
							<span class="item-sp darkgray" title="최소 <?php echo $list[$i]['it_buy_min_qty'];?>일 이상 주문 가능">
								<?php echo $list[$i]['it_buy_min_qty'];?>일이상 주문가능
							</span>
						<?php } ?>
						<?php if($list[$i]['it_point']) { ?>
							<span class="item-sp green">
								<i class="fa fa-gift"></i>
								<?php echo ($list[$i]['it_point_type'] == 2) ? $list[$i]['it_point'].'% 적립' : number_format(get_item_point($list[$i])).'P';?>
							</span>
						<?php } ?>
						<?php if($dc_per) { ?>
							<span class="item-sp orangered">
								<i class="fa fa-bolt"></i>
								<?php echo $dc_per;?>% DC
							</span>
						<?php } ?>
					<?php } ?>
				<?php } ?>
				</div>
				<div class="item-details en">
					<?php if($wset['cmt'] && $list[$i]['pt_comment']) { ?>
						<span class="item-sp red">
							<i class="fa fa-comment"></i>
							<?php echo number_format($list[$i]['pt_comment']);?>
						</span>
					<?php } ?>
					<?php if($wset['buy'] && $list[$i]['it_sum_qty']) { ?>
						<span class="item-sp blue">
							<i class="fa fa-shopping-cart"></i>
							<?php echo number_format($list[$i]['it_sum_qty']);?>
						</span>
					<?php } ?>
					<?php if($wset['hit'] && $list[$i]['it_hit']) { ?>
						<span class="item-sp gray">
							<i class="fa fa-eye"></i>
							<?php echo number_format($list[$i]['it_hit']);?>
						</span>
					<?php } ?>
				</div>
			</div>
			<?php if($wset['sns']) { ?>
				<div class="item-sns">
					<?php
						$sns_url  = G5_SHOP_URL.'/item.php?it_id='.$list[$i]['it_id'];
						$sns_title = get_text($list[$i]['it_name']);
						$sns_img = $widget_url.'/img';
						echo  get_sns_share_link('facebook', $sns_url, $sns_title, $sns_img.'/sns_fb.png').' ';
						echo  get_sns_share_link('twitter', $sns_url, $sns_title, $sns_img.'/sns_twt.png').' ';
						echo  get_sns_share_link('googleplus', $sns_url, $sns_title, $sns_img.'/sns_goo.png').' ';
						echo  get_sns_share_link('kakaostory', $sns_url, $sns_title, $sns_img.'/sns_kakaostory.png').' ';
						echo  get_sns_share_link('kakaotalk', $sns_url, $sns_title, $sns_img.'/sns_kakao.png').' ';
						echo  get_sns_share_link('naverband', $sns_url, $sns_title, $sns_img.'/sns_naverband.png').' ';
					?>
				</div>
			<?php } ?>
		</div>
	</div>
<?php } // end for ?>
<?php if(!$list_cnt) { ?>
	<div class="item-none">등록된 상품이 없습니다.</div>
<?php } ?>

<?php
// 경매상품이면 상품상세페이지 URL이 다르므로 변경시켜 주는 함수 JSLEE {
function convertUrl($url) {
	global $g5;

    // URL을 파싱하여 쿼리 문자열을 추출
    $parsedUrl = parse_url($url);
    parse_str($parsedUrl['query'], $queryParams);

    // it_id 값을 추출
    $it_id = $queryParams['it_id'];

	// write_auction_table 에서 wr_id 확인
	$row = sql_fetch("SELECT wr_id FROM {$g5['write_auction_table']} WHERE pcnum = '$it_id' ");
    // 새로운 URL을 생성
    $newUrl = G5_BBS_URL . "/board.php?bo_table=auction&wr_id=" . $row['wr_id'] . "&s=&pcnum=" . $it_id;

    return $newUrl;
}
// 경매상품이면 상품상세페이지 URL이 다르므로 변경시켜 주는 함수 JSLEE }
?>

<script>
	document.addEventListener("DOMContentLoaded", function() {
		function updateAuctionTime() {
			const elements = document.querySelectorAll('.auction_remain_timer');
			elements.forEach(function(element) {
				const expireTime = parseInt(element.getAttribute('data-expire-time'), 10);
				const currentTime = new Date().getTime();
				const timeRemaining = expireTime - currentTime;

				if (timeRemaining > 0) {
					const seconds = Math.floor((timeRemaining / 1000) % 60);
					const minutes = Math.floor((timeRemaining / (1000 * 60)) % 60);
					const hours = Math.floor((timeRemaining / (1000 * 60 * 60)) % 24);
					const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));

					let displayTime = '';
					if (days > 0) displayTime += days + '일 ';
				 	// 시,분,초를 2자리로 표시하고, 값이 0일 때도 항상 출력되도록 설정
					if (days > 0) {
						displayTime += ('0' + hours).slice(-1) + '시간 ';
					} else {
						if (hours > 0) displayTime += hours + '시간 ';
					}
					displayTime += ('0' + minutes).slice(-2) + '분 ';
					displayTime += ('0' + seconds).slice(-2) + '초 ';

					// element.textContent = displayTime + "남음";
					element.textContent = displayTime;
				} else {
					element.textContent = "종료";
				}
			});
		}

		// 매 1초마다 남은 시간을 업데이트
		setInterval(updateAuctionTime, 1000);

		// 페이지 로드 후 즉시 시간 업데이트
		updateAuctionTime();
	});
</script>