<?
include_once('./_common.php');

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

if(AMINA != "g4s") include_once(AMINA_PATH.'/lib/head.lib.php');

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

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

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

	<b>■ 아미나스킨 설정값 정리하기</b>

	<? if($act) { ?>

		<?
			$result = sql_query(" select bo_table from {$g4['amina']} group by bo_table order by bo_table "); 
			for ($i=0; $row=sql_fetch_array($result); $i++) {
				$row1 = sql_fetch(" select count(*) as cnt from {$g4['board_table']} where bo_table = '{$row['bo_table']}' ", FALSE);
				if (!$row1['cnt']) sql_query(" delete from {$g4['amina']} where bo_table = '{$row['bo_table']}' ", FALSE);
			}

			$result = sql_query(" select bo_table from {$g4['amina_skin']} group by bo_table order by bo_table "); 
			for ($i=0; $row=sql_fetch_array($result); $i++) {
				$row1 = sql_fetch(" select count(*) as cnt from {$g4['board_table']} where bo_table = '{$row['bo_table']}' ", FALSE);
				if (!$row1['cnt']) sql_query(" delete from {$g4['amina_skin']} where bo_table = '{$row['bo_table']}' ", FALSE);
			}
		
		?>
		<script type="text/javascript"> 
			alert('아미나스킨 설정값 정리가 완료되었습니다.');
			opener.location.reload(); 
			window.close(); 
		</script>
	<? } else { ?>
		<ul style="line-height:1.8;">
			<li>존재하지 않는 게시판의 아미나스킨 설정값을 삭제합니다.</li>
			<li>클릭후 완료 메시지 출력까지 기다려 주세요.</li>
		</ul>
		<script type="text/javascript"> 
			function set_href(href) {
				document.getElementById('loading').style.display = "block";
				document.location.href = encodeURI(href);
			}
		</script>
		<p style="text-align:center;">
			<input type="button" value=" 설정값 정리하기 " onclick="set_href('<?=AMINA_URL?>/reset.set.php?bo_table=<?=$bo_table?>&act=on');" class="btn_blue">
		</p>
	<? } ?>
</div>
<div id="loading" style="display:none;margin-top:30px; text-align:center;">
		<img src="<?=AMINA_URL?>/img/loader.gif" />
		<p>정리 중...</p>
</div>
<? include(G4_PATH.'/tail.sub.php'); ?>