<?
//-- 리뉴얼 스킨 관리
$sub_menu = "400300";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token		= get_token();
include_once("$g4[path]/head.sub.php");


//-- 스킨 정보 싱크 하기. -------------------------------
//-- 원래 스킨에 있는 메뉴가 리뉴얼 메뉴에 없으면 레코드 추가
$rs	= sql_query("select * from zm_builder_config");
while($rd = sql_fetch_array($rs)){
	$rrd	= sql_fetch("select * from zm_builder_renewal_config where db_org_recno='$rd[db_recno]'");
	if(!$rrd[db_recno])	//--없으면 추가
		sql_query("insert into zm_builder_renewal_config set db_org_recno='$rd[db_recno]', db_link_type='$rd[db_link_type]'");
}

//-- 리뉴얼 메뉴에 원래 스킨에 없는 메뉴가 있으면 레코드 삭제
$rs	= sql_query("select * from zm_builder_renewal_config");
while($rd = sql_fetch_array($rs)){
	$rrd	= sql_fetch("select * from zm_builder_config where db_recno='$rd[db_org_recno]'");
	if(!$rrd[db_recno])	//-- 원본에 없는 메뉴면 리뉴얼 메뉴의 레코드 삭제
		sql_query("delete from zm_builder_renewal_config where db_recno='$rd[db_recno]'");
}
//-----------------------------------------------
?>
<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<style type="text/css">
.info	{ border:1px solid #8397BF; background-color:#F8F8FB; color:#4C596E; text-align:left; padding:5px; margin:10px 0 5px 0; font-family:나눔고딕; }

.trhead td	{ background:#F95E05; color:#ffffff; font-size:13px; font-family:나눔고딕; }

.group_list	{ position:relative; margin:0 auto; padding:3px; width:33%; line-height:200%; text-align:left; float:left; }
.line		{ border-top:1px solid #EFEFEF; clear:both; }
.btnsetup	{ vertical-align:middle; cursor:pointer; _cursor /**/:hand; }
.info		{ padding:10px; color:#515151; line-height:160%; }
.fbold		{ color:#FF0000; }
.left-pad1	{ padding-left:20px; cursor:pointer; }
.left-pad2	{ padding-left:50px; cursor:pointer; }
.left-pad3	{ padding-left:80px; cursor:pointer; }
.level_1	{ color:#F95E05; font-size:15px; font-family:'맑은 고딕'; }
.level_2	{ color:#373737; font-size:12px; }
.level_3	{ color:#A2A2A2; font-size:12px; }
.group_bg1	{ background-color:#FFFFFF; }
.group_bg2	{ background-color:#F7F7F7; }
.msg		{ color:#B2B2B2; }

.grpreg_box	{ margin-bottom:10px; }
.grpreg_box select	{ height:25px; cursor:pointer; }
.grpreg_box input	{ height:19px; padding:3px; }
.grpreg_box input[type=button]	{ height:26px; }

.mdate		{ color:#AAAAAA; text-align:center; }

td a:hover	{ text-decoration:underline; }
td a		{ color:#2A2A2A; font-size:12px; }
td.line1	{ height:2px; background:#FCAE82; }
td.line2	{ height:1px; background:#FCAE82; }

tr.ht		{ height:30px; }
</style>
<link rel="stylesheet" href="<?=$g4[path]?>/adm/admin.style.css" type="text/css">
<?
$g4[title] = "지음빌더 리뉴얼 스킨";
include_once ("./admin.head.php");
include_once ("./zm.lib.php");


$index_exist= read_group(0, "");			//-- 인덱스 정보
$group_1	= read_group(1, "");			//-- 메뉴 그룹
$group_2	= read_group(2, "$g_1_r");		//-- 중분류 정보
$group_3	= read_group(3, "");			//-- 소분류 정보
$member_skin = read_group(99, "");			//-- 회원가입

//-- 리뉴얼용 스킨 정보 -----------------------
$ren_skin	= read_skin_renewal();

//-- 회원가입 스킨 정보가 없으면 생성 -----------
$rd_mem	= sql_fetch("select * from $zmb[table_builder_config] where db_level='99'");
if(!$rd_mem[db_recno]) {
	$member_skins	= get_skin_dir("zm.member");			//-- 회원가입 스킨
	$topmenu_skins	= get_skin_dir("zm.topmenu");			//-- Topmenu 스킨
	$bottom_skins	= get_skin_dir("zm.bottom");			//-- Bottom 스킨

	$sql	= "insert into $zmb[table_builder_config] set db_level='99', db_menu_reg='1', db_group_name='회원가입', db_group_explain='회원가입', db_layout_skin='$member_skins[0]', db_datetime='".date("Y-m-d H:i:s")."'";
	sql_query($sql);
}


$colspan	= 7;
?>
<?=subtitle("리뉴얼 스킨 관리")?>
<div class="subtitle_msg">홈페이지를 운영중에 리뉴얼 작업을 할 경우 작업자의 아이디 또는 아이피를 등록합니다. 자세한 설명은 <a href="http://ziumb.tistory.com/66" target="_blank">ziumb.tistory.com/66</a>를 참고해 주시기 바랍니다.</div>

<table width=100% cellpadding=0 cellspacing=0 border=0 align="center">
<colgroup width=30%>
<colgroup width=28%>
<colgroup width=10%>
<colgroup width=8%>
<colgroup width=6%>
<colgroup width=8%>
<colgroup width=10%>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='trhead ht center '>
    <td>INDEX > 메뉴그룹 > 중분류 > 소분류</td>
	<td>스킨 / PAGE / URL</td>
	<td>게시판</td>
	<td>출력순위</td>
	<td>더보기</td>
	<td>Sub domain</td>
	<td>수정일</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='ht'>
	<td>
		<img src="<?=$member_skin[0][btnimage]?>" class="btnsetup" onClick="zm_gourl('./zm.builder_renewal_write.php?recno=<?=$member_skin[0][recno]?>');"> 회원가입
	</td>
	<td><a href="<?=$ren_skin[$member_skin[0][recno]][go_href]?>" target="_blank"><span class="msg">skin/zm.member/</span><?=$ren_skin[$member_skin[0][recno]][layout_skin]?></a></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class="mdate"><?=$index_exist[0][datetime]?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='ht'>
	<td>
<?	if($index_exist[0][recno]) : ?>
		<img src="<?=$index_exist[0][btnimage]?>" class="btnsetup" onClick="zm_gourl('./zm.builder_renewal_write.php?recno=<?=$index_exist[0][recno]?>');"> INDEX
<?	else : ?>
		<center>INDEX를 등록하세요.</center>
<?	endif; ?>
	</td>
	<td><a href="<?=$index_exist[0][go_href]?>" target="_blank"><span class="msg"><?=$ren_skin[$index_exist[0][recno]][skin_dir]?></span><?=$ren_skin[$index_exist[0][recno]][index_skin]?></a></td>
	<td><?=$index_exist[0][board]?></td>
	<td align="left">0</td>
	<td align="center"></td>
	<td></td>
	<td class="mdate"><?=$index_exist[0][datetime]?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<!-- 메뉴그룹 -->
<? for($i = 0; $i < count($group_1); $i++) : ?>
<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
	<td class="left-pad1" onClick="zm_gourl('./zm.builder_renewal_write.php?recno=<?=$group_1[$i][recno]?>');">
	<span>└&nbsp;<img src="<?=$group_1[$i][btnimage]?>" class="btnsetup"></span>
	<span class="level_1"><?=$group_1[$i][groupname]?></span>
	</td>
	<td><a href="<?=$group_1[$i][go_href]?>" target="_blank"><span class="msg"><?=$ren_skin[$group_1[$i][recno]][skin_dir]?></span><?=$ren_skin[$group_1[$i][recno]][skin_url]?></a></td>
	<td><?=$group_1[$i][board]?></td>
	<td align="left"><?=$group_1[$i][rank]?></td>
	<td align="center"><?=($group_1[$i][more])?"√":""?></td>
	<td><?=$group_1[$i][subdomain]?> <? if($group_1[$i][subdomain] && $group_1[$i][href]) : ?><a href="<?=$group_1[$i][go_href]?>" target="_blank" title="<?=$group_1[$i][go_href]?>"><img src="./img/icon_preview.gif" align="absmiddle"></a><? endif; ?></td>
	<td class="mdate"><?=$group_1[$i][datetime]?></td>
</tr>
	<!-- 중분류 -->
<?	$group_2_	= read_group("2", $group_1[$i][recno]);
	for($j = 0; $j < count($group_2_); $j++) : ?>
	<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
		<td class="left-pad2" onClick="zm_gourl('./zm.builder_renewal_write.php?recno=<?=$group_2_[$j][recno]?>');">
		<span>└&nbsp;<img src="<?=$group_2_[$j][btnimage]?>" class="btnsetup"></span>
		<span class="level_2"><?=$group_2_[$j][groupname]?></span>
		</td>
		<td><a href="<?=$group_2_[$j][go_href]?>" target="_blank"><span class="msg"><?=$ren_skin[$group_2_[$j][recno]][skin_dir]?></span><?=$ren_skin[$group_2_[$j][recno]][skin_url]?></a></td>
		<td><?=$group_2_[$j][board]?></td>
		<td align="center"><?=$group_2_[$j][rank]?></td>
		<td align="center"><?=($group_2_[$j][more])?"√":""?></td>
		<td><span class="msg"><?=$group_2_[$j][subdomain]?></span></td>
		<td class="mdate"><?=$group_2_[$j][datetime]?></td>
	</tr>
		<!-- 소분류 -->
<?		$group_3_	= read_group("3", $group_2_[$j][recno]);
		for($k = 0; $k < count($group_3_); $k++) : ?>
		<tr class='ht <?=($i%2)?"group_bg1":"group_bg2"?>' onMouseOver="this.style.backgroundColor='#FFFFE0'" onMouseOut="this.style.backgroundColor=''">
			<td class="left-pad3" onClick="zm_gourl('./zm.builder_renewal_write.php?recno=<?=$group_3_[$k][recno]?>');">
			<span>└&nbsp;<img src="<?=$group_3_[$k][btnimage]?>" class="btnsetup"></span>
			<span class="level_3"><?=$group_3_[$k][groupname]?></span>
			</td>
			<td><a href="<?=$group_3_[$k][go_href]?>" target="_blank"><span class="msg"><?=$ren_skin[$group_3_[$k][recno]][skin_dir]?></span><?=$ren_skin[$group_3_[$k][recno]][skin_url]?></a></td>
			<td><?=$group_3_[$k][board]?></td>
			<td align="right"><?=$group_3_[$k][rank]?></td>
			<td align="center"><?=($group_3_[$k][more])?"√":""?></td>
			<td><span class="msg"><?=$group_3_[$k][subdomain]?></span></td>
			<td class="mdate"><?=$group_3_[$k][datetime]?></td>
		</tr>
<?		endfor; //-- 소분류 ?>
<?	endfor; //-- 중분류 ?>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? endfor; //-- 메뉴그룹 ?>
</table>
</form>


<?
//-- 레벨 9 이상인 회원
$memlist	= array();
$i			= 0;
$memrs	= sql_query("select mb_id from $g4[member_table] where mb_level >= 9");
while($memrd = sql_fetch_array($memrs)){
	$memlist[$i]	= $memrd[mb_id];
	$i++;
}
?>
<div class="info">
	<div><form name="frenewal" method="post"><input type="hidden" name="mode" value="renewal">회원 레벨 9 이상인 <select name="renewal_id">
	<option value="">-아이디 선택-</option>
<?	for($i = 0; $i < count($memlist); $i++) :
	if($memlist[$i] == $zm_config[renewal_id]) $sel = "selected"; else $sel = ""; ?>
	<option value="<?=$memlist[$i]?>" <?=$sel?>><?=$memlist[$i]?></option>
<?	endfor; ?>
	</select>로 로그인 했을 때 또는 아이피 <input name="renewal_ip" value="<?=($zm_config[renewal_ip])?$zm_config[renewal_ip]:""?>">에서 접속 했을 때는 리뉴얼 스킨이 적용 됩니다. <input type="button" value="내용 변경/적용" onclick="send_renewal(document.frenewal)"></form></div>
	<div>접속하고 계신 PC의 현재 아이피는 <span style="cursor:pointer; color:#3099FF;" onclick="frenewal.renewal_ip.value='<?=$_SERVER[REMOTE_ADDR]?>'"><?=$_SERVER[REMOTE_ADDR]?></span>입니다.</div>
	<div>설정한 아이디로 로그인 했을 때 이 페이지에서 적용한 스킨이 적용 됩니다. 자세한 설명은 <a href="http://ziumb.tistory.com/66" target="_blank"><b>ziumb.tistory.com/66</b></a>를 참고해 주시기 바랍니다.</div>
</div>

<form name="form_group" method="post" enctype="multipart/form-data">
<input type="hidden" name="mode" value="save">
<input type="hidden" name="level" value="">
<input type="hidden" name="uprecno" value="">
<input type="hidden" name="group_name" value="">
<input type="hidden" name="group_skin" value="">
</form>


<script language="javascript">
//-- reg_group(등록할 메뉴 레벨, 상위 레벨 레코드 번호, 분류명, 스킨명)
function reg_group(level, uprecno, gname) {
	var f	= document.form_group;

	f.level.value	= level;
	f.uprecno.value	= uprecno;
	f.group_name.value	= gname;

	if(!gname) { alert("분류명을 입력 해 주세요."); return false; }
	if((level != '0') && !uprecno) { alert("상위 분류(메뉴)를 선택해 주세요."); return false; }
	
	f.action		= "./zm.builder_process.php";
	f.submit();
}

function send_renewal(f){
	f.action	= "./zm.builder_renewal_process.php";
	f.submit();
}
</script>
<?
include_once ("./admin.tail.php");
?>
</body>
</html>