www.gusucode.com > 学校共青团组织网站源代码 > 学校共青团组织网站源代码/626/admin/admin_db_backup.asp

    <%
if Request.Cookies("admindj")<>"1" then
   Response.Write "<BR><BR><BR><BR><center>权限不足,你没有此功能的管理权限"
   Response.end
end if

sss=LCase(request.servervariables("QUERY_STRING"))
GuoLv="select,insert,;,update,',delete,exec,admin,count,drop"
GuoLvA=split(GuoLv,",")
for i=0 to ubound(GuoLvA)
  if instr(sss,GuoLvA(i))<>0 then
    Response.Redirect "res://shdoclc.dll/dnserror.htm"
    response.end		
  end if
next
%>
<!--#include file = admin_chk.asp -->
<!--#include file = titleb.asp -->
<STYLE type="text/css">
<!--
a:link {text-decoration: none; font-family: AdobeSm; color: #000000 }
a:visited {text-decoration: none; color: #000000 }
A:hover {COLOR: green; FONT-FAMILY: "宋体,MingLiU"; TEXT-DECORATION: underline}
body {font-size: 9pt; font-family:  宋体,MingLiU, Arial;color: #000000}
TD {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000;line-height: 120%;table-layout:fixed;word-break:break-all}
p {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
input {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
body {margin-top: 0; margin-bottom: 0;margin-left:0;margin-right:0; color: #000000}
select {FONT-SIZE: 9PT;font-family:  宋体}
option {FONT-SIZE: 9pt;font-family:  宋体}
textarea {FONT-SIZE: 9pt;font-family:  宋体}
-->
</STYLE>
<%
dim action
dim admin_flag




	action=trim(request("action"))

dim dbpath,bkfolder,bkdbname,fso,fso1
Dim uploadpath

	'备份数据

select case action
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 "请输入您要恢复成的数据库全名"	
			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 "<br>"
			response.write "<br>"
			response.write "<br>"
			response.write "<center>成功恢复数据!"
			response.write "</center>"			
			else
			response.write "备份目录下并无您的备份文件!"	
			end if
		else
		
			call RestoreData()
		end if
end select


'====================备份数据库=========================
sub BackupData()
If IsSqlDataBase = 1 Then
	SQLUserReadme()
	Exit Sub
End If
%>
<body bgcolor="#EFEFDE">
	<div align="center">
	<table border="0"  cellspacing="1" cellpadding="5" height="1" width="80%" class="tableBorder">
  				<tr>
  					<th height=20 >
  					&nbsp;&nbsp;<B>备份数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  					</th>
  				</tr>
  				<form method="post" action="admin_db_backup.asp?action=BackupData&act=Backup">
  				<tr>
  					<td height=20 class="forumrow">
  						 </td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;当前数据库路径(相对路径):<input type=text size=45 name=DBpath value="<%=finddir(request.servervariables("URL"))%>data/#db1.asp"></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库目录(相对路径):<input type=text size=45 name=bkfolder value=Databackup>&nbsp;<br>
&nbsp;<font color="#FF0000">如目录不存在,程序将自动创建</font></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库名称(填写名称):<input type=text size=45 name=bkDBname value=#db1.mdb>&nbsp;<br>
&nbsp;<font color="#FF0000">如备份目录有该文件,将覆盖,如没有,将自动创建</font></td>
  				</tr>	
  				<tr>
  					<td height=20 class="forumrow">
  						<p align="center">
						<input type=submit value="备份数据" style="border: 1px solid #FFFFFF"></td>
  				</tr>	
  				<tr>
  					<td class="forumrow">
  						&nbsp;&nbsp;<font color="#FF0000">在上面填写本程序的数据库路径全名,本程序的默认数据库文件为database/#db1.mdb,<B><br>
						请一定不能用默认名称命名备份数据库</B>您可以用这个功能来备份您的法规数据,以保证您的数据安全!<br>
						&nbsp;注意:所有路径都是相对与程序空间根目录的相对路径				</font>
  						</font>
  					</td>
  				</tr>
  				<tr>
  					<td class="forumrow">
  						 </td>
  				</tr>	
  				</form>
  			</table>
</div>
<%
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 "<br>"
			response.write "<br>"
			response.write "<br>"						
			response.write "<center>备份数据库成功,您备份的数据库路径为 服务器空间的:" &bkfolder& "\"& bkdbname
			response.write "</center>"
		Else
			response.write "找不到您所需要备份的文件。"
		End if
end sub
'====================恢复数据库=========================
sub RestoreData()

%>
<div align="center">
<table border="0"  cellspacing="1" cellpadding="5" height="160" width="80%" class="tableBorder">
	<th height=20 >
   					&nbsp;&nbsp;<B>恢复数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )
  					</th>
  				</tr>
				<form method="post" action="admin_db_backup.asp?action=RestoreData&act=Restore">
  				
  				<tr>
  					<td height=20 class="forumrow">
  						 </td>
  				</tr>	
  				
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;备份数据库路径(相对):<input type=text size=30 name=DBpath value="DataBackup\#db1.mdb">&nbsp;</td>
  				</tr>	
  				
  				<tr>
  					<td height=20 class="forumrow">
  						&nbsp;目标数据库路径(相对):<input type=text size=30 name=backpath value="#db1.mdb"></td>
  				</tr>	
  				
  				<tr>
  					<td class="forumrow">
  						<font color="#FF0000">
						&nbsp;填写您当前使用的数据库路径,如不想覆盖当前文件,可自行命名(注意路径是否正确),然后修改admin_conn.asp<span lang="zh-cn">和member下的conn</span>.<span lang="zh-cn">asp</span>文件,如果目标文件名和当前使用数据库名一致的话,不需修改admin_conn.asp<span lang="zh-cn">和member下的conn</span>.<span lang="zh-cn">asp</span>文件</font></td>
  				</tr>	
  				<tr>
  					<td class="forumrow">
  						<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit value="恢复数据" style="border: 1px solid #FFFFFF">
  					</td>
  				</tr>
  				
  				<tr>
  					<td class="forumrow">
  						&nbsp;<font color="#FF0000">&nbsp;在上面填写本程序的数据库路径全名,本程序的默认备份数据库文件为DataBackup\#db1.mdb,请按照您的备份文件自行修改。<br>
  						&nbsp;&nbsp;您可以用这个功能来备份您的法规数据,以保证您的数据安全!<br>
  						&nbsp;&nbsp;注意:所有路径都是相对与程序空间根目录的相对路径</font>
  					</font>
  					</td>
  				</tr>	
  				</form>
  			</table>
</div>

<%
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
%>