📄 admin_database.asp
字号:
<!--#include file="../conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<html>
<head>
<title>数据库管理</title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<link href='Admin_Style.css' rel='stylesheet' type='text/css'>
</head>
<body leftmargin='2' topmargin='0' marginwidth='0' marginheight='0'>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
<tr class='topbg'>
<td height='22' colspan='2' align='center'><strong>数 据 库 管 理</strong></td>
</tr>
<tr class='tdbg'>
<td width='70' height='30' ><strong>管理导航:</strong></td>
<td><a href='Admin_Database.asp?Action=Backup'>备份数据库</a> | <a href='Admin_Database.asp?Action=Restore'>恢复数据库</a> | <a href='Admin_Database.asp?Action=Compact'>压缩数据库</a> | <a href='Admin_Database.asp?Action=SpaceSize'>系统空间占用情况</a>
</td>
</tr>
</table>
<%
select case lcase(request("Action"))
case "backup"
call backup()
case "restore"
call Restore()
case "compact"
call compact()
case "spacesize"
call spaceSize()
case "compactdata"
call CompactData(db,false)
case "backupdata"
call BackupData()
case "restoredata"
call RestoreData()
case else
call WriteErrMsg( "没有相关处理命令。")
end select
Sub ShowSpaceInfo(drvpath)
dim showsize,fso,d,size
set fso=createobject("scripting.filesystemobject")
drvpath=server.mappath(drvpath)
set d=fso.getfolder(drvpath)
size=d.size
showsize=size & " Byte"
if size>1024 then
size=(Size/1024)
showsize=formatnumber(size,2) & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " GB"
end if
response.write "<font face=verdana>" & showsize & "</font>"
End Sub
Function Drawspecialbar()
dim fso,drvpathroot,d,fc,f1,size,totalsize,barsize
set fso=server.createobject("scripting.filesystemobject")
drvpathroot=server.mappath("../pic")
drvpathroot=left(drvpathroot,(instrrev(drvpathroot,"\")-1))
set d=fso.getfolder(drvpathroot)
totalsize=d.size
set fc=d.files
for each f1 in fc
size=size+f1.size
next
barsize=cint((size/totalsize)*500)
Drawspecialbar=barsize
End Function
Function Drawbar(drvpath)
dim fso,drvpathroot,d,size,totalsize,barsize
set fso=server.createobject("scripting.filesystemobject")
drvpathroot=server.mappath("../pic")
drvpathroot=left(drvpathroot,(instrrev(drvpathroot,"\")-1))
set d=fso.getfolder(drvpathroot)
totalsize=d.size
drvpath=server.mappath(drvpath)
set d=fso.getfolder(drvpath)
size=d.size
barsize=cint((size/totalsize)*400)
Drawbar=barsize
End Function
Sub Showspecialspaceinfo(method)
dim fso,d,fc,f1,size,showsize,drvpath
set fso=server.createobject("scripting.filesystemobject")
drvpath=server.mappath("../pic")
drvpath=left(drvpath,(instrrev(drvpath,"\")-1))
set d=fso.getfolder(drvpath)
if method="All" then
size=d.size
elseif method="Program" then
set fc=d.Files
for each f1 in fc
size=size+f1.size
next
end if
showsize=size & " Byte"
if size>1024 then
size=(Size/1024)
showsize=size & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " GB"
end if
response.write "<font face=verdana>" & showsize & "</font>"
end sub
sub RestoreData()
if request("backpath")<>"" then backpath=request("backpath")
dbpath=db
backpath=server.MapPath(backpath)
Set Fso=createobject("scripting.filesystemobject")
If fso.fileexists( backpath) = True Then
fso.CopyFile backpath ,dbpath
call WriteSuccessMsg("恢复数据库成功,您恢复的数据库路径为" & backpath)
else
call WriteErrMsg( "找不到您所需要恢复的备份数据库。")
End if
response.End()
end sub
Function CompactData(dbPath, boolIs97)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
fso.CopyFile dbpath,strDBPath & "temp.mdb"
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
End If
fso.CopyFile strDBPath & "temp1.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
fso.DeleteFile(strDBPath & "temp1.mdb")
Set fso = nothing
Set Engine = nothing
call WriteSuccessMsg( "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLf)
Else
call WriteErrMsg( "数据库压缩失败。")
End If
End Function
sub backupdata()
if request("bkfolder")<>"" then bkfolder=request("bkfolder") else bkfolder="defaultbak" end if
if request("bkdbname")<>"" then bkdbname=request("bkdbname") else bkdbname="default" end if
bkdbname=bkdbname&"#.asp"
dbpath=db
bkfolder=server.MapPath(bkfolder)
Set Fso=createobject("scripting.filesystemobject")
if fso.fileexists(db) then
If fso.folderexists(bkfolder) = True Then
fso.copyfile dbpath,bkfolder& "\"& bkdbname
else
fso.createfolder bkfolder
fso.copyfile dbpath,bkfolder& "\"& bkdbname
end if
call WriteSuccessMsg("备份数据库成功,您备份的数据库路径为" &bkfolder& "\"& bkdbname)
Else
call WriteErrMsg( "找不到您所需要备份的文件。")
End if
response.End()
end sub
%>
<%sub backup()%>
<form method='post' action='Admin_Database.asp?action=BackupData'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' class='border'> <tr class='title'> <td align='center' height='22' valign='middle'><b>备 份 数 据 库</b></td> </tr> <tr class='tdbg'> <td height='150' align='center' valign='middle'><table cellpadding='3' cellspacing='1' border='0' width='100%'> <tr> <td width='200' height='33' align='right'>备份目录:</td> <td><input name=bkfolder type=text id="bkfolder" value=Databackup size=20></td> <td>相对路径目录,如目录不存在,将自动创建</td> </tr> <tr> <td width='200' height='34' align='right'>备份名称:</td> <td height='34'>
<input type=text size=20 name=bkDBname value='<%=FormatDateTime(now(),2)%>'></td>
<td height='34'>不用输入文件名后缀(默认为“.asa”)。如有同名文件,将覆盖</td>
</tr> <tr align='center'>
<td height='40' colspan='3'>
<input name='submit' type=submit value=' 开始备份 '></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%end sub%>
<%sub Restore()%>
<form method='post' action='Admin_Database.asp?action=RestoreData'><table width='100%' class='border' border='0' align='center' cellpadding='0' cellspacing='0'> <tr class='title'> <td align='center' height='22' valign='middle'><b>数据库恢复</b></td> </tr> <tr class='tdbg'> <td align='center' height='150' valign='middle'><table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='200' height='30' align='right'>备份数据库路径(相对):</td> <td height='30'><input name=backpath type=text id='backpath' value='Databackup\521movie.mdb' size=50 maxlength='200'></td> </tr> <tr align='center'> <td height='40' colspan='2'><input name='submit' type=submit value=' 恢复数据 '></td> </tr></table> </td> </tr></table></form>
<%end sub%>
<%sub compact%>
<form method='post' action='Admin_Database.asp?action=CompactData'><table class='border' width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr class='title'> <td align='center' height='22' valign='middle'><b>数据库在线压缩</b></td> </tr> <tr class='tdbg'> <td align='center' height='150' valign='middle'> <br> <br> 压缩前,建议先备份数据库,以免发生意外错误。 <br> <br> <br> <input name='submit' type=submit value=' 压缩数据库 '><br><br> </td> </tr></table></form>
<%end sub%>
<%sub SpaceSize()%>
<br>
<table class='border' width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr class='title'>
<td align='center' height='22' valign='middle'><b>系统空间占用情况</b></td>
</tr> <tr class='tdbg'>
<td width='100%' height='125' valign='top'>
<blockquote>
<p><br>
基本系统占用空间: <img src='../images/bar.gif' width='<%= Drawbar("../inc") %>' height=10> <font face=verdana>
<%call ShowSpaceInfo("../inc")%>
</font><br>
<br>
后台管理占用空间: <img src='../images/bar.gif' width='<%= Drawbar("../admin") %>' height=10> <font face=verdana>
<% call ShowSpaceInfo("../admin") %>
</font> <br>
<br>
系统占用空间总计: <img src='../images/bar.gif' width='269' height=12><font face=verdana>
<%call Showspecialspaceinfo("All") %>
</font></p>
</blockquote> </td> </tr></table>
<% end sub %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -