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

📄 admin_data.asp

📁 本系统是一套开源WEB的网站管理系统
💻 ASP
字号:
<!--#include file="admin_conn.asp"-->
<!--#include file="../include/admin_setting.asp"-->
<!--#include file="admin_function.asp"-->
<!--#include file="admin_serverInfo.asp"-->
<%
'==============================================================
'程序名称:茂盛网站管理系统(Maoin CSM)
'当前版本:Maosin CMS Version 1.1   Powered by maosin.com
'程序作者:阿茂(李胜茂)
'网站地址:www.maosin.com   www.maosin.net
'      QQ:57861417  
'电子邮箱:maosin@163.com  maosin@maosin.com
'--------------------------------------------------------------
'Copyright (C) 2006 maosin.com All Rights Reserved.
'免费版本请在程序首页保留(Powered by:Maosin CMS)版权链接信息;
'您可以对此版本进行修改,美化,但请保留此ASP文件内的版权信息;
'茂盛设计网保留此软件的法律追究权利
'==============================================================
Call admin_top()
Call navMenu()
Select Case LCase(Request.QueryString("action"))
	Case LCase("backupdata")
		if getPopedom("dataBackup")=false then
			popedomMsg
		else
			Call backupdata()
		end if
	Case LCase("restoreData")
		if getPopedom("dataResume")=false then
			popedomMsg
		else
			Call restoreData()
		end if
	Case LCase("Compress")
		if getPopedom("dataCompress")=false then
			popedomMsg
		else
			Call Compress()
		end if		
	Case LCase("checkServerObject")
		Call checkServerObject()
	Case LCase("spacesize")%>
	<!--#include file="admin_spacesize.asp"-->
	<%
	Case Else
		if getPopedom("dataBackup")=false then
			popedomMsg
		else
			Call backupdata()
		end if
End Select
Call admin_foot()
Sub navMenu()%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="text table_border mainTable">
  <tr><td colspan="2" class="td_titleT">数据管理</td></tr>
  <tr><td width="95" height="30" class="td_bgcolor">管理快捷导航:</td><td class="td_bgcolor">
  <a href="admin_data.asp">数据库备份</a>&nbsp;|&nbsp;
  <a href="admin_data.asp?action=restoredata">数据库恢复</a>&nbsp;|&nbsp;
  <a href="admin_data.asp?action=Compress">数据压缩</a>&nbsp;|&nbsp;
  <a href="admin_sql.asp">数据库 SQL 操作语句</a>&nbsp;|&nbsp;
  <a href="admin_data.asp?action=checkServerObject">服务器检测</a>&nbsp;|&nbsp;
  <a href="admin_data.asp?action=spacesize">服务器空间使用情况</a>
  </td></tr>
