<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=form}-->
<!--{include file=elements/header.js.html type=valid}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>网站管理&nbsp;&gt;&nbsp;网站备份&nbsp;&gt;&nbsp;数据库还原
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Database.backup" class="link">数据库备份</a>
				<a href="index.php?r=Database.restore" class="nolink">数据库还原</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent">
					<form id="uploadForm" action="index.php?r=database.upload" method="post" enctype="multipart/form-data">
						<table class="tbl_edit" width="100%">
							<tr>
								<td class="td_name">本地上传(只支持扩展名.sql)</td>
								<td class="td_content"><input id="sqlfile" type="file" name="sqlfile"><span id="span_sqlfile"></span></td>
							</tr>
							<tr>
								<td class="noborder"></td>
								<td class="noborder"><input type="hidden" name="act" value ="upload_sql"><button type="submit" class="but4font">上传文件</button></td>
							</tr>
						</table>
					</form>
				</div>
				<div class="tableContent2">
					<form action="index.php?r=database.delete" id="file_list" name="file_list" method="post"  >
						<input type="hidden" name="act" value="remove"/>
						<div class="operation"><button type="submit" class="but2font">删除</button></div>
						<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0">
							<tr class="thead">
								<td width="10%"><input type="checkbox" name="chkall" onClick="checkall(this.form, 'file[]')"></td>
								<td width="15%">文件名</td>
								<td width="15%">版本</td>
								<td width="15%">时间</td>
								<td width="15%">大小</td>
								<td width="15%">卷数</td>
								<td width="15%">操作</td>
							</tr>
							<!--{foreach from=$list key=key item=item}-->
							<tr>
								<td><input type="checkbox" name="file[]" value="<!--{$item.filename}-->" /></td>
								<td key="<!--{$key+1}-->"><!--{if $item.count > 1}--><img src="images/menu_plus.gif" class="openlist"><!--{/if}--><a class="openlist" href="<!--{if $item.count > 1}-->#<!--{else}-->tmp/backup/<!--{$item.filename}--><!--{/if}-->" <!--{if $item.count == 1}-->target="_blank"<!--{/if}-->><!--{$item.name}--></a></td>
								<td><!--{$item.ver}--></td>
								<td><!--{$item.add_time}--></td>
								<td><!--{$item.file_size}--></td>
								<td><!--{$item.count}--></td>
								<td><a href="javascript:if(confirm('你确定要导入此备份文件吗？')){window.location.href='index.php?r=database.import&file_name=<!--{$item.filename}-->';}">导入</a> </td>
							</tr>
							<tbody id="tbody-<!--{$key+1}-->" style="display:none;" >
							<!--{foreach from=$item.list item=item2}-->
							<tr>
								<td>&nbsp;</td>
								<td><a href="tmp/backup/<!--{$item2.filename}-->" target="_blank"><!--{$item2.name}--></a></td>
								<td><!--{$item2.ver}--></td>
								<td><!--{$item2.add_time}--></td>
								<td><!--{$item2.file_size}--></td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>
							<!--{/foreach}-->
							</tbody>
							<!--{/foreach}-->
						</table>
						<div class="operation"><button type="submit" class="but2font">删除</button></div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
$(document).ready(function(){
	$(".openlist").click(function(){
		var id= $(this).parent().attr("key");
		if($("#tbody-"+id).is(":visible") !== false){
			$("#tbody-"+id).css("display","none");
		}else{
			$("#tbody-"+id).css("display","");
		}
	});
	
	$("#uploadForm").ajaxForm({
		success: function(ResponseHtml){
	          var data = eval('(' + ResponseHtml + ')');
		if(data.status==1)
		{
			window.location.reload();
		}else{
			alert(data.error);
		}
	      }
	});
	 
	$("#file_list").submit(function(){
		var ckd = false;
		$("input:checkbox",$(this)).each(function(){
		if($(this).attr("name") == "file[]" && $(this).attr("checked"))
		{
			ckd = true;
		}
	});
	if(!ckd){
		alert("请选择要删除的文件！");
		return false;
	}
	if(confirm("你确定要删除选中数据吗？"))
	{
	 	$(this).ajaxSubmit({
		 	success: function(ResponseHtml){
	            var data = eval('(' + ResponseHtml + ')');
				if(data.status==1)
				{
					window.location.reload();
				}
	        }
		 });
	 }
	 return false;
	});
});
	
function checkall(frm, chk)
{
    for (i = 0; i < frm.elements.length; i++)
    {
        if (frm.elements[i].name == chk)
        {
            frm.elements[i].checked = frm.elements['chkall'].checked;
        }
    }
}
</script>
</html>