<!--#include file="../Inc/Consts.inc" -->
<!--#include file="../Inc/common.Asp" -->
<!--#include file="../Inc/sharefunc.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="Images/Admin_style.css">
<script language="javascript" src="Admin.js"></script>
<%
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
If InStr(SsMasterPurview, "|38,") = 0 Then
    response.Write "<center>您没有管理该模块的权限！</center>"
    response.End
End If
%>

<script language="javascript">
function seleChan(str){
    if(str=="varchar"){
        document.getElementById("charlen").style.display="";
    }
    else{
        document.getElementById("charlen").style.display="none";
    }
}
</script>
</head>
<body>
<%
dim bkfolder
dim bkdbname
dim fso
dim folderpath,fso1,f
call main()
conn.close
set conn=nothing
sub main()
%>
<%
if request("action")="Backup" then
call backupdata()
else
%>
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="form1" method="post" action="?action=Backup">
    <tr>
      <th height="22" colspan="2" sytle="line-height:150%">【备份数据库】</th>
    </tr>
    <tr>
      <td colspan="2" align="left" class="forumRow"><font color="#ff0000">注意：备份数据需要FSO组件支持，FSO组件的相关帮助！路径都是程序空间根目录的相对路径！可能在有些空间备份后,在本机上不能用ACCESS打开,此功能小心使用。</font></td>
    </tr>
    <tr>
      <td width="10%" nowrap="nowrap" align="right" class="forumRow">当前数据库路径：</td>
      <td class="forumRowHighlight"><input type=text size="34" name="DBpath" value="<%response.Write(".."&SysRootDir&SiteDataPath)%>">
        请正确添写您当前使用的数据库路径！</td>
    </tr>
    <tr>
      <td class="forumRow" align="right">备份数据库目录：</td>
      <td class="forumRowHighlight"><input type="text" size="34" name="bkfolder" value="<%response.Write(".."&SysRootDir&"DataBak/")%>">如果目录不存在，程序将自动创建！</td>
    </tr>
    <tr>
      <td class="forumRow" align="right">备份数据库名称：</td>
      <td class="forumRowHighlight">备份名称默认为当前时间字符串，备份后请到相应目录下下载数据备份! </td>
    </tr>
    <tr>
      <td colspan="2" align="left" class="forumRow">在上面填写数据库路径及数据库完整名称，程序的默认数据库文件为时间字符串.mdb<br>
      您可以用这个功能来备份您的数据库，以保证数据的安全！</td>
    </tr>
    <tr>
      <td class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="开始备份">
        <input type="button" value="返回上一页" onClick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
end if
%>
<%
end sub
sub backupdata()
Dim Dbpath,bkfolder,bkdbname
Dbpath=request.form("Dbpath")
Dbpath=server.mappath(Dbpath)
bkfolder=request.form("bkfolder")
bkdbname=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&".mdb"
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
If CheckDir(bkfolder) = True Then
fso.copyfile dbpath,bkfolder& "\"& bkdbname
else
MakeNewsDir bkfolder
fso.copyfile dbpath,bkfolder& "\"& bkdbname
end if
response.write "数据库备份完成名称为："&bkdbname&"，请进行其他操作！<br>建议使用 FTP 工具将数据库备份，以保证数据安全"
else
response.write "找不到您所需要备份的文件！"
end if
end sub
Function CheckDir(FolderPath)
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
CheckDir = True
Else
CheckDir = False
End if
Set fso1 = nothing
End Function
Function MakeNewsDir(foldername)
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>
</body>
</html>