⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_datebaseback.asp

📁 功能强大 首发! 演示地址:http://jsice.com QQ:3300828 运行环境: Internet Information Server 5.x or 6.0 (ii
💻 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)""> &lt;&lt; 返回上一页</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)"">&lt;&lt; 返回上一页</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">
      &nbsp;如目录不存在,程序将自动创建</td>
  </tr>
  <tr> 
    <td height="25" nowrap>备份数据库名称(填写名称):</td>
    <td class="tdbg1" height="25" width="100%" > 
      <input type=text size=30 name=bkDBname value="#$JsIce#@web%20backup.mdb" class="form">
      &nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建,建议采用默认备份目录</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%>/#$JsIce#@web%20backup.mdb" class="form" size="40">
        &nbsp; 
        <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%>/#$JsIce#@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/#$JsIce#@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 + -