<?php
$sub_menu = "777200";
include_once('./_common.php');

include_once(AMINA_PATH.'/lib/admin.lib.php');

include_once(AMINA_PATH.'/lib/head.lib.php');

include(G5_PATH.'/head.sub.php');

?>

<link rel="stylesheet" href="<?php echo AMINA_URL; ?>/css/admin.css" />

<div style="padding:15px;">

	<b>■ 아미나스킨 설정값 복사</b>

	<?php if($act == "copy") { 

		if(!$type || !$id || !$bo_list) alert_close("값이 제대로 넘어오지 않았습니다.");

		if($type == "func") {

			$row = sql_fetch(" select * from {$g5['amina']} where id = '{$id}' "); 

			if(!$row['id']) alert_close("복사할 설정값이 없습니다.");

			$sql_common = " bo_type				= '{$row['bo_type']}'
							, auto_rss			= '{$row['auto_rss']}'
							, view_code			= '{$row['view_code']}'
							, poll_level		= '{$row['poll_level']}'
							, poll_point		= '{$row['poll_point']}'
							, tag				= '{$row['tag']}'
							, tag_mb			= '".addslashes($row['tag_mb'])."'
							, nameless_write	= '{$row['nameless_write']}'
							, nameless_cmt		= '{$row['nameless_cmt']}'
							, nameless_head		= '{$row['nameless_head']}'
							, nameless_tail		= '{$row['nameless_tail']}'
			                , view_photo		= '{$row['view_photo']}'
							, cmt_photo			= '{$row['cmt_photo']}'
			                , emo_skin			= '{$row['emo_skin']}'
			                , emo_cnt			= '{$row['emo_cnt']}'
							, limit_post		= '{$row['limit_post']}'
			                , limit_post_cnt	= '{$row['limit_post_cnt']}'
			                , limit_writer		= '{$row['limit_writer']}'
							, limit_cmt			= '{$row['limit_cmt']}'
			                , limit_date		= '{$row['limit_date']}'
							, shingo			= '{$row['shingo']}'
			                , upimg_size		= '{$row['upimg_size']}'
			                , upimg_quality		= '{$row['upimg_quality']}'
							, good_point		= '{$row['good_point']}'
			                , good_repoint		= '{$row['good_repoint']}'
			                , star				= '{$row['star']}'
			                , star_color		= '{$row['star_color']}'
			                , star_point		= '{$row['star_point']}'
			                , star_repoint		= '{$row['star_repoint']}'
							, cmt_cool			= '{$row['cmt_cool']}'
							, cmt_cool_txt		= '".addslashes($row['cmt_cool_txt'])."'
							, cmt_bad_txt		= '".addslashes($row['cmt_bad_txt'])."'
							, cmt_good			= '{$row['cmt_good']}'
							, cmt_best			= '{$row['cmt_best']}'
							, cmt_good_txt		= '".addslashes($row['cmt_good_txt'])."'
							, cmt_good_point	= '{$row['cmt_good_point']}'
							, cmt_good_repoint	= '{$row['cmt_good_repoint']}'
							, cmt_choice		= '{$row['cmt_choice']}'
							, cmt_choice_return	= '{$row['cmt_choice_return']}'
							, cmt_choice_txt	= '".addslashes($row['cmt_choice_txt'])."'
							, po_view			= '{$row['po_view']}'
							, po_view_cnt		= '{$row['po_view_cnt']}'
							, po_view_day		= '{$row['po_view_day']}'
							, po_view_time		= '{$row['po_view_time']}'
							, po_view_term		= '{$row['po_view_term']}'
							, po_view_fee		= '{$row['po_view_fee']}'
							, po_view_free		= '{$row['po_view_free']}'
							, po_view_level		= '{$row['po_view_level']}'
							, po_down			= '{$row['po_down']}'
							, po_down_cnt		= '{$row['po_down_cnt']}'
							, po_down_day		= '{$row['po_down_day']}'
							, po_down_time		= '{$row['po_down_time']}'
							, po_down_term		= '{$row['po_down_term']}'
							, po_down_fee		= '{$row['po_down_fee']}'
							, po_down_free		= '{$row['po_down_free']}'
							, po_down_level		= '{$row['po_down_level']}'
							, editor			= '{$row['editor']}'
							, resize			= '{$row['resize']}'
							, uploader			= '{$row['uploader']}'
							, move				= '{$row['move']}'
							, move_bo			= '{$row['move_bo']}'
							, move_ca			= '{$row['move_ca']}'
							, move_term			= '{$row['move_term']}'
							, move_hit			= '{$row['move_hit']}'
							, move_cmt			= '{$row['move_cmt']}'
							, move_good			= '{$row['move_good']}'
							, move_cnt			= '{$row['move_cnt']}'
							, move_star			= '{$row['move_star']}'
							, move_score		= '{$row['move_score']}'
							, lucky_rate		= '{$row['lucky_rate']}'
							, lucky_point		= '{$row['lucky_point']}'
							, wm				= '{$row['wm']}'
							, wm_file			= '".addslashes($row['wm_file'])."'
							, wm_loc			= '{$row['wm_loc']}'
							, wm_x				= '{$row['wm_x']}'
							, wm_y				= '{$row['wm_y']}'
							, limit_down_cmt	= '{$row['limit_down_cmt']}'
							, limit_down_star	= '{$row['limit_down_star']}'
							, limit_down_poll	= '{$row['limit_down_poll']}'
							, limit_down_good	= '{$row['limit_down_good']}'
							, limit_good_cmt	= '{$row['limit_good_cmt']}'
							, limit_good_star	= '{$row['limit_good_star']}'
							, limit_good_poll	= '{$row['limit_good_poll']}'
							, limit_good_down	= '{$row['limit_good_down']}'
							, limit_star_cmt	= '{$row['limit_star_cmt']}'
							, limit_star_poll	= '{$row['limit_star_poll']}'
							, limit_star_down	= '{$row['limit_star_down']}'
							, limit_star_good	= '{$row['limit_star_good']}'
							, limit_poll_cmt	= '{$row['limit_poll_cmt']}'
							, limit_poll_star	= '{$row['limit_poll_star']}'
							, limit_poll_down	= '{$row['limit_poll_down']}'
							, limit_poll_good	= '{$row['limit_poll_good']}'
							, auto_sns			= '{$row['auto_sns']}'
							, mileage			= '{$row['mileage']}'
							, syndi				= '{$row['syndi']}'
							, view_fancybox		= '{$row['view_fancybox']}'
						";

			$bo = explode(",", $bo_list);
			
			for($i=0;$i<count($bo);$i++) {

				$bo_id = trim($bo[$i]);

				if(!$bo_id) continue;

				//기존값 삭제
				sql_query(" delete from {$g5['amina']} where bo_table = '{$bo_id}' ", false);

				//신규값 추가
				sql_query(" insert into {$g5['amina']} set bo_table = '{$bo_id}', $sql_common ");

			}

		} else if($type == "skin") {

			$row = sql_fetch(" select * from {$g5['amina_skin']} where id = '{$id}' "); 

			if(!$row['id']) alert_close("복사할 설정값이 없습니다.");

			$c_type = $row['sca'];
			$s_type = $row['skin_type'];

			$sql_common = " sca					= '{$row['sca']}'
							, skin_type			= '{$row['skin_type']}'
							, cate_skin			= '{$row['cate_skin']}'
							, cate_css			= '{$row['cate_css']}'
							, head_skin			= '{$row['head_skin']}'
							, head_css			= '{$row['head_css']}'
							, list_skin			= '{$row['list_skin']}'
							, list_css			= '{$row['list_css']}'
							, list_set			= '".addslashes($row['list_set'])."'
							, list_rows			= '{$row['list_rows']}'
							, view_skin			= '{$row['view_skin']}'
							, view_css			= '{$row['view_css']}'
							, view_set			= '".addslashes($row['view_set'])."'
							, view_good			= '{$row['view_good']}'
							, view_sns			= '{$row['view_sns']}'
							, star_skin			= '{$row['star_skin']}'
							, poll_skin			= '{$row['poll_skin']}'
							, preview_skin		= '{$row['preview_skin']}'
							, related_skin		= '{$row['related_skin']}'
							, cmt_skin			= '{$row['cmt_skin']}'
							, cmt_css			= '{$row['cmt_css']}'
							, cmt_rows			= '{$row['cmt_rows']}'
							, cmt_sns			= '{$row['cmt_sns']}'
							, sign_skin			= '{$row['sign_skin']}'
							, sign_css			= '{$row['sign_css']}'
							, sign_set			= '".addslashes($row['sign_set'])."'
							, tag_skin			= '{$row['tag_skin']}'
							, tag_css			= '{$row['tag_css']}'
							, tag_set			= '".addslashes($row['tag_set'])."'
							, linked_tab		= '{$row['linked_tab']}'
							, linked_skin		= '{$row['linked_skin']}'
							, linked_css		= '{$row['linked_css']}'
							, addon_skin		= '{$row['addon_skin']}'
							, addon_css			= '{$row['addon_css']}'
							, addon_set			= '".addslashes($row['addon_set'])."'
							, info_skin			= '{$row['info_skin']}'
							, info_css			= '{$row['info_css']}'
							, info_set			= '".addslashes($row['info_set'])."'
							, write_skin		= '{$row['write_skin']}'
							, write_css			= '{$row['write_css']}'
							, write_set			= '".addslashes($row['write_set'])."'
							, page_skin			= '{$row['page_skin']}'
							, page_css			= '{$row['page_css']}'
							, page_rows			= '{$row['page_rows']}'
							, btn_skin			= '{$row['btn_skin']}'
							, btn_css			= '{$row['btn_css']}'
							, deco_list			= '{$row['deco_list']}'
							, deco_view			= '{$row['deco_view']}'
							, deco_write		= '{$row['deco_write']}'
							, attach_skin		= '{$row['attach_skin']}'
							, attach_css		= '{$row['attach_css']}'
							, attach_set		= '".addslashes($row['attach_set'])."'
							";

			$bo = explode(",", $bo_list);
			
			for($i=0;$i<count($bo);$i++) {

				$bo_id = trim($bo[$i]);

				if(!$bo_id) continue;

				//기존값 삭제
				sql_query(" delete from {$g5['amina_skin']} where bo_table = '{$bo_id}' and sca = '{$c_type}' and skin_type = '{$s_type}' ");

				//신규값 추가
				sql_query(" insert into {$g5['amina_skin']} set bo_table = '{$bo_id}', $sql_common ");
			}
		}
	?>
		<script type="text/javascript"> 
			alert('설정값 복사가 완료되었습니다.');
			opener.location.reload(); 
			window.close(); 
		</script>
	<?php } else { ?>
		<form id="fboardform" name="fboardform" method="post" onsubmit="return fboardform_submit(this);" enctype="multipart/form-data">
		<input type="hidden" name="id" value="<?php echo $id; ?>">
		<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
		<input type="hidden" name="type" value="<?php echo $type; ?>">
		<input type="hidden" name="act" value="copy">
		<ul style="line-height:1.8;">
			<li>게시판 아이디를 콤마(,)로 구분해 입력해 주세요.</li>
		</ul>
		<textarea rows=5 style="width:100%; height:100px;overflow:auto;" name="bo_list"></textarea></li>
		<p style="text-align:center;">
			<input type="submit" value=" 복사하기 " class="btn_blue">
		</p>
		</form>
	<? } ?>
</div>
<script type="text/javascript"> 
	function fboardform_submit(f) {
		document.getElementById('loading').style.display = "block";
		return true;
	}
</script>
<div id="loading" style="display:none;margin-top:30px; text-align:center;">
		<img src="<?=AMINA_URL?>/img/loader.gif" />
		<p>정리 중...</p>
</div>
<? include(G5_PATH.'/tail.sub.php'); ?>