<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    ChkSysAdminLevel "sys_config", "show"
    '=====================================================================
%>
<script src="<%=CmsAdminMapPath%>js/check/public.type.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <div class="navigation">插件管理 &gt; 备份数据库</div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">备份数据库</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 当前数据库路径： </th>
            <td class="td2"><input type="text" name="DataBasePath" class="txtInput w350" autocomplete="off" datatype="*10-50" nullmsg="当前数据库路径必须填写" errormsg="至少10个字符,最多50个字符!" value="<%=DataBasePath%>" readonly="readonly" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 备份数据库目录： </th>
            <td class="td2"><input type="text" name="BackupPath" class="txtInput w350" autocomplete="off" datatype="*10-50" nullmsg="备份数据库目录必须填写" errormsg="至少10个字符,最多50个字符!" value="<%=DataBaseBakPath%>" readonly="readonly" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 备份数据库名称： </th>
            <td class="td2"><input type="text" name="BackupName" class="txtInput w350" autocomplete="off" datatype="bakmdb" nullmsg="备份数据库名称必须填写" errormsg="至少10个字符,最多30个字符,以：bak_开头,.mdb结尾!" value="bak_<%=Easp.DateTime(Now(),"yyyymmddhhiiss") & Easp.Rand(111111, 999999)%>.mdb" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="开始备份" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_config", "edit"
    '=====================================================================
    Dim BackupPath, BackupName
    BackupPath = Trim(Easp.Post("BackupPath:s"))
    BackupName = Trim(Easp.Post("BackupName:s"))
    '=====================================================================
    If Easp.IsN(BackupPath) Then
        CmsAdmin.JscriptMsg "备份数据库目录必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(BackupName) Then
        CmsAdmin.JscriptMsg "备份数据库名称必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Easp.Use "fso"
    Easp.Fso.CreateFolder BackupPath
    Easp.Fso.CopyFile DataBasePath, BackupPath & BackupName
    CmsAdmin.JscriptMsg "备份数据库成功,数据库路径："& BackupPath & BackupName & "！", "Admin.Data.Backup.Asp", "Success", "null"
    '=====================================================================
End Sub
%>
