<?
$sub_menu = "300110";
include_once("./_common.php");

if ($is_admin != "super")
    alert("ÃÖ°í°ü¸®ÀÚ¸¸ Á¢±Ù °¡´ÉÇÕ´Ï´Ù.");

if (!$it_id)
	alert("º¹»çÇÒ »óÇ°ÄÚµå°¡ ¾ø½À´Ï´Ù.");

for ($i=0; $i<10000; $i++)
{
	$new_it_id = time();
	$row = sql_fetch(" select count(*) as cnt from $g4[yc4_item_table] where it_id = '$new_it_id' ");
	if(!$row[cnt])
		break;
}

$sql = " select * from $g4[yc4_item_table] where it_id = '$it_id' limit 1 ";
$cp = sql_fetch($sql);

$sql_common = " ca_id            = '$cp[ca_id]',
                ca_id2           = '$cp[ca_id2]',
                ca_id3           = '$cp[ca_id3]',
                it_name          = '$cp[it_name]',
                it_gallery       = '$cp[it_gallery]',
                it_maker         = '$cp[it_maker]',
                it_origin        = '$cp[it_origin]',
                it_opt1_subject  = '$cp[it_opt1_subject]',
                it_opt2_subject  = '$cp[it_opt2_subject]',
                it_opt3_subject  = '$cp[it_opt3_subject]',
                it_opt4_subject  = '$cp[it_opt4_subject]',
                it_opt5_subject  = '$cp[it_opt5_subject]',
                it_opt6_subject  = '$cp[it_opt6_subject]',
                it_opt1          = '$cp[it_opt1]',
                it_opt2          = '$cp[it_opt2]',
                it_opt3          = '$cp[it_opt3]',
                it_opt4          = '$cp[it_opt4]',
                it_opt5          = '$cp[it_opt5]',
                it_opt6          = '$cp[it_opt6]',
                it_type1         = '$cp[it_type1]',
                it_type2         = '$cp[it_type2]',
                it_type3         = '$cp[it_type3]',
                it_type4         = '$cp[it_type4]',
                it_type5         = '$cp[it_type5]',
                it_basic         = '$cp[it_basic]',
                it_explan        = '$cp[it_explan]',
                it_explan_html   = '$cp[it_explan_html]',
                it_cust_amount   = '$cp[it_cust_amount]',
                it_amount        = '$cp[it_amount]',
                it_amount2       = '$cp[it_amount2]',
                it_amount3       = '$cp[it_amount3]',
                it_point         = '$cp[it_point]',
                it_sell_email    = '$cp[it_sell_email]',
                it_use           = '$cp[it_use]',
                it_stock_qty     = '$cp[it_stock_qty]',
                it_head_html     = '$cp[it_head_html]',
                it_tail_html     = '$cp[it_tail_html]',
                it_time          = '$g4[time_ymdhis]',
                it_ip            = '$_SERVER[REMOTE_ADDR]',
                it_order         = '$cp[it_order]',
                it_tel_inq       = '$cp[it_tel_inq]',
                it_mb_id         = '$cp[it_mb_id]'
				";

$sql = " insert $g4[yc4_item_table]
			set it_id = '$new_it_id',
			$sql_common	";

sql_query($sql);

$img_path = "$g4[path]/data/item/";

for($j=1; $j<6; $j++)
{
	$limg = $it_id."_l".$j;
		if(is_file($img_path.$limg))
			copy($img_path.$limg,$img_path.$new_it_id."_l".$j);

}

$simg = $it_id."_s";
	if(is_file($img_path.$simg))
		copy($img_path.$simg,$img_path.$new_it_id."_s");

$mimg = $it_id."_m";
	if(is_file($img_path.$mimg))
		copy($img_path.$mimg,$img_path.$new_it_id."_m");

$qstr = "$qstr&sca=$sca&page=$page";

goto_url("./itemlist.php?$qstr");
?>




