?? data_s.asp
字號(hào):
<!--#include file="../inc/md5.asp"-->
<!--#include file="../conn.asp"-->
<!--#include file="inc/inc.asp"-->
<!--#include file="../inc/inc.asp"-->
<!--#include file="admin_page_top.asp"-->
<%
Login_Judge
Dim ZC_DATABASE_PATH
'數(shù)據(jù)庫(kù)的路徑
ZC_DATABASE_PATH=DataPath
data_array= Split(ZC_DATABASE_PATH,"/")
Dim action
action=trim(request("action"))
Dim dbpath,bkfolder,bkdbname,fso,fso1
Select Case action
Case ""
Call chushihua()
Case "CompressData" '壓縮數(shù)據(jù)
Ispower 1033
Dim tmprs
dim allarticle
dim Maxid
dim topic,username,dateandtime,body
call CompressData()
case "BackupData" '備份數(shù)據(jù)
Ispower 1031
if request("act")="Backup" Then
call updata()
else
call BackupData()
end If
case "RestoreData" '恢復(fù)數(shù)據(jù)
Ispower 1032
dim backpath
if request("act")="Restore" Then
Dbpath=request.form("Dbpath")
backpath=ZC_DATABASE_PATH
if dbpath="" Then
response.write "Please input your database whole Name"
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
rightmsg "","數(shù)據(jù)庫(kù)被成功還原!<br>"
else
errormsg "沒(méi)找到您所需要的數(shù)據(jù)庫(kù)!"
end If
else
call RestoreData()
end If
Case "SpaceSize" '系統(tǒng)空間占用
call SpaceSize()
Case "deletebackup"
Dim dbname
dbpath=Request.QueryString("dbpath")
dbname=Request.QueryString("dbname")
dbpath=Server.MapPath(dbpath)
dbpath=dbpath &"\"&dbname
set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
fso.DeleteFile(DBPath)
Set fso = nothing
rightmsg "data_s.asp?action=BackupData","您備份的數(shù)據(jù)庫(kù)已經(jīng)" & dbpath &"被成功刪除!"
Else
response.write dbpath
errormsg "輸入的路徑錯(cuò)誤,請(qǐng)確認(rèn)后重新輸入!"
End If
Case Else
End Select
%>
<!--#include file="admin_page_footer.asp"-->
<%
'====================系統(tǒng)空間占用=======================
Sub SpaceSize()
On Error Resume Next
%>
<h1>系統(tǒng)空間查看</h1>
<table width="100%" cellspacing="1" cellpadding="0" class="info_tab">
<!-- <tr>
<td class="art_tit zq">注意:
輸入數(shù)據(jù)庫(kù)所在相對(duì)路徑,并且輸入數(shù)據(jù)庫(kù)名稱(正在使用中數(shù)據(jù)庫(kù)不能壓縮,請(qǐng)選擇備份數(shù)據(jù)庫(kù)進(jìn)行壓縮操作)
</td>
</tr> -->
<tr>
<td class="art_info2 zq">數(shù)據(jù)庫(kù):<%showSpaceinfo("../"&data_array(UBound(data_array)-1))%></td></tr>
<tr>
<td class="art_info2 zq">備份數(shù)據(jù)庫(kù):<%showSpaceinfo("../databackup")%></td></tr>
<tr>
<td class="art_info2 zq">頁(yè)面文件:<%showSpaceinfo("$$~_~$$")%></td></tr>
<tr>
<td class="art_info2 zq">系統(tǒng)總共:<%showSpaceinfo("../")%></td></tr>
</table>
<%End Sub
Sub ShowSpaceInfo(drvpath)
dim fso,d,size,showsize
set fso=server.CreateObject("scripting.filesystemobject")
If drvpath="$$~_~$$" Then
drvpath1=server.mappath("../")
set d=fso.getfolder(drvpath1)
size1=d.size
drvpath2=server.mappath("../databackup")
set e=fso.getfolder(drvpath2)
size2=e.size
drvpath3=server.mappath("../"&data_array(UBound(data_array)-1))
set f=fso.getfolder(drvpath3)
size2=f.size
size=size1-size2-size3
Else
drvpath=server.mappath(drvpath)
set d=fso.getfolder(drvpath)
size=d.size
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()%>
<h2>還原數(shù)據(jù)庫(kù)(恢復(fù)論壇數(shù)據(jù)( 需要FSO支持,F(xiàn)SO相關(guān)幫助請(qǐng)看微軟網(wǎng)站 ))</h2>
<table width="100%" cellspacing="1" cellpadding="0" class="info_tab">
<!-- <tr>
<td class="art_tit zq">注意:
輸入數(shù)據(jù)庫(kù)所在相對(duì)路徑,并且輸入數(shù)據(jù)庫(kù)名稱(正在使用中數(shù)據(jù)庫(kù)不能壓縮,請(qǐng)選擇備份數(shù)據(jù)庫(kù)進(jìn)行壓縮操作)
</td>
</tr> -->
<form id="edit" method="post" action="data_s.asp?action=RestoreData&act=Restore">
<tr>
<td class="art_tit zq">還原的路徑(相對(duì)路徑):<input type=text size=30 name=DBpath value="..\DataBackup\<%=Date()%>_Bak.mdb"></td>
</tr>
<tr>
<td class="art_tit"> <input type=submit value="開(kāi)始還原"></td>
</tr>
</form>
</table>
<h6>在上面填寫本程序的數(shù)據(jù)庫(kù)路徑全名,本程序的默認(rèn)備份數(shù)據(jù)庫(kù)文件為DataBackup\時(shí)間_Bak.MDB,請(qǐng)按照您的備份文件自行修改。</h6>
<h6>您可以用這個(gè)功能來(lái)備份您的法規(guī)數(shù)據(jù),以保證您的數(shù)據(jù)安全!</h6>
<h6>注意:所有路徑都是相對(duì)與程序空間根目錄的相對(duì)路徑</h6>
<%End Sub
Sub updata()
Dbpath=ZC_DATABASE_PATH
Dbpath=server.mappath(Dbpath)
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
If bkfolder="" Then bkfolder="..\Databackup"
If bkfolder="..\" & data_array(UBound(data_array)-1) Then errormsg "Error 備份數(shù)據(jù)庫(kù)目標(biāo)文件夾不可在系統(tǒng)數(shù)據(jù)庫(kù)目錄下!"
If bkfolder="../" & data_array(UBound(data_array)-1) Then errormsg "Error 備份數(shù)據(jù)庫(kù)目標(biāo)文件夾不可在系統(tǒng)數(shù)據(jù)庫(kù)目錄下!"
If bkdbname="" Then bkdbname="2007-9-9_bak"
bkdbname=bkdbname & ".mdb"
bkfolders=bkfolder
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 "<h2>已經(jīng)成功備份,你的數(shù)據(jù)庫(kù)的路徑:" &bkfolders& "\"& bkdbname&"</h2>"
response.write "<h4>點(diǎn)擊此處將數(shù)據(jù)庫(kù)下載下來(lái):<a href="""& bkfolders & "/" & bkdbname &""">" & bkfolder & "/" & bkdbname &"</h4>"
response.write "<h4><a href=""data_s.asp?action=deletebackup&dbpath="&bkfolders&"&dbname=" & bkdbname &""">當(dāng)您下載完畢后,點(diǎn)擊此處將刪除備份的數(shù)據(jù)庫(kù)!</h4>"
response.write "<h4><a href=""javascript:history.go(-1)"">返回上一頁(yè)</a></h4>"
Else
errormsg "Error 找不到文件!"
End If
Set fso = nothing
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
'-------------根據(jù)指定名稱生成目錄-----------------------
Function MakeNewsDir(foldername)
dim f
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
Sub BackupData()
%>
<h2>備份數(shù)據(jù)庫(kù)(恢復(fù)論壇數(shù)據(jù)( 需要FSO支持,F(xiàn)SO相關(guān)幫助請(qǐng)看微軟網(wǎng)站 )</h2>
<table width="100%" cellspacing="1" cellpadding="0" class="info_tab">
<!-- <tr>
<td class="art_tit zq">注意:
輸入數(shù)據(jù)庫(kù)所在相對(duì)路徑,并且輸入數(shù)據(jù)庫(kù)名稱(正在使用中數(shù)據(jù)庫(kù)不能壓縮,請(qǐng)選擇備份數(shù)據(jù)庫(kù)進(jìn)行壓縮操作)
</td>
</tr> -->
<form id="edit" method="post" action="data_s.asp?action=BackupData&act=Backup">
<tr>
<td class="art_tit zq">備份數(shù)據(jù)庫(kù)目錄(相對(duì)路徑):<input type=text name=bkfolder value="..\Databackup" style="width:180px;"> 如目錄不存在,程序?qū)⒆詣?dòng)創(chuàng)建</td>
</tr>
<tr>
<td class="art_tit zq">備份數(shù)據(jù)庫(kù)名稱(填寫名稱):<input type=text name=bkDBname value="<%=Date()%>_bak" style="width:156px;">.mdb 按日期自動(dòng)命名。如備份目錄有該文件,將覆蓋,如沒(méi)有,將自動(dòng)創(chuàng)建</td>
</tr>
<tr>
<td class="art_tit"> <input type=submit value="開(kāi)始備份"></td>
</tr>
</form>
</table>
<h6>請(qǐng)一定不能用默認(rèn)名稱命名備份數(shù)據(jù)庫(kù)。</h6>
<h6>您可以用這個(gè)功能來(lái)備份您的法規(guī)數(shù)據(jù),以保證您的數(shù)據(jù)安全!</h6>
<h6>注意:所有路徑都是相對(duì)與程序空間根目錄的相對(duì)路徑</h6>
<%
End Sub
Sub CompressData()
%>
<h2>壓縮數(shù)據(jù)庫(kù)( 需要FSO支持,F(xiàn)SO相關(guān)幫助請(qǐng)看微軟網(wǎng)站 )</h2>
<table width="100%" cellspacing="1" cellpadding="0" class="info_tab">
<!-- <tr>
<td class="art_tit zq">注意:
輸入數(shù)據(jù)庫(kù)所在相對(duì)路徑,并且輸入數(shù)據(jù)庫(kù)名稱(正在使用中數(shù)據(jù)庫(kù)不能壓縮,請(qǐng)選擇備份數(shù)據(jù)庫(kù)進(jìn)行壓縮操作)
</td>
</tr> -->
<form id="edit" action="data_s.asp?action=CompressData" method="post">
<tr>
<td class="art_tit zq"><input type="checkbox" name="boolIs97" value="True">如果是ac97,請(qǐng)將鉤打上.(默認(rèn)是Access 2000)</td>
</tr>
<tr>
<td class="art_tit"> <input type="submit" value="開(kāi)始?jí)嚎s"></td>
</tr>
<INPUT TYPE="hidden" NAME="Cdat" value="1">
</form>
</table>
<%
Dim dbpath,boolIs97
boolIs97 = request("boolIs97")
If request("Cdat")<>"" Then
dbpath = server.mappath(ZC_DATABASE_PATH)
response.write(CompactDB(dbpath,boolIs97))
End If
End Sub
'=====================壓縮參數(shù)=========================
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath,JET_3X
strDBPath = Left(dbPath,InStrRev(DBPath,"\"))
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
CompactDB = "<h6>您的數(shù)據(jù)庫(kù)已經(jīng)被成功壓縮! " & vbCrLf
Else
CompactDB = "<h6>您輸入的路徑錯(cuò)誤,請(qǐng)確認(rèn)后重新輸入!</h6>" & vbCrLf
End If
End Function
'////////////////////end////////////////////////
%>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -