📄 db_compact.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="ConnUser.asp"-->
<!--#include file="config.asp"-->
<!--#include file="char.inc"-->
<!--#include file="chkuser.asp" -->
<!--#include file="ChkURL.asp"-->
<!--#include file="ChkManage.asp" -->
<%
IF request.cookies(eChuang)("ManageKEY")<>"super" or request.cookies(eChuang)("ManagePurview")<>"99999" then
Show_Err("对不起,您的后台管理权限不够!")
response.end
else
response.buffer=true
Response.Expires=0
Set rs9 = Server.CreateObject("ADODB.Recordset")
sql9 ="SELECT * From "& db_System_Table &" Order By id DESC"
RS9.open sql9,Conn,1,1
if rs9("system")="1" or request.cookies(eChuang)("purview")="99999" then
'这里一定要先关闭数据库,并且保证在压缩时没有使用数据库内容
rs9.close
set rs9=nothing
conn.close
set conn=nothing
'**************************************************
'函数名:IsObjInstalled
'作 用:检查组件是否已经安装
'参 数:strClassString ----组件名
'返回值:True ----已经安装
' False ----没有安装
'**************************************************
dim ObjInstalled
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
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
ThisNameFile="Db_Compact.asp" '定义本文件的文件名
%>
<html><head>
<title>ACCESS数据库压缩_建站铺修正版_bbs.jzpu.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href=site.css rel=stylesheet>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!--#include file=Admin_Top.asp-->
<table cellpadding="0" cellspacing="0" border="1" width="100%" style="border-collapse: collapse" bordercolor="#FFDFBF" width="100%" id="AutoNumber1">
<tr class="TDtop">
<td height="30" colspan="2" align="center"><strong>数 据 库 管 理</strong></td>
</tr>
<tr >
<td height="25" colspan="2" align="center"><font color="#FF0000">使用本功能需要服务器支持FSO(Scripting.FileSystemObject)!</font></td>
</tr>
<tr>
<td width="20%" height="30" align="center"><strong>管理导航:</strong></td>
<td width="80%" height="30" align="center">
<a href="<%=ThisNameFile%>?Action=BackupData">备份数据库</a>
<a href="<%=ThisNameFile%>?Action=RestoreData">恢复数据库</a>
<a href="<%=ThisNameFile%>?action=CompressData">压缩数据库</a>
<a href="<%=ThisNameFile%>?action=SpaceSize">系统空间占用</a>
</td>
</tr>
</table>
<%
dim action
action=trim(request("action"))
dim dbpath,bkfolder,bkdbname,fso,fso1
select case action
case "CompressData" '压缩数据
dim tmprs
dim allarticle
dim Maxid
dim topic,username,dateandtime,body
call CompressData()
case "BackupData" '备份数据
if request("act")="Backup" then
call updata()
else
call BackupData()
end if
case "RestoreData" '恢复数据
dim backpath
if request("act")="Restore" then
Dbpath=request.form("Dbpath")
backpath=request.form("backpath")
if dbpath="" then
response.write "<div align=center><font color=#FF0000>请输入您要恢复成的数据库全名</font> </div>"
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 "<div align=center><font color=#FF0000>成功恢复数据!</font> </div>"
else
response.write "<div align=center><font color=#FF0000>备份目录下并无您的备份文件!</font> </div>"
end if
else
call RestoreData()
end if
case "SpaceSize" '系统空间占用
call SpaceSize()
end select
%>
<!--#include file=Admin_Bottom.asp-->
<%'====================系统空间占用=======================
sub SpaceSize()
On error resume next
%>
<table cellpadding="0" cellspacing="0" border="1" width="100%" style="border-collapse: collapse" bordercolor="#FFDFBF" width="100%" id="AutoNumber1">
<tr class="TDtop">
<td height="25" colspan="2" align="center" > <strong>系统空间占用情况</strong></td>
</tr>
<%
If ObjInstalled=false Then
Response.Write "<tr align=center><td height=30 colspan=3> <div align=center><b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b> </div></td></tr>"
else
l_path=left(Request.ServerVariables("PATH_INFO"),instrrev(Request.ServerVariables("PATH_INFO"),"/"))
%>
<tr>
<td width="22%" height="25"> 【数据库】<img src="images/mdb.gif" height=22>:</td>
<td width="78%" height="25"> <%=ShowFileSize(l_path & db)%></td>
</tr>
<%
cpath=Server.MapPath(l_path)
set fsoBrowse=CreateObject("Scripting.FileSystemObject")
Set theFolder=fsoBrowse.GetFolder(cpath)
Set theFiles=theFolder.files
Set theSubFolders=theFolder.SubFolders
for each SubF in theSubFolders%>
<tr>
<td> 【<%=SubF.name%>】:</td>
<td> <img src="images/Admin_db_bar.gif" width=<%=drawbar(SubF.name)%> height=10><%showSpaceinfo(SubF.name)%></td>
</tr>
<%next
set fsoBrowse=nothing
set theFolder=nothing
set theSubFolders=nothing
%>
<tr>
<td> 系统空间总计:</td>
<td> <img src="images/Admin_db_bar.gif" width=400 height=10> <%showspecialspaceinfo("All")%></td>
</tr>
<%end if%>
</table>
<%
end sub
%>
<%'====================恢复数据库=========================
sub RestoreData()
If IsSqlDataBase = 1 Then
SQLUserReadme()
Exit Sub
End If
%>
<table cellpadding="0" cellspacing="0" border="1" width="100%" style="border-collapse: collapse" bordercolor="#FFDFBF" width="100%" id="AutoNumber1">
<form method="post" action="<%=ThisNameFile%>?action=RestoreData&act=Restore">
<tr class="TDtop">
<td height=25 colspan="2" align="center" > <B>恢复数据</B> </td>
</tr>
<tr>
<td width="200" height="30" align="right">备份数据库路径(相对):</td>
<td height="30"> <input type=text size=40 name=DBpath value="DataBackup/#eChuang#.mdb"></td>
</tr>
<tr align="center">
<td height="30" colspan="2"><font color="#FF0000">填写备份数据库文件名替换“#eChuang#.mdb”,可自行命名(注意路径不能改变),可以参考下面显示的数据库名称</font></td>
</tr>
<tr>
<td width="200" height="30" align="right">当前数据库路径(相对):</td>
<td> <input type=text size=40 name=backpath readonly value="<%=db%>"></td>
</tr>
<tr align="center">
<td height="30" colspan="2">填写您当前使用的数据库路径,如不想覆盖当前文件,可自行命名(注意路径是否正确)</td>
</tr>
<tr align="center">
<td height=30 colspan="2">
<input type=submit value=" 恢复数据 " <%If ObjInstalled=false Then response.Write "disabled"%> style="cursor: hand;background-color: #cccccc;">
</td>
</tr>
<%
If ObjInstalled=false Then
Response.Write "<tr align=center><td height=30 colspan=2> <div align=center><b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b> </div></td></tr>"
end if
%>
</form>
</table>
<%
end sub
'====================备份数据库=========================
sub BackupData()
If IsSqlDataBase = 1 Then
SQLUserReadme()
Exit Sub
End If
%>
<table cellpadding="0" cellspacing="0" border="1" width="100%" style="border-collapse: collapse" bordercolor="#FFDFBF" width="100%" id="AutoNumber1">
<form method="post" action="<%=ThisNameFile%>?action=BackupData&act=Backup">
<tr class="TDtop">
<td height=25 align="center"> <strong>备份数据库</strong></td>
</tr>
<tr>
<td height=100 >
当前数据库路径(相对路径):<input type=text size=40 readonly name=DBpath value="<%=db%>">
相对路径<BR>
备份数据库目录(相对路径):<input type=text size=40 name=bkfolder value="Databackup"> 如目录不存在,程序将自动创建<BR>
备份数据库名称(填写名称):<input type=text size=40 name=bkDBname value=<%=date%>.mdb> 如备份目录有该文件,将覆盖,如没有,将自动创建
</td>
</tr>
<tr align="center">
<td height="30" >
<input type=submit value=" 开始备份 " <%If ObjInstalled=false Then response.Write "disabled"%> style="cursor: hand;background-color: #cccccc;">
</td>
</tr>
<%
If ObjInstalled=false Then
Response.Write "<tr align=center><td height=30 > <div align=center><b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b> </div></td></tr>"
end if
%>
</form>
</table>
<%
end sub
sub updata()
Dbpath=request.form("Dbpath")
Dbpath=server.mappath(Dbpath)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -