www.gusucode.com > 追梦翔飞数字报静态生成版 7.0 体验版码程序 > admin/admin_data.asp

    <!--#include file="Admin.asp"-->
<!--#include file="cf.asp" -->
<!--#include file="../include/conn.asp" -->
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
.STYLE2 {color: #181818;font-size: 12px}
-->
</style>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">数据管理</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9" class="left_ts"><%
dim action
action=trim(request("action"))

dim dbpath,bkfolder,bkdbname,fso,fso1

select case action
case "CompressData"		'压缩数据
	'if not supermaster or session("flag")="" then
	'	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
	'	call txl_error()
	'else
		dim tmprs
		dim allarticle
		dim Maxid
		dim topic,dateandtime,body
		call CompressData()

	'end if	

case "BackupData"		'备份数据
	'if not supermaster or session("flag")="" then
	'	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
	'	call txl_error()
	'else
		if request("act")="Backup" then
			call updata()
		else
			call BackupData()
		end if
	'end if

case "RestoreData"		'恢复数据
	dim backpath
	'if not supermaster or session("flag")="" then
	'	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用,请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
	'	call txl_error()
	'else
		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 "成功恢复数据!"
			else
			response.write "备份目录下并无您的备份文件!"	
			end if
		else
		call RestoreData()
		end if
case else
	response.Write "请选取相应的操作"
	'	Errmsg=Errmsg+"<br>"+"<li>选取相应的操作。"
	'	call txl_error()

end select

conn.close
set conn=nothing
response.write"</body></html>"

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

'====================备份数据库=========================
sub BackupData()
%>
	<table border="0"  cellspacing="1" cellpadding="5" height="1" align=center width="100%" class="tableBorder">
  				<tr class="left_txt">
  					<th height=25 >
  					&nbsp;&nbsp;<B>备份数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 )  					</th>
  				</tr>
  				<form method="post" action="ADMIN_data.asp?action=BackupData&act=Backup">
  				<tr>
  					<td height=100 class="left_txt">
  						&nbsp;&nbsp;
						当前数据库路径(相对路径):<input type=text size=30 name=DBpath value="<%=Db%>">
						<BR>
						&nbsp;&nbsp;
						备份数据库目录(相对路径):<input type=text size=30 name=bkfolder value=DataBackup>
						&nbsp;如目录不存在,程序将自动创建<BR>
						&nbsp;&nbsp;
						备份数据库名称(填写名称):<input type=text size=30 name=bkDBname value=Ghostangel_Backup#.mdb>
						&nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建<BR>
						&nbsp;&nbsp;<input type=submit value="确定"><br>
						<br>
  						&nbsp;&nbsp;在上面填写本程序的数据库路径全名,本程序的默认数据库文件为Include\#Ghostangel#.asa,<B>请一定不能用默认名称命名备份数据库</B><br>
  						&nbsp;&nbsp;您可以用这个功能来备份您的法规数据,以保证您的数据安全!<br>
  						&nbsp;&nbsp;注意:所有路径都是相对与程序空间根目录的相对路径				</font>
  					</td>
  				</tr>	
  				</form>
</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
		Else
			response.write "找不到您所需要备份的文件。"
		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"  cellspacing="1" cellpadding="5" height="1" align=center width="100%" class="tableBorder">
<form action="Admin_data.asp?action=CompressData" method="post">
<tr >
<td class="left_txt" height=25><b>注意:</b><br>输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </td>
</tr>
<tr>
<td class="left_txt">压缩数据库:<input name="dbpath" type="text" value="DataBackup\Ghostangel_Backup#.mdb" size="30">
&nbsp;
<input type="submit" value="开始压缩"></td>
</tr>
<tr>
<td class="left_txt"><input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择
(默认为 Access 2000 数据库)<br><br></td>
</tr>
<form>
</table>
<%
dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

If dbpath <> "" Then
dbpath = server.mappath(dbpath)
	response.write(CompactDB(dbpath,boolIs97))
End If

end sub

'=====================压缩参数=========================
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
Set Engine = CreateObject("JRO.JetEngine")

	If boolIs97 = "True" Then
		Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
		"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
		& "Jet OLEDB:Engine Type=" & JET_3X
	Else
		Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
		"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
	End If

fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
Set fso = nothing
Set Engine = nothing

	CompactDB = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLf

Else
	CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf
End If

End Function
%>
<%
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
%>
<%sub dosql()%>
 <table width=95% cellspacing=1 cellpadding=5  align=center>
      <tr >
        <td>
            <%end sub%></td>
        <td background="images/mail_rightbg.gif">&nbsp;</td>
      </tr>
      <tr>
        <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
        <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
        <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
      </tr>
    </table>
  </body>