</table>
<%table(5)%>
<%End Sub
Sub backupdata()
If request.form("backdata")<>"" Then
dataSource=Request.Form("dataSource")
dataup=Request.Form("dataup")
if dataSource="" then
dataSource=datapath
end if
if dataup="" then
dataup=databackup
end if
mydatapath=Server.MapPath(dataSource)
mybackuppath=Server.MapPath(dataup)
	dim strpath,folderpath,filename
	strpath=split(mybackuppath,"\")
	arraysize=ubound(strpath)
	for i=0 to arraysize-1
	folderpath=folderpath&strpath(i)&"\"
	next
	filename=strpath(arraysize)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
if fso.folderExists(folderpath)=false then
fso.CreateFolder(folderpath)
fso.CopyFile mydatapath,folderpath&date&"_"&filename,true
set fso=Nothing
Response.write("数据已备份在:"&folderpath&date&"_"&filename)
else
fso.CopyFile mydatapath,folderpath&date&"_"&filename,true
set fso=Nothing
Response.write("数据已备份在:"&folderpath&date&"_"&filename)
end if
End If
%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="text table_border mainTable">
  <tr> 
    <td height="25" align="center" valign="middle" class="td_titleT">备份数据库(需要FSO组件支持)</td>
  </tr>
  <tr> 
    <td height="68" valign="top"  class="td_bgcolor">
	<table width="100%" border="0" cellpadding="4" cellspacing="0">
        <form action="?action=backupdata" name="backupform" method="post">
        <tr valign="middle">
          <td height="21" align="right">当前目标数据库路径:</td>
          <td> <input type="text" name="datasource" value="<%=datapath&"/"&dataMdb%>" size="30">
            *相对路径</td>
        </tr>
        <tr valign="middle"> 
          <td height="23" align="right">备份数据库保存路径:</td>
          <td> <input type="text" name="dataup" value="<%=databackup%>" size="30"> <select name="fileRS" onChange="this.form.dataup.value=this.value"><option>请选择数据库</option><%getFileRS%></select><br/>
            *绝对路径,如果目录和文件存在,程序会覆盖文件</td>
        </tr>
        <tr valign="middle"> 
          <td height="24" colspan="2" align="center"> <input type="submit" name="backdata" value="开始备份"></td>
        </tr>
		</form>
      </table></td>
  </tr>
</table>
<%
End Sub
Sub restoreData()
if request.form("restore")<>"" then
dim dataRestore,dataSource
dataRestore=Request.Form("datarestore")
dataSource=Request.Form("datasource")
if dataSource="" then
dataSource=datapath
end if
if dataRestore="" then
dataRestore=databackup
end if
dim dataSourcePath,dataRestorePath,fso
dataSourcePath=Server.MapPath(dataSource)
dataRestorePath=Server.MapPath(dataRestore)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(dataSourcePath)=false then
errormsg=dataSource&"&nbsp;目标数据库不存在,恢复不成功!<br>"
end if
if fso.FileExists(dataRestorePath)=false then
errormsg=errormsg&dataRestore&"nbsp;备份数据库不存在,恢复不成功!"
end if
if errormsg<>"" then
response.write(errormsg)
Set fso=Nothing
exit sub
else
fso.CopyFile dataRestorePath,dataSourcePath,true
set fso=nothing
end if
end if%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="text table_border mainTable">
  <tr> 
    <td height="25" align="center" valign="middle" class="td_titleT">恢复数据库(需要FSO组件支持)</td>
  </tr>
  <tr class="td_bgcolor"> 
    <td height="68" valign="top">
	<table width="100%" border="0" cellpadding="4" cellspacing="0">
        <form action="?action=restoreData" name="restoreform" method="post">
        <tr valign="middle">
          <td height="21" align="right">目标数据库路径:</td>
          <td> <input type="text" name="datarestore" value="<%=databackup%>" size="30">
		  <select name="fileRS" onChange="this.form.datarestore.value=this.value">
		  	<option>请选择数据库</option>
		  	<%getFileRS%>
		  </select></td>
        </tr>
        <tr valign="middle"> 
          <td height="23" align="right">恢复到数据库路径:</td>
          <td> <input type="text" name="datasource" value="<%=datapath&"/"&dataMdb%>" size="30">
            *[绝对路径],如果目录和文件存在,程序会覆盖文件</td>
        </tr>
        <tr valign="middle"> 
          <td height="24" colspan="2" align="center"> <input type="submit" name="restore" value="开始恢复"></td>
        </tr>
		</form>
      </table></td>
  </tr>
</table>
<%End Sub
Sub Compress()
If Request.form("compress")<>"" Then
compressDataPath=Request.form("CompressDataPath")
access97=Request.form("access97")
myDataPath=Server.MapPath(compressDataPath)
Response.Write(CompactDB(myDataPath,access97))
End If
%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="text table_border mainTable">
  <tr> 
    <td height="24" align="center" valign="middle" class="td_titleT">压缩数据库(需要FSO组件支持)</td>
  </tr>
  <tr class="td_bgcolor"> 
    <td height="130" valign="top"><table width="100%" border="0" cellpadding="6" cellspacing="0">
        <tr> 
          <td width="645" height="21" valign="top">注意:<br>
            输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </td>
        </tr>
		<form action="?action=Compress" name="compressform" Method="post">
        <tr> 
          <td height="26" valign="middle">压缩目标数据库: <input type="text" size="30" value="<%=databackup%>" name="CompressDataPath"> <select name="fileRS" onChange="this.form.CompressDataPath.value=this.value"><option>请选择数据库</option><%getFileRS%></select>
		  </td>
        </tr>
        <tr> 
          <td height="27" valign="middle"> <input name="access97" type="checkbox" id="access97" value="True">
            如果使用 Access 97 数据库请选择(默认为 Access 2000 数据库)</td>
        </tr>
        <tr> 
          <td height="29" align="center" valign="middle"> <input type="submit" name="Compress" value="开始压缩"></td>
        </tr></form>
      </table></td>
  </tr>
</table>
<%
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
	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 = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbNewLine
Else
	CompactDB = "数据库名称或路径不正确. 请重试!" & vbNewLine
End If
End Function

Sub getFileRS()
dim getbackPath,backFso,fileObj,folderObj,fileRS
getbackPath=Server.MapPath(left(databackup,InStrRev(databackup,"/")))&"\"
Set backFso=Server.CreateObject("Scripting.FileSystemObject")
if backFso.folderExists(getbackPath)=false then
		fileRS=fileRS&"<option value="""">提供的路径不存在</option>"
	response.write "提供的路径不存在"
else
	Set folderObj=backFso.getFolder(getbackPath)
	for each fileObj in folderObj.files
		fileRS=fileRS&"<option value="""&left(databackup,InStrRev(databackup,"/"))&fileObj.name&""">"&fileObj.name&"</option>"
	next
	response.write fileRS
end if
End Sub
'========================================================
'MaoSin CMS 1.1      Power by maosin.com
'Email: maosin@163.com , maosin@maosin.com
'Web: http://www.maosin.com  http://www.maosin.net
'Copyright (C) 2006 maosin.com All Rights Reserved.
'========================================================
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -