{:tpl head}
<script language="javascript">
function selecttables(obj,val){
  switch(val){
    case "all":
          for(var i=0;i<obj.length;i++){
              obj[i].checked=true;
          }
          document.all.checkall.checked=true;
		  document.all.backname.value="all_bak";
          break;
    case "other":
          for(var i=0;i<obj.length;i++){
              if(obj[i].value.indexOf("{:$DB_PREFIX}"))obj[i].checked=true;
              else obj[i].checked=false;
          }
          document.all.checkall.checked=false;
		  document.all.backname.value="other_bak";
          break;
    default:
          for(var i=0;i<obj.length;i++){
              if(obj[i].value.indexOf("{:$DB_PREFIX}"))obj[i].checked=false;
              else obj[i].checked=true;
          }
          document.all.checkall.checked=false;
		  document.all.backname.value="{:$DB_PREFIX}bak";
          break;
 }
}
function backtype(obj){
   var flag=false;
   if(obj.checked)flag=true;
   obj.form.backjxcms.checked=false;
   obj.form.backother.checked=false;
   obj.form.backall.checked=false;
   obj.checked=flag;
   selecttables(obj.form.tables,obj.value);
}
</script>

<table cellpadding="0" cellspacing="1" class="table_list">
 <caption>数据库管理</caption>
  <tr>
   <td>
    <strong>管理选项：</strong>
    <a href="?c=data">数据库备份</a> |
    <a href="?c=data&a=import">数据库恢复</a>
   </td>
  </tr>
</table>
{:if $a == 'defaults'}
<table cellpadding="0" cellspacing="1" class="table_list">
 <caption>数据库备份</caption>
  <form method="post" name="myform" action="">
  <input type="hidden" name="selids" value="" />
  <tr align="center">
   <th width="20%"><input name="checkall" type="checkbox" onclick="checkorno(this,this.form.tables)" checked="checked" /></th>
   <th width="40%">数据库表</th>
   <th width="10%">记录条数</th>
   <th width="15%">大小 [共{:$totalsize}M]</th>
   <th width="15%">多余</th>
  </tr>
  {:loop $table $v}
  <tr>
   <td align="center"><input type="checkbox" name="tables" value="{:$v['name']}" checked></td>
   <td>{:$v['name']}</td>
   <td>{:$v['row']}</td>
   <td>{:$v['size']}K</td>
   <td>{:$v['free']}</td>
  </tr>
  {:/loop}
  <tr>
    <td colspan="5" align="center"><strong>分卷备份设置</strong></td>
  </tr>
  <tr>
   <td align="center">快速选择</td>
   <td colspan="4"><input type="checkbox" name="backjxcms" value="{:$DB_PREFIX}" onClick="backtype(this)">本系统数据({:$DB_PREFIX}) <input type="checkbox" name="backother" value="other" onClick="backtype(this)">其他数据(other) <input type="checkbox" name="backall" value="all" onClick="backtype(this)">全部数据(all)</td>
  </tr>
  <tr>
   <td align="center">分卷长度</td>
   <td colspan="4"><input type="text" name="filesize" value="2048" size="10"> K <span class="fblue">设置成小于1024，将会自动更正为1024</span></td>
  </tr>
  <tr>
   <td align="center">文件名称</td>
   <td colspan="4"><input type="text" name="backname" value="{:$DB_PREFIX}bak" size="20"> 以名称+日期+4位随机数+分卷号保存</td>
  </tr>
  <tr>
   <td colspan="5" align="center">
    <button name="select1" onclick="selAll(this.form.tables)" type="button">全选</button>
    <button name="select2" onclick="noSelAll(this.form.tables)" type="button">反选</button>
    <button type="button" name="sbbf" onclick="subform(this.form,this.form.tables,'?c=data&a=export','')">备份数据</button>
    <button type="button" name="repair" onclick="subform(this.form,this.form.tables,'?c=data&a=repair','')">修复数据表</button>
    <button type="button" name="optimize" onclick="subform(this.form,this.form.tables,'?c=data&a=optimize','')">优化数据表</button>
   </td>
  </tr>
  </form>
</table>
{:elseif $a == 'import'}
<table cellpadding="0" cellspacing="1" class="table_list">
 <caption>已备份的SQL文件</caption>
 <form method="post" name="myform">
 <tr align="center">
  <th width="30%">文件名</th>
  <th width="15%">文件大小</th>
  <th width="20%">备份时间</th>
  <th width="15%">卷号</th>
  <th width="20%">操作</th>
 </tr>
 {:loop $data $tmp}
 <tr align="center">
  <td>{:$tmp['filename']}</td>
  <td>{:$tmp['filesize']}M</td>
  <td>{:$tmp['maketime']}</td>
  <td>{:$tmp['number']}</td>
  <td>
   <a href="?c=data&a=import&pre={:$tmp['pre']}&submit=1">导入</a> |
   <a href="?c=data&a=del&pre={:$tmp['pre']}">删除</a> |
   <a href="?c=data&a=download&filename={:$tmp['file']}">下载</a></td>
  </tr>
  {:/loop}
  </form>
</table>
{:/if}
{:tpl foot}