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

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

$token		= get_token();

$rs_tables	= sql_query("SHOW TABLES from $mysql_db");

$g4[title] = "MySQL Backup";
include_once("./admin.head.php");

$colspan = 6;
?>
<style>
.tbl_box	{ border:1px solid #CBCBCB; border-top:2px solid #989898; }
.tbl_box tr th	{ background:#F7F7F7; height:30px; border-right:1px solid #EFEFEF; border-bottom:1px solid #EFEFEF; }
.tbl_box tr th:last-child	{ border-right:0; }
.tbl_box tr td	{ padding:6px; border-right:1px solid #EFEFEF; border-bottom:1px solid #EFEFEF; }
.tbl_box tr td:last-child	{ border-right:0; }
.tbl_box tr:last-child td	{ border-bottom:0; }
div.msg		{ font:normal 11px Dotum; padding:4px; }
</style>
<?=subtitle("DB 백업관리 : $mysql_db")?>
<div class="subtitle_msg">간편하게 DB를 백업 할 수 있으며 파일 형식은 TEXT입니다. 백업은 매달 MySQL DUMP나 phpMyAdmin을 이용해 한 번 더 백업하시는 걸 권장합니다.</div>

<form name=fboardlist method=post action="./zm.mysql_backup_process.php">
<input type="hidden" name="mode" value="bl_update">
<table width=100% cellpadding=0 cellspacing=1 border=0 class="tbl_box">
<colgroup width=10%>
<colgroup width=30%>
<colgroup width=10%>
<colgroup width=10%>
<colgroup width=30%>
<colgroup width=10%>
<tr>
    <th><input type=checkbox name=chkall value="1" onclick="check_all(this.form)"></td>
    <th>테이블</th>
    <th>레코드 수</th>
    <th></th>
    <th>테이블</th>
    <th>레코드 수</th>
</tr>
<? while($rd = mysql_fetch_row($rs_tables)) : 
	$reccnt	= 0;
	$reccnt	= mysql_fetch_array(mysql_query("select count(*) as rcnt from $rd[0]"));
?>
<tr class='list<?=$list?> col1 ht' onMouseOver="this.style.backgroundColor='#F6F8FA'" onMouseOut="this.style.backgroundColor=''">
<? for($sw_col = 0; $sw_col < 2; $sw_col++) : ?>
<?	if($sw_col == 0) : ?>
    <td align="center" height=25><input type=checkbox name=chk[] value="<?=$rd[0]?>"></td>
	<td><?=$rd[0]?></td>
	<td align="right"><?=number_format($reccnt[rcnt])?>&nbsp;&nbsp;</td>
<?	else:
	$rd = @mysql_fetch_row($rs_tables);
	$reccnt	= 0;
	$reccnt	= @mysql_fetch_array(mysql_query("select count(*) as rcnt from $rd[0]"));
?>
	<td align="center" height=25><input type=checkbox name=chk[] value="<?=$rd[0]?>"></td>
	<td><?=$rd[0]?></td>
	<td align="right"><?=number_format($reccnt[rcnt])?>&nbsp;&nbsp;</td>
<?	endif; ?>
<? endfor; ?>
</tr>
<? endwhile; ?>
 
<?
if ($i == 0)
    echo "<tr><td colspan='$colspan' align=center height=100 bgcolor=#ffffff>자료가 없습니다.</td></tr>"; 
?>
</table>
<div>
	<input type="submit" value="선택 테이블 백업하기" class="bttn_common">
</div>
</form>

<script language="javascript">
function btn_chk(f, m) {
	var chk = document.getElementsByName("chk[]");

	f.mode.value = m;
	
	var sw = 0;
	for(i=0; i<chk.length; i++) {
		if(chk[i].checked) sw = 1;
	}
	if(!sw) { alert("선택 된 리스트가 없습니다."); return false; }

	f.action	= "./zm.report_process.php";
	f.submit();
}

function chkAlert(th, d) {
	var	s = "";

	if(d == "w") s = "글쓰기";
	if(d == "m") s = "쪽지발송";
	if(d == "f") s = "영구히";
	if(th.checked) alert(s+" 서비스를 제한 합니다.");
}

</script>

<?
include_once("./admin.tail.php");
?>
