<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/nowshop.asp"-->

<script language=javascript src=../include/mouse.js></script>
      <%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("10")%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
</head>
<BODY bgcolor="#D9EAFC">
<%
action=request("backup")
if action<>"ok" then
%>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;数据库在线维护</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30><font color="#000000">&nbsp;<a href="http://www.nowshop.com.cn/help/index.asp?boardid=2&page=1" target="_blank">设置帮助</a></font></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <form action=safe5.asp method=post name=backup>
    <input type="hidden" name="oldpath" value="<%=db%>">
    <input type="hidden" name="DBname" size="20" value="shopbackup.mdb">
    <%
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath("shopbackup.mdb")) then
set myfile=fso.getfile(server.mappath("shopbackup.mdb"))
response.write "<tr bgcolor=#ffffff><td heigh=50 width=25% >上次备份日期</td><td>"&myfile.datelastmodified&"</td></tr>"
response.write "<tr bgcolor=#ffffff><td heigh=50 width=25% >备份文件大小</td><td>"&myfile.size/1024&" KB</td></tr>"
else
response.write "<tr bgcolor=#ffffff><td colspan=2 heigh=50>从未备份数据库文件</td></tr>"
end if
%>
    <tr>
      <td colspan=2 bgcolor="#FFFFFF"> <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('删除备份的数据库文件（即后台目录里的备份文件shopbackup.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("shopbackup.mdb")
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("shopbackup.mdb")
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("shopbackup.mdb")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(dbname) then
 response.write "<script language='javascript'>"
 response.write "location.href='shopbackup.mdb';"
 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("shopbackup.mdb")
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
%>
<table width="95%" border="0">
  <tr> 
    <td height="60"><font color="#FF0000">我们将为购买正版NowShop商城系统者免费设计全套广告图片；提供免费安装调试；免费送1%网银接口、支付宝接口；免费提供技术支持；免费提供系统升级；免费提供系统模板更换；免费代办网站ICP备案；使您的网店更具吸引力！</font></td>
  </tr>
  <tr> 
    <td><p>购买咨询或技术支持，请在周一至周五8：00-18：00间联系<br>
        Email / MSN：shop@nowshop.com.cn<br>
        电话：0551-3929843&nbsp;&nbsp;13965090551<br>
        QQ：2055008<br>
        网站：<a href="http://www.nowshop.com.cn" target="_blank">http://www.nowshop.com.cn</a><br>
        演示：<a href="http://ys.nowshop.com.cn" target="_blank">http://ys.nowshop.com.cn</a><br>
      </p>
      <p>Powerd By：NowShop商城系统 V3.0</p></td>
  </tr>
</table>
