📄 dboperate.asp
字号:
<!--#include file="conn_fj16.asp" -->
<!--#include file="admin_qx.asp" -->
<% isgjgl %>
<html>
<head>
<STYLE type=text/css>
BODY {
SCROLLBAR-FACE-COLOR: #c6ebde;
MARGIN: 0px;
FONT: 9pt 宋体;
SCROLLBAR-HIGHLIGHT-COLOR: #ffffff;
SCROLLBAR-SHADOW-COLOR: #39867b;
SCROLLBAR-3DLIGHT-COLOR: #39867b;
SCROLLBAR-ARROW-COLOR: #330000;
SCROLLBAR-TRACK-COLOR: #e2f3f1;
SCROLLBAR-DARKSHADOW-COLOR: #ffffff;
TEXT-DECORATION: none;
background-image: url(images/bg/bg6.jpg);
background-color: #E7E2FA;
}
TABLE {
BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px
}
TD {
FONT: 13px 宋体
}
IMG {
BORDER-RIGHT: 0px; BORDER-TOP: 0px; VERTICAL-ALIGN: bottom; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px
}
A {
FONT: 12px 宋体; COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #cc0000; TEXT-DECORATION: underline
}
.sec_menu {
BORDER-RIGHT: white 1px solid; BACKGROUND: #c6ebde; OVERFLOW: hidden; BORDER-LEFT: white 1px solid; BORDER-BOTTOM: white 1px solid
}
.menu_title {
}
.menu_title SPAN {
FONT-WEIGHT: bold; LEFT: 8px; COLOR: #39867b; POSITION: relative; TOP: 2px
}
.menu_title2 {
}
.menu_title2 SPAN {
FONT-WEIGHT: bold; LEFT: 8px; COLOR: #cc0000; POSITION: relative; TOP: 2px
}
INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
select {border-width: 1; border-color: #000000; background-color: #ffffff; font-family: 宋体; font-size: 9pt; font-style: bold;}
OPTION {
FONT-FAMILY: "宋体"; FONT-SIZE: 12px; TABLE-LAYOUT: fixed; WORD-BREAK: break-all
}
.style1 {
color: #000000;
font-weight: bold;
}
</STYLE>
<title>数据管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body topmargin="0" style="BACKGROUND-POSITION: center 50%; BACKGROUND-ATTACHMENT: fixed; BACKGROUND-IMAGE: url('images/3.jpg')">
<table width="750" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td height="5"></td>
</tr>
</table>
<table width="750" border="0" cellpadding="5" cellspacing="0" align="center" class="bk">
<tr>
<td height="20" align="center"> <p> </p>
<p><a href="dboperate.asp?action=CompressData"><u>压缩数据</u></a> <a href="dboperate.asp?action=BackupData"><u>备份数据</u></a> <a href="dboperate.asp?action=RestoreData"><u>恢复数据</u></a> <a href="dboperate.asp?action=SpaceSize"><u>空间占用</u></a> </p></td>
</tr>
</table><br>
<%
dim action
dim admin_flag
action=trim(request("action"))
dim dbpath,bkfolder,bkdbname,fso,fso1
select case action
case "CompressData" '压缩数据
if request("act")="yashu" then
call yasu()
else
call CompressData()
end if
case "BackupData" '备份数据
if request("act")="Backup" then
call updata()
else
call BackupData()
end if
case "RestoreData" '恢复数据
if request("act")="Restore" then
Dbpath=request.form("Dbpath")
backpath=request.form("backpath")
if dbpath="" then
'response.write "请输入您要恢复成的数据库全名"
%>
<script language=vbscript>
alert ("请输入您要恢复成的数据库全名")
window.location="dboperate.asp?action=RestoreData"
</script>
<%
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 "成功恢复数据!"
%>
<script language=vbscript>
alert ("成功恢复数据!")
window.location="dboperate.asp?action=RestoreData"
</script>
<%
else
'response.write "备份目录下并无您的备份文件!"
%>
<script language=vbscript>
alert ("备份目录下并无您的备份文件!")
window.location="dboperate.asp?action=RestoreData"
</script>
<%
end if
else
call RestoreData()
end if
case "SpaceSize" '系统空间占用
call SpaceSize()
case else
Errmsg=ErrMsg + "<BR><li>选取相应的操作。"
end select
'====================系统空间占用=======================
sub SpaceSize()
on error resume next
%>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="750" >
<tr>
<td align="center" >
<table width="100%" cellpadding="5" cellspacing="0" class="bk">
<tr >
<td align="center" class="x">系统空间占用情况</td>
</tr>
<tr>
<td>
<blockquote> <br>
常规数据占用空间: <%othersize("db")%><br>
<img src="images/bar1.gif" width=<%=drawbar("db")%> height=10>
<br>
<br>
备份数据占用空间: <%othersize("databackup")%><br>
<img src="images/bar2.gif" width=<%=drawbar("databackup")%> height=10>
<br>
<br>
<br>
相片占用空间: <%othersize("upload/photo")%><br>
<img src="images/bar3.gif" width=<%=drawbar("upload/photo")%> height=10>
<br>
<br>
系统占用空间总计: <%allsize()%><br>
<img src="images/bar4.gif" width=<%=drawbar("/")%> height=10>
<br>
<br>
</blockquote></td>
</tr>
</table>
</td>
</tr>
</table>
<%end sub%>
<%
'====================恢复数据库=========================
sub RestoreData()
%>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="750" >
<tr><form method="post" action="dboperate.asp?action=RestoreData&act=Restore">
<td align="center" >
<table width="100%" cellpadding="5" cellspacing="0" class="bk">
<tr>
<td align="center" class="x">恢复数据库</td>
</tr>
<tr>
<td> 备份数据库路径(相对):
<input type=text size=40 name=DBpath class="an2" value="DataBackup\jgbeifen.mdb"></td>
</tr>
<tr>
<td> 目标数据库路径(相对):
<input type=text size=40 name=backpath class="an2" value="<%=db%>"></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td align="center" class="s"><input type=submit class="an1" value="恢复数据"></td>
</tr>
</table>
</td>
</from>
</table>
<%end sub%>
<%'====================备份数据库=========================
sub BackupData()
%>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="750" >
<tr><form method="post" action="dboperate.asp?action=BackupData&act=Backup">
<td align="center" >
<table width="100%" cellpadding="5" cellspacing="0" class="bk">
<tr >
<td align="center" class="x">备份系统数据</td>
</tr>
<tr>
<td>
当前数据库路径(相对路径):
<input type=text size=25 name=DBpath class="an2" value="<%=DBpath%>"></td>
</tr>
<tr>
<td>
备份数据库目录(相对路径):
<input type=text size=25 name=bkfolder class="an2" value=databackup>
如目录不存在,程序将自动创建</td>
</tr>
<tr>
<td>
备份数据库名称(填写名称):
<input type=text size=25 name=bkDBname class="an2" value=jgbeifen.mdb>
如备份目录有该文件,将覆盖,如没有,将自动创建</td>
</tr>
<tr>
<td align="center" class="s"><input type=submit class="an1" value="确定"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<%end sub%>
<%sub updata()
Dbpath=request.form("Dbpath")
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 "备份数据库成功,您备份的数据库路径为" &bkfolder& "\"& bkdbname
%>
<script language=vbscript>
alert ("备份数据库成功!")
window.location="dboperate.asp?action=BackupData"
</script>
<%
Else
'response.write "找不到您所需要备份的文件。"
%>
<script language=vbscript>
alert ("找不到您所需要备份的文件. 请重试!")
window.location="dboperate.asp?action=BackupData"
</script>
<%
End if
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()
%>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="750" >
<tr>
<td align="center" >
<table width="100%" cellpadding="5" cellspacing="0" class="bk">
<form action="dboperate.asp?action=CompressData&act=yashu" method="post">
<tr >
<td align="center" class="x">压缩系统数据</td>
</tr>
<tr>
<td>注意:输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作)</td>
</tr>
<tr>
<td align="center">压缩数据库:
<input type="text" name="dbpath" size="20" class="an2" value="<%=db%>">
</td>
</tr>
<tr>
<td align="center" class="s"><input type="submit" class="an1" value="开始压缩"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<% end sub%>
<%
'=====================系统空间参数=========================
sub othersize(names)
set fso=server.CreateObject("scripting.filesystemobject")
path=server.mappath("images")
ml=left(path,(instrrev(path,"\")-1))&"\"&names
set d=fso.getfolder(ml)
mlsize=d.size
size=mlsize
dx=size & " Byte"
if size>1024 then
size=(Size/1024)
dx=formatnumber(size,2) & " KB"
end if
if size>1024 then
size=(size/1024)
dx=formatnumber(size,2) & " MB"
end if
if size>1024 then
size=(size/1024)
dx=formatnumber(size,2) & " GB"
end if
response.write dx
end sub
sub allsize()
set fso=server.CreateObject("scripting.filesystemobject")
path=server.mappath("index.asp")
ml=left(path,(instrrev(path,"\")-1))
set d=fso.getfolder(ml)
mlsize=d.size
size=mlsize
dx=size & " Byte"
if size>1024 then
size=(Size/1024)
dx=size & " KB"
end if
if size>1024 then
size=(size/1024)
dx=formatnumber(size,2) & " MB"
end if
if size>1024 then
size=(size/1024)
dx=formatnumber(size,2) & " GB"
end if
response.write dx
end sub
Function Drawbar(drvpath)
dim fso,drvpathroot,d,size,totalsize,barsize
set fso=server.createobject("scripting.filesystemobject")
drvpathroot=server.mappath("/")
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)*600)
Drawbar=barsize
End Function
%>
</body>
</html>
<%
sub yasu()
Set Conn = Nothing
dim dbpath
dbpath = request("dbpath")
If dbpath <> "" Then
dbpath = server.mappath(dbpath)
End If
'=====================压缩参数=========================
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = 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 "数据库压缩成功!"
%>
<script language=vbscript>
alert ("数据库压缩成功!")
window.location="dboperate.asp?action=CompressData"
</script>
<%
Else
%>
<script language=vbscript>
alert ("数据库名称或路径不正确. 请重试!")
window.location="dboperate.asp?action=CompressData"
</script>
<%
'response.write "数据库名称或路径不正确. 请重试!"
End If
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -