<!--#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="DataBaseFile" 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> 是否Access 97：</th>
            <td class="td2"><span>
              <input id="IsAccess97_1" type="radio" name="IsAccess97" value="1" datatype="n0-1" />
              <label for="IsAccess97_1">是</label>
              <input id="IsAccess97_0" type="radio" name="IsAccess97" value="0" checked="checked" />
              <label for="IsAccess97_0">否</label>
              </span><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 IsAccess97
    '=====================================================================
    If CompactDB(DataBasePath, IsAccess97) Then
        CmsAdmin.JscriptMsg "压缩数据库成功！", "Admin.Data.Compress.Asp", "Success", "null"
    Else
        CmsAdmin.JscriptMsg "压缩失败,数据库没有找到！", "back", "Error", "null"
    End If
    '=====================================================================
End Sub

Function CompactDB(ByVal db, ByVal IsAc97)
    Dim DataPathTemp, strTemp, Engine, DataDbPath, DataStr, DataStrTemp
    strTemp = False
    DataPathTemp = Server.MapPath(db)
    Easp.Use "fso"
    If Easp.Fso.IsFile(DataPathTemp) Then
        Easp.C(Easp.db.Conn)
        DataDbPath = Left(DataPathTemp, instrrev(DataPathTemp, "\"))
        DataStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataPathTemp
        DataStrTemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataDbPath & "temp.mdb"
        Set Engine = CreateObject("JRO.JetEngine")
        If IsAc97 = 1 Then
            Engine.CompactDatabase DataStr & ";Jet OLEDB:Engine Type=4", DataStrTemp
        Else
            Engine.CompactDatabase DataStr, DataStrTemp
        End If
        Easp.Fso.CopyFile DataDbPath & "temp.mdb", DataPathTemp
        Easp.Fso.DelFile DataDbPath & "temp.mdb"
        Set Engine = Nothing
        strTemp = True
    Else
        strTemp = False
    End If
    CompactDB = strTemp
End Function
%>
