📄 admin_data.asp
字号:
<!--#include file = admin_chk.asp -->
<%
If Not ChkAdmin("Data") Then
Call ArtErr("","")
End If
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../images/admin/style.css">
<body>
<table cellpadding=2 cellspacing=1 border=0 width=98% class=tableBorder align=center>
<tr align="center">
<th height=25 align=center colspan="2"><strong>数 据 库 管 理</strong>(access)
</tr>
<tr >
<td width=12% height=30 class=forumRow> <strong>管理导航:</strong></td>
<td width=88% height=30 class=forumRow><a href="admin_data.asp?action=BackupData">备份数据库</a> | <a href="admin_data.asp?action=RestoreData">恢复数据库</a> | <a href="admin_data.asp?action=CompressData">压缩数据库</a> | <a href="admin_data.asp?action=resetdata">数据库初始</a>
</td>
</tr>
</table>
<%
dim action
dim admin_flag
Function finddir(filepath)
finddir=""
for i=1 to len(filepath)
if left(right(filepath,i),1)="/" or left(right(filepath,i),1)="\" then
abc=i
exit for
end if
next
if abc <> 1 then
finddir=left(filepath,len(filepath)-abc+1)
end if
end Function
action=trim(request("action"))
dim dbpath,bkfolder,bkdbname,fso,fso1
Dim uploadpath
'备份数据
select case action
case "BackupData" '备份数据
If DataBaseType=0 then
if request("act")="Backup" then
call updata()
else
call BackupData()
Call AdminPageEnd()
end if
Else
Call ArtErr("<li>当前数据库类型为MSSQL,不支持此操作!</li>",1)
End If
case "RestoreData" '恢复数据
If DataBaseType=0 then
dim backpath
if request("act")="Restore" then
'Dbpath=request.form("Dbpath") '豪---取消这一句。
Dbpath=request.form("path_Dbpath")&"/"&request.form("file_Dbpath") '豪---增这一句
'backpath=request.form("backpath") ---豪---2006-9-23 取消这句
backpath=artmdb '豪---增加---2006-9-23 增这句。不用在表单中提取,保证数据库路径不显示出来。
if dbpath="" then
response.write "请输入您要恢复成的数据库全名"
else
Dbpath=server.mappath(Dbpath)
end if
backpath=server.mappath(backpath)
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
fso.copyfile Dbpath,Backpath
response.write "<BR><BR><BR><center>祝贺你,数据库恢复成功!</center>"
else
response.write "<BR><BR><BR><center>备份目录找不到要恢复的数据库文件,<BR>请登录到FTP服务器查看后再填写!</center>"
end if
else
call RestoreData()
Call AdminPageEnd()
end if
Else
Call ArtErr("<li>当前数据库类型为MSSQL,不支持此操作!</li>",1)
End If
case "CompressData"
if DataBaseType=0 then
call CompressData()
Call AdminPageEnd()
else
Call ArtErr("<li>当前数据库类型为MSSQL,不支持此操作!</li>",1)
End If
case "resetdata"
if Request.Cookies(Art2008)("purview")="99999" then
call resetdata()
Call AdminPageEnd()
end if
case "deldata"
call deldata()
Call AdminPageEnd()
end select
'====================备份数据库=========================
sub BackupData()
%>
<br>
<table border="0" cellpadding="5" cellspacing="1" class="tableBorder">
<tr>
<td height=20 bgcolor="#0099CF" align="center" colspan="2">
<font color=#FFFFFF><strong>备份数据</strong>( 需要FSO支持,FSO相关帮助请看微软网站 )</font>
</td>
</tr>
<form method="post" action="admin_data.asp?action=BackupData&act=Backup">
<tr>
<td height="20" class="forumRow" width="32%"> <span class="butext">备份数据库目录(相对路径):</span><br>
<font color="#FF0000">目录名称之前不用加“/”符号。<BR>为了安全,你可以修改为另一个目录名称。</font></td>
<td class="forumRow"><input type="text" size="40" name="bkfolder" value="../Databackup"></td>
</tr>
<tr>
<td height="20" class="forumRow">
<span class="butext">备份数据库名称(填写名称): </span><br>
<font color="#FF0000">不允许修改名称,以防止被下载数据库。<BR>请抄下数据库名称,以备恢复时使用。<BR>建议用FTP功能来恢复数据库。</font></td>
<td class="forumRow"><input type=text size="40" name="bkDBname" readonly value="#Artdb_backup_<%=year(now())&month(now())&day(now())&"_"&hour(now())&Minute(now())&second(now())%>.asp"></td>
</tr>
<tr>
<td height="25" colspan="2" class="forumRaw">
<p align="center">
<input type="submit" value="开始备份数据" ></td>
</tr>
</form>
</table>
<%
end sub
sub updata()
'Dbpath=request.form("Dbpath") '豪----取消这句
Dbpath=finddir(request.servervariables("URL"))&artmdb '豪--增加这句,直接取出数据库名称.不用从表单中提取,以防被人知道数据库的名称.
Dbpath=server.mappath(Dbpath)
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
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 "<center>数据库备份成功!您备份的数据库路径为 服务器空间的:" &bkfolder& "\"& bkdbname --豪--取消这一句.防止别人知道服务器的物理路径.
response.write "<BR><BR><BR><center>首先表扬和祝贺你,数据库备份成功!<br>网站要做到安全,就应该经常备份数据库!</center>"
Else
response.write "<BR><BR><BR><center>找不到你需要备份的数据库文件,请查看你的数据库连接串名称。</center>"
End if
end sub
'====================恢复数据库=========================
sub RestoreData()
%>
<br>
<table border="0" cellpadding="5" cellspacing="1" class="tableBorder">
<td height=20 align="center" bgcolor="#0099CF" colspan="2">
<font color=#FFFFFF><strong>恢复数据库</strong>( 需要FSO支持,FSO相关帮助请看微软网站 )</font>
</td>
</tr>
<form method="post" action="admin_data.asp?action=RestoreData&act=Restore">
<tr>
<td height="20" class="forumRow" width="32%">
<span class="butext">要恢复的数据库源目录:</span> <BR>
原备份的数据库的目录名称后面不用再加“/”。</font> </td>
<td class="forumRow"><input type="text" size="40" name="path_DBpath" value="../Databackup">
<font color="red"></td>
</tr>
<tr>
<td height="20" class="forumRow" >
<span class="butext">要恢复的数据库文件名:
<font color="red"></font></span><font color="red"><BR>
如果不记得原来备份的文件名,请用FTP登录到服务器查看。</font> </td>
<td class="forumRow"> <input type="text" size="40" name="file_DBpath" value="#Artdb_backup_<%=year(now())&month(now())&day(now())&"_"&hour(now())&Minute(now())&second(now())%>.asp"></td>
</tr>
<!-- 取消,防止数据库的目标路径被知道。
<tr>
<td height=20 >
目标数据库路径(相对):<input type="text" size="30" name="backpath" value="<%=artmdb%>">
</td>
</tr>
-->
<tr>
<td align="center" colspan="2" class="forumRaw">
<input type="submit" value="立即恢复数据库" >
</td>
</tr>
</form>
</table>
<%
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)
dim f
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>
<%
'====================压缩数据库 =========================
sub CompressData()
%><!-- 以下颜色不同部分为客户端界面代码 -->
<%
conn.close
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -