<%Server.ScriptTimeOut=400%>
<!--#include file="inc.asp"-->
<!--#include file="check.asp"-->
<script language=javascript src=images/mouse.js></script>
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="images/Admin_Style.css" type="text/css">
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<%
action=request("backup")
if action<>"ok" then
%>
<table width="98%" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" 
bordercolor="#333333" cellspacing="0" cellpadding="2">
<form action=safe5.asp method=post name=backup>
<tr class=backs><td colspan=2 class=td height=18>数据库在线维护</td></tr>
<input type="hidden" name="oldpath" value="<%=db%>">
<input type="hidden" name="DBname" size="20" value="m#backup.asa">
<%
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath("m#backup.asa")) then
set myfile=fso.getfile(server.mappath("m#backup.asa"))
response.write "<tr><td heigh=50 width=25% >上次备份日期</td><td>"&myfile.datelastmodified&"</td></tr>"
response.write "<tr><td heigh=50 width=25% >备份文件大小</td><td>"&myfile.size/1024&" KB</td></tr>"
else
response.write "<tr><td colspan=2 heigh=50>从未备份数据库文件</td></tr>"
end if
%>
<tr><td colspan=2>
<input title='备份正在使用的数据库文件' type="submit" name="Submit" value="备份" onclick="{if(confirm('备份正在使用的数据库文件，有道是常“备”无患，出了问题后可用于恢复！\n\n备份文件将保存在后台目录里，只要后台目录不公开，放在这里的文件就非常安全。\n\n单击确定继续，单击取消返回。')){this.document.backup.submit();return true;}return false;}"> 
<input title='对备份的数据库文件进行压缩和修复' type='button' value='压缩' onclick="{if(confirm('对数据库备份文件进行压缩，减少占用空间，还可修复数据库错误。\n\n正在使用的数据库不能压缩，请按“备份”—“压缩”—“恢复”的流程操作。\n\n单击确定继续，单击取消返回。 ')){location.href='safe5.asp?action=yasuo';}}"> 
<input title='用备份文件覆盖正式数据库文件' type='button' value='恢复' onclick="{if(confirm('用数据库备份文件覆盖正式的数据库文件，单击确定继续，单击取消返回。')){location.href='safe5.asp?action=huifu';}}"> 
<input title='删除数据库备份文件' type='button' value='删除' onclick="{if(confirm('删除备份的数据库文件（即后台目录里的备份文件backup.mdb）。\n\n单击确定继续，单击取消返回。')){location.href='safe5.asp?action=del';}}"> 
<input title='将备份的数据库下载到本地保存' type='button' value='下载' onclick="{if(confirm('将数据库备份文件下载到自己的电脑中保存一份，以备不测。\n\n不怕一万，只怕万一 ^_^ 需要时可上传并恢复数据库。\n\n单击确定继续，单击取消返回。 ')){location.href='safe5.asp?action=down';}}"> 
<INPUT title='将本地数据库文件上传到网站' TYPE="button" value="上传" onClick="window.open('upload.asp?fuptype=db&fupname=shopbackup&frmname=db','blank_','scrollbars=yes,resizable=no,width=650,height=450')">
<input type="hidden" name="backup" value="ok">
</td></tr>
</form>
</table>
<br><font color=red>※提示：</font><br><br>
此操作需FSO功能支持。<br>
执行此操作前，请先关闭其它网页窗口，断开FTP连接。<br>
提交后，请耐心等待<font color=red>（请不要重复点击上面的按钮），</font>完成时间视网络状况而定。<br>
请在网络空闲时进行此操作，<b>执行此操作可能导致服务器变慢或不稳定</b>。
<% 
else
oldpath=request("oldpath")
oldpath=server.mappath(oldpath)
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(oldpath) then
fso.copyfile oldpath,server.mappath("./")&"/"&request.form("dbname")
 response.write "<script language='javascript'>"
 response.write "alert('操作成功，数据库备份完成！');"
 response.write "location.href='safe5.asp';"
 response.write "</script>"
 response.end
else
 response.write "<script language='javascript'>"
 response.write "alert('出错了，找不到需要备份的源文件！');"
 response.write "location.href='javascript:history.go(-1)';"
 response.write "</script>"
 response.end
end if
end if
if request("action")="yasuo" then
dbname = server.mappath("m#backup.asa")
tempname = server.mappath("./")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(dbname) then
Set Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbname, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tempname & "/temp.mdb"
 fso.CopyFile tempname & "/temp.mdb",dbname
 fso.DeleteFile(tempname & "/temp.mdb")
Set fso = nothing
Set Engine = nothing
 response.write "<script language='javascript'>"
 response.write "alert('操作成功，数据库备份文件压缩完成！');"
 response.write "location.href='safe5.asp';"
 response.write "</script>"
 response.end
else
 response.write "<script language='javascript'>"
 response.write "alert('出错了，找不到需要压缩的文件，可能是还没有备份，或者备份文件已经被删除！');"
 response.write "location.href='javascript:history.go(-1)';"
 response.write "</script>"
 response.end
end if
end if
if request("action")="del" then
dbname = server.mappath("m#backup.asa")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(dbname) then
fso.DeleteFile(dbname)
Set fso = nothing
 response.write "<script language='javascript'>"
 response.write "alert('操作成功，数据库备份文件已被删除！');"
 response.write "location.href='safe5.asp';"
 response.write "</script>"
 response.end
else
 response.write "<script language='javascript'>"
 response.write "alert('出错了，找不到需要删除的文件，可能是还没有备份，或者备份文件已经被删除！');"
 response.write "location.href='javascript:history.go(-1)';"
 response.write "</script>"
 response.end
end if
end if
if request("action")="down" then
dbname = server.mappath("m#backup.asa")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(dbname) then
 response.write "<script language='javascript'>"
 response.write "location.href='m#backup.asa';"
 response.write "</script>"
 response.end
else
 response.write "<script language='javascript'>"
 response.write "alert('出错了，找不到要下载的文件，可能是还没有备份，或者备份文件已经被删除！');"
 response.write "location.href='javascript:history.go(-1)';"
 response.write "</script>"
 response.end
end if
Set fso = nothing
end if
if request("action")="huifu" then
dbname = server.mappath("m#backup.asa")
oldname = server.mappath(db)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(dbname) then
fso.CopyFile dbname,oldname
Set fso = nothing
 response.write "<script language='javascript'>"
 response.write "alert('操作成功，已用备份的数据库文件覆盖网站数据库文件！');"
 response.write "location.href='safe5.asp';"
 response.write "</script>"
 response.end
else
 response.write "<script language='javascript'>"
 response.write "alert('出错了，找不到用来恢复的文件，可能是还没有备份，或者备份文件已经被删除！');"
 response.write "location.href='javascript:history.go(-1)';"
 response.write "</script>"
 response.end
end if
end if
%>