📄 admin_database.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="Admin_Chkpass.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
dim dbpath
dim ObjInstalled
dbpath=server.mappath(db)
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
%>
<html>
<head>
<title>数据库备份</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="Admin_STYLE.CSS">
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<table width="98%" 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 height="30"><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>
<%
if Action="Backup" or Action="BackupData" then
call CloseConn()
call ShowBackup()
elseif Action="Compact" or Action="CompactData" then
call CloseConn()
call ShowCompact()
elseif Action="Restore" or Action="RestoreData" then
call CloseConn()
call ShowRestore()
elseif Action="SpaceSize" then
call SpaceSize()
call CloseConn()
else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
call CloseConn()
end if
if FoundErr=True then
call WriteErrMsg()
end if
sub ShowBackup()
%>
<form method="post" action="admin_database.asp?action=BackupData">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr class="title">
<td align="center" height="22" valign="middle"><span class="style1">备 份 数 据 库</span></td>
</tr>
<tr class="tdbg">
<td height="150" align="center" valign="middle">
<%
if request("action")="BackupData" then
call backupdata()
else
%>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<td width="200" height="33" align="right">备份目录:</td>
<td><input type=text size=20 name=bkfolder value=Databackup></td>
<td>相对路径目录,如目录不存在,将自动创建</td>
</tr>
<tr>
<td width="200" height="34" align="right">备份名称:</td>
<td height="34"><input type=text size=20 name=bkDBname value="<%=date()%>"></td>
<td height="34">不用输入文件名后缀(默认为“.asa”)。如有同名文件,将覆盖</td>
</tr>
<tr align="center">
<td height="40" colspan="3"><input name="submit" type=submit value=" 开始备份 " <%If ObjInstalled=false Then response.Write "disabled"%>></td>
</tr>
</table>
<%
If ObjInstalled=false Then
Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
end if
end if
%>
</td>
</tr>
</table>
</form>
<%
call copyright()
end sub
sub ShowCompact()
%>
<form method="post" action="admin_database.asp?action=CompactData">
<table class="border" width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="title">
<td align="center" height="22" valign="middle"><span class="style1">数据库在线压缩</span></td>
</tr>
<tr class="tdbg">
<td align="center" height="150" valign="middle">
<%
if request("action")="CompactData" then
call CompactData()
else
%>
<br>
<br>
<br>
压缩前,建议先备份数据库,以免发生意外错误。 <br>
<br>
<br>
<input name="submit" type=submit value=" 压缩数据库 " <%If ObjInstalled=false Then response.Write "disabled"%>>
<br>
<br>
<%
If ObjInstalled=false Then
Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
end if
end if
%>
</td>
</tr>
</table>
</form>
<%
call copyright()
end sub
sub ShowRestore()
%>
<form method="post" action="admin_database.asp?action=RestoreData">
<table width="98%" class="border" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="title">
<td align="center" height="22" valign="middle"><span class="style1">数据库恢复</span></td>
</tr>
<tr class="tdbg">
<td align="center" height="150" valign="middle">
<%
if request("action")="RestoreData" then
call RestoreData()
else
%>
<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\oblog.mdb" size=50 maxlength="200"></td>
</tr>
<tr align="center">
<td height="40" colspan="2"><input name="submit" type=submit value=" 恢复数据 " <%If ObjInstalled=false Then response.Write "disabled"%>></td>
</tr>
</table>
<%
If ObjInstalled=false Then
Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
end if
end if
%>
</td>
</tr>
</table>
</form>
<%
call copyright()
end sub
sub SpaceSize()
on error resume next
dim rs,upfile_path,upfile_path1
set rs=conn.execute("select upfile_path from bloginfo")
upfile_path=rs(0)
upfile_path1=rs(0)
set rs=nothing
'call closeconn()
%>
<br>
<table class="border" width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="title">
<td align="center" height="22" valign="middle"><span class="style1">系统空间占用情况</span></td>
</tr>
<tr class="tdbg">
<td width="100%" height="150" valign="middle">
<blockquote><br>
系统数据占用空间: <img src="images/bar.gif" width=<%=drawbar("data")%> height=10>
<%showSpaceinfo("data")%>
<br>
<br>
备份数据占用空间: <img src="images/bar.gif" width=<%=drawbar("databackup")%> height=10>
<%showSpaceinfo("databackup")%>
<br>
<br>
程序文件占用空间: <img src="images/bar.gif" width=<%=drawspecialbar%> height=10>
<%showSpecialSpaceinfo("Program")%>
<br>
<br>
配色模板占用空间: <img src="images/bar.gif" width=<%=drawbar("skin")%> height=10>
<%showSpaceinfo("skin")%>
<br>
<br>
系统图片占用空间: <img src="images/bar.gif" width=<%=drawbar("images")%> height=10>
<%showSpaceinfo("images")%>
<br>
<br>
上传文件占用空间: <img src="images/bar.gif" width=<%=drawbar(upfile_path)%> height=10>
<%showSpaceinfo(upfile_path1)%>
<br>
<br>
系统占用空间总计:<img src="images/bar.gif" width=400 height=10>
<%showspecialspaceinfo("All")%>
</blockquote>
</td>
</tr>
</table>
<br>
<%
call copyright()
end sub
%>
</body>
</html>
<%
sub BackupData()
dim bkfolder,bkdbname,fso
bkfolder=trim(request("bkfolder"))
bkdbname=trim(request("bkdbname"))
if bkfolder="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定备份目录!</li>"
end if
if bkdbname="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定备份文件名</li>"
end if
if FoundErr=True then exit sub
bkfolder=server.MapPath(bkfolder)
Set Fso=server.createobject("scripting.filesystemobject")
if fso.FileExists(dbpath) then
If fso.FolderExists(bkfolder)=false Then
fso.CreateFolder(bkfolder)
end if
fso.copyfile dbpath,bkfolder & "\" & bkdbname & ".asa"
response.write "<center>备份数据库成功,备份的数据库为 " & bkfolder & "\" & bkdbname & ".asa</center>"
Else
response.write "<center>找不到源数据库文件,请检查inc/conn.asp中的配置。</center>"
End if
end sub
sub CompactData()
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath," Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
Set fso = nothing
Set Engine = nothing
response.write "数据库压缩成功!"
Else
response.write "数据库没有找到!"
End If
end sub
sub RestoreData()
dim backpath,fso
backpath=request.form("backpath")
if backpath="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定原备份的数据库文件名!<li>"
exit sub
end if
backpath=server.mappath(backpath)
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(backpath) then
fso.copyfile Backpath,Dbpath
response.write "成功恢复数据!"
else
response.write "找不到指定的备份文件!"
end if
end sub
Sub ShowSpaceInfo(drvpath)
dim fso,d,size,showsize
set fso=server.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=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 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
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
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)*400)
Drawspecialbar=barsize
End Function
'**************************************************
'函数名:IsObjInstalled
'作 用:检查组件是否已经安装
'参 数:strClassString ----组件名
'返回值:True ----已经安装
' False ----没有安装
'**************************************************
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -