?? database.asp
字號:
<%@language=vbscript codepage=936 %>
<%
if session("admin")<>1 then response.Redirect "default.asp"
response.buffer=true
%>
<!--#include file="config.asp"-->
<!--#INCLUDE FILE="background.asp"-->
<%
conn.close
set conn=nothing
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
dim dbpath
dbpath=server.mappath(db)
%>
<html>
<head>
<title>數據庫管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="1.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
margin-left: 15px;
margin-top: 15px;
margin-right: 15px;
margin-bottom: 15px;
}
-->
</style></head>
<body>
<%
if Action="Backup" or Action="BackupData" then
set conn=nothing
call ShowBackup()
elseif Action="Compact" or Action="CompactData" then
set conn=nothing
call ShowCompact()
elseif Action="Restore" or Action="RestoreData" then
set conn=nothing
call ShowRestore()
elseif Action="SpaceSize" then
call SpaceSize()
set conn=nothing
else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>錯誤參數!</li>"
set conn=nothing
end if
sub ShowBackup()
%>
<form method="post" action="Database.asp?action=BackupData">
<table width="100%" align="center" cellpadding="5" cellspacing="1" class="tablebg<%=skin%>b">
<tr class="tablebg<%=skin%>a">
<td height="22" align="center" valign="middle" class="tablebg<%=skin%>d"><b>備 份 數 據 庫</b></td>
</tr>
<tr class="tablebg<%=skin%>d">
<td height="150" align="center" valign="middle">
<%
if request("action")="BackupData" then
call backupdata()
else
%>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<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=" 開始備份 "></td>
</tr>
</table>
<%
end if
%>
</td>
</tr>
</table>
</form>
<%
end sub
sub ShowCompact()
%>
<form method="post" action="Database.asp?action=CompactData">
<table width="100%" align="center" cellpadding="5" cellspacing="1" class="tablebg<%=skin%>b">
<tr class="tablebg<%=skin%>a">
<td height="22" align="center" valign="middle" class="tablebg<%=skin%>d"><b>數據庫在線壓縮</b></td>
</tr>
<tr class="tablebg<%=skin%>d">
<td height="150" align="center" valign="middle">
<%
if request("action")="CompactData" then
call CompactData()
else
%>
<br>
<br>
<br>
壓縮前,建議先備份數據庫,以免發生意外錯誤。 <br>
<br>
<br>
<input name="submit" type=submit value=" 壓縮數據庫 ">
<br>
<br>
<%
end if
%>
</td>
</tr>
</table>
</form>
<%
end sub
sub ShowRestore()
%>
<form method="post" action="Database.asp?action=RestoreData">
<table width="100%" align="center" cellpadding="5" cellspacing="1" class="tablebg<%=skin%>b">
<tr class="tablebg<%=skin%>a">
<td height="22" align="center" valign="middle" class="tablebg<%=skin%>d"><b>數據庫恢復</b></td>
</tr>
<tr class="tablebg<%=skin%>d">
<td align="center" height="150" valign="middle">
<%
if request("action")="RestoreData" then
call RestoreData()
else
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200" height="30" align="right">備份數據庫路徑(相對):</td>
<td height="30"><input name=backpath type=text id="backpath" value="DataBackup\data.mdb" size=50 maxlength="200"></td>
</tr>
<tr align="center">
<td height="40" colspan="2"><input name="submit" type=submit value=" 恢復數據 "></td>
</tr>
</table>
<%
end if
%>
</td>
</tr>
</table>
</form>
<%
end sub
sub SpaceSize()
on error resume next
%>
<br>
<table width="100%" align="center" cellpadding="5" cellspacing="1" class="tablebg<%=skin%>b">
<tr class="tablebg<%=skin%>a">
<td height="22" align="center" valign="middle" class="tablebg<%=skin%>d"><b>系統空間占用情況</b></td>
</tr>
<tr class="tablebg<%=skin%>d">
<td width="100%" height="150" valign="middle">
<blockquote><br>
系統數據占用空間: <img src="images/bar.gif" width=<%=drawbar("lyDB")%> height=10>
<%showSpaceinfo("lyDB")%>
<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("images")%> height=10>
<%showSpaceinfo("images")%>
<br>
<br>
上傳文件占用空間: <img src="images/bar.gif" width=<%=drawbar("Upload")%> height=10>
<%showSpaceinfo("Upload")%>
<br>
<br>
系統占用空間總計: <img src="images/bar.gif" width=400 height=10>
<%showspecialspaceinfo("All")%>
</blockquote>
</td>
</tr>
</table>
<%
end sub
%>
<hr>
<div align="center">
</div>
</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>找不到數據庫,請使用記事本打開本頁并修改第14行的數據庫路徑。</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 "數據庫沒有找到!請使用記事本打開本頁并修改第14行的數據庫路徑"
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 "找不到指定的備份文件!請使用記事本打開本頁并修改第14行的數據庫路徑"
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
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -