?? admin_datebaseback.asp
字號:
<!--#include file="../Conn.ASP"--><!--#include file="../inc/config.asp"-->
<!--#include file="session.asp"--><!-- #include file="../inc/version.asp" -->
<html>
<head>
<title>數據管理</title>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="css.css" type="text/css">
</head>
<body>
<%Server.ScriptTimeout=999999 '程序執行超時秒數%>
<%
Sub ShowAdminErrMsg()
dim strMsg
strMsg=strMsg & "<br><br>" & vbcrlf
strMsg=strMsg & " <table cellpadding=""5"" cellspacing=""1"" border=""0"" width=400 class=""tableBorder"" align=center>" & vbcrlf
strMsg=strMsg & " <th height=25>錯誤信息</th>" & vbcrlf
strMsg=strMsg & " <tr class=""tdbg""><td height=""100"" valign=""top""><br>您的操作請求產生錯誤了,原因如下:<br><br>" & ErrCodes &"</td></tr>" & vbcrlf
strMsg=strMsg & " <tr class=""tdbg1"" align=""center""><td ><a href=""javascript:history.go(-1)""> << 返回上一頁</a></td></tr>" & vbcrlf
strMsg=strMsg & "</table>" & vbcrlf
response.write strMsg
End Sub
Sub ShowAdminSuccessMsg(SuccessMsg)
dim strMsg
strMsg=strMsg & "<br><br>" & vbcrlf
strMsg=strMsg & " <table cellpadding=""5"" cellspacing=""1"" border=""0"" width=400 class=""tableBorder"" align=center>" & vbcrlf
strMsg=strMsg & " <th height=25>成功信息</th>" & vbcrlf
strMsg=strMsg & " <tr><td class=""tdbg"" height=""100"" valign=""top""><br><li>" & SuccessMsg &"</td></tr>" & vbcrlf
strMsg=strMsg & " <tr align=""center""><td class=""tdbg1""><a href=""javascript:history.go(-1)""><< 返回上一頁</a></td></tr>" & vbcrlf
strMsg=strMsg & "</table>" & vbcrlf
response.write strMsg
End Sub
Dim Action,FoundErr,ErrCodes
dim dbpath,bkfolder,bkdbname,fso,fso1
Dim AFSO,AFile,AData,AFDate
FoundErr=False
Action=Request("action")
Select Case Action
Case "BackupDataMain"
Call BackupDataMain()
Case "BackupData"
Call backupdata()
Case "CompressDataMain"
Call CompressDataMain()
Case "CompressData"
Call CompressData()
Case "RestoreDataMain"
Call RestoreDataMain()
Case "RestoreData"
Call RestoreData()
Case "ConnSqlMain"
Call ConnSqlMain()
Case "ConnSql"
Call ConnSql()
Case Else
End Select
If FoundErr=True then
Call ShowAdminErrMsg()
End If
Sub BackupDataMain
%>
<table cellpadding="5" cellspacing="1" border="1" width="100%" align=center bordercolor="#1f3566" bordercolordark="#FFFFFF">
<tr> <th colspan="2" height=25 bgcolor="#1C3566">
<font color="#FFFFFF">
<B>備份數據庫</B>( 需要FSO支持,FSO相關幫助請看微軟網站 )</font></th>
</tr>
<form method="post" action="?action=BackupData">
<tr>
<td height="25" nowrap>當前數據庫路徑(相對路徑):</td>
<td class="tdbg1" height="25" width="100%" >
<input type=text size=30 name=DBpath value="../<%=DatabasPath%>/<%=sitidata%>" class="form">
</td>
</tr>
<tr>
<td height="25" nowrap>備份數據庫目錄(相對路徑):</td>
<td class="tdbg1" height="25" width="100%" >
<input type=text size=30 name=bkfolder value="../<%=DatabackupPath%>" class="form">
如目錄不存在,程序將自動創建</td>
</tr>
<tr>
<td height="25" nowrap>備份數據庫名稱(填寫名稱):</td>
<td class="tdbg1" height="25" width="100%" >
<input type=text size=30 name=bkDBname value="#$cnend#@web%20backup.mdb" class="form">
如備份目錄有該文件,將覆蓋,如沒有,將自動創建,建議采用默認備份目錄</td>
</tr>
<tr align="center">
<td height="25" colspan="2">
<input type=submit value="確定備份" name="submit" class="button">
</td>
</tr>
</form>
</table>
<%
End Sub
sub backupdata()
Dbpath=request.form("Dbpath")
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
If Lcase(Left(dbpath,Len(DatabasPath)+3))<>"../"&Lcase(DatabasPath)&"" Then
ErrCodes = ErrCodes & "<li>為了安全,只允許備份"&DatabasPath&"目錄中的數據!</li><br>"
FoundErr=True
ElseIf bkfolder<>"../"&DatabackupPath&"" Then
ErrCodes = ErrCodes & "<li>為了安全,數據庫只允許備份到"&DatabackupPath&"目錄中!</li><br>"
FoundErr=True
Else
Dbpath=server.mappath(Dbpath)
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
Call ShowAdminSuccessMsg("備份數據庫成功,您備份的數據庫路徑為" &bkfolder& "\"& bkdbname)
Else
ErrCodes = ErrCodes & "<li>找不到您所需要備份的文件!</li><br>"
FoundErr=True
End if
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 CompressDataMain()
%>
<table cellpadding="5" cellspacing="1" border="1" width="100%" align=center bordercolor="#1f3566" bordercolordark="#FFFFFF">
<tr>
<th colspan="2" height=26 bgcolor="#1C3566"> <font color="#FFFFFF"> <B>壓縮數據庫</B>( 需要FSO支持,FSO相關幫助請看微軟網站 )</font></th>
</tr>
<form method="post" action="?action=CompressData">
<tr>
<td height="25" colspan="2"><b>注意:</b>輸入數據庫所在相對路徑,并且輸入數據庫名稱(正在使用中數據庫不能壓縮,請選擇備份數據庫進行壓縮操作)
</td>
</tr>
<tr>
<td height="25" nowrap>壓縮數據庫:</td>
<td class="tdbg1" height="25" width="100%" >
<input type="text" name="dbpath" value="../<%=DatabackupPath%>/#$cnend#@web%20backup.mdb" class="form" size="40">
<input type="submit" value="開始壓縮" name="submit2" class="button">
</td>
</tr>
<tr>
<td height="25" colspan="2">
<input type="checkbox" name="boolIs97" value="True" class="form">如果使用 Access 97 數據庫請選擇 (默認為 Access 2000/Access 2003 數據庫)</td>
</tr>
</form>
</table>
<%
end sub
Sub CompressData()
dim dbpath,boolIs97
Dim fso, Engine, strDBPath,JET_3X
dbpath = request("dbpath")
If (Lcase(Left(dbpath,Len(DatabasPath)+3))<>"../"&Lcase(DatabasPath)&"") And (Lcase(Left(dbpath,Len(DatabackupPath)+3))<>"../"&Lcase(DatabackupPath)&"") Then
ErrCodes = ErrCodes & "<li>為了安全,只允許壓縮"&DatabasPath&"或"&DatabackupPath&"目錄中的數據庫!</li><br>"
FoundErr=True
Exit Sub
End If
boolIs97 = request("boolIs97")
If dbpath <> "" Then
dbpath = server.mappath(dbpath)
End If
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
Call ShowAdminSuccessMsg("你的數據庫, " & dbpath & ", 已經壓縮成功!")
Else
ErrCodes = ErrCodes & "<li>數據庫名稱或路徑不正確,請重試!</li><br>"
FoundErr=True
End If
End Sub
'恢復數據庫
sub RestoreDataMain()
%>
<table cellpadding="5" cellspacing="1" border="1" width="100%" align=center bordercolor="#1f3566" bordercolordark="#FFFFFF">
<tr>
<th colspan="2" height=25 bgcolor="#1C3566"> <font color="#FFFFFF"> <B>恢復網站數據</B>( 需要FSO支持,FSO相關幫助請看微軟網站
)</font></th>
</tr>
<form method="post" action="?action=RestoreData">
<tr>
<td height="25" colspan="2"><b>注意:</b>輸入數據庫所在相對路徑,并且輸入數據庫名稱(正在使用中數據庫不能壓縮,請選擇備份數據庫進行壓縮操作)
</td>
</tr>
<tr>
<td height="25" nowrap>備份數據庫路徑(相對):</td>
<td class="tdbg1" height="25" width="100%" >
<input type=text size=40 name=DBpath value="../<%=DatabackupPath%>/#$cnend#@web%20backup.mdb" class="form">
</td>
</tr>
<tr>
<td height="25" nowrap>目標數據庫路徑(相對):</td>
<td class="tdbg1" height="25" width="100%" >
<input type=text size=40 name=backpath value="../<%=DatabasPath%>/<%=sitidata%>" class="form">
<br>
填寫您當前使用的數據庫路徑,如不想覆蓋當前文件,可自行命名(注意路徑是否正確),然后修改conn.asp文件,如果目標文件名和當前使用數據庫名一致的話,不需修改conn.asp文件
</td>
</tr>
<tr>
<td height="25" colspan="2" align="center">
<input type=submit value="恢復數據" name="submit3" class="button">
</td>
</tr>
<tr>
<td height="25" colspan="2">在上面填寫本程序的數據庫路徑全名,本程序的默認備份數據庫文件為../Databackup/#$cnend#@web%20backup.mdb,請按照您的備份文件自行修改。<br>
您可以用這個功能來備份您的法規數據,以保證您的數據安全!<br>
注意:所有路徑都是相對與程序空間根目錄的相對路徑</td>
</tr>
</form>
</table>
<%
end sub
Sub RestoreData()
dim backpath
Dbpath=request.form("Dbpath")
backpath=request.form("backpath")
if dbpath="" then
ErrCodes = ErrCodes & "<li>請輸入您要恢復成的數據庫全名!</li><br>"
FoundErr=True
else
If Lcase(Left(DbPath,Len(DatabackupPath)+3))<>"../"&Lcase(DatabackupPath)&"" Then
ErrCodes = ErrCodes & "<li>為了安全,只允許恢復"&DatabackupPath&"目錄中的數據!</li><br>"
FoundErr=True
Elseif Lcase(Left(backpath,Len(DatabasPath)+3))<>"../"&Lcase(DatabasPath)&"" Then
ErrCodes = ErrCodes & "<li>為了安全,只允許恢復數據庫至"&DatabasPath&"目錄中!</li><br>"
FoundErr=True
Else
Dbpath=server.mappath(Dbpath)
backpath=server.mappath(backpath)
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
fso.copyfile Dbpath,Backpath
Call ShowAdminSuccessMsg("成功恢復數據!")
else
ErrCodes = ErrCodes & "<li>備份目錄下并無您的備份文件!</li><br>"
FoundErr=True
end if
end if
End If
End Sub
'數據庫管理
Sub ConnSqlMain()
%>
<table cellpadding="5" cellspacing="1" border="1" width="100%" align=center bordercolor="#1f3566" bordercolordark="#FFFFFF">
<tr>
<th colspan="2" height=25 bgcolor="#1C3566"> <font color="#FFFFFF"> <B>執行SQL操作</B></font></th>
</tr>
<form method="post" action="?action=ConnSql">
<tr>
<td height="25" colspan="2"><b>SOL語句執行操作</b>:本操作僅限高級、對SQL編程比較熟悉的用戶,您可以直接輸入SQL執行語句,比如delete
from bbs1 where username='test'進行刪除某用戶帖子操作,在操作前請慎重考慮您的執行語句是否正確和完整,執行后不可恢復。</td>
</tr>
<tr>
<td height="25" nowrap>請輸入SQL語句指令:</td>
<td class="tdbg1" height="25" width="100%" >
<Input type="text" name="SQL_Statement" Size=50 class="form">
<select name="SQL_class" size="1" class='form'>
<option value="conn" name=SQL_class>主數據庫</option>
<option value="Itemconn" name=SQL_class>采集數據庫</option>
<option value="tempconn" name=SQL_class>模版數據庫</option>
</select>
<input type="Submit" value="執 行" name="Submit" class="button">
</td>
</tr>
</form>
</table>
<%
End Sub
Sub ConnSql()
If Not IsUseSQl Then
ErrCodes = ErrCodes & "<li>本功能已經被設置為禁止使用!</li><br><li>如果您需要開啟的話,請自行修改conn.ASP,找到IsUseSQl=False,改為:IsUseSQl=True;如果您的網站有2個以上管理員,為了系統安全,建議不要開啟。"
FoundErr=True
Exit Sub
End If
Dim SQL_Statement
SQL_Statement=Request("SQL_Statement")
SQL_class=Request("SQL_class")
if SQL_Statement<>"" then
On Error Resume Next
if SQL_class="conn" then
conn.Execute(SQL_Statement)
elseif SQL_class="Itemconn" then
Itemconn.Execute(SQL_Statement)
elseif SQL_class="tempconn" then
tempconn.Execute(SQL_Statement)
else
Call ShowAdminSuccessMsg("未知錯誤!已停止")
end if
if err.number=0 then
Call ShowAdminSuccessMsg("SQL語句指令執行成功!")
else
ErrCodes = ErrCodes & "<li>SQL語句有問題!具體出錯如下:<br>"&Err.Description&"</li><br>"
FoundErr=True
end if
Else
ErrCodes = ErrCodes & "<li>SQL語句指令不能為空!</li><br>"
FoundErr=True
End if
End Sub
%><br>執行此操作前,請先關閉其它網頁窗口,斷開FTP連接。<br>
提交后,請耐心等待<font color=red>(請不要重復點擊上面的按鈕),</font>完成時間視網絡狀況而定。<br>
本操作<font color="#FF0000">極占系統資源</font>請在網絡空閑時進行此操作,<b>執行此操作可能導致服務器變慢或不穩定</b>。
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -