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

📄 admin_data.asp

📁 ASP+Accesss数据库设备WEB报修
💻 ASP
字号:
<%if session("pass")<>"ok" then 
    Response.Redirect "index.asp"
    Response.End 
  end if
%>
<!--#include file="conn.asp"-->

<head>
<title>空间使用信息查看</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="TableBorder" align=center>
<tr align="center">
    <td height=23 colspan=2 class="TableTitle1"><strong>空 间 使 用 情 况</strong></tr>
<tr>
    <td width="100" height=25 class="TableRow2"><strong>管理快捷方式:</strong></td>
    <td class="TableRow2"><a href="Admin_system.asp">网站信息设置</a> | <a href="admin_data.asp?action=SpaceSize">
	空间使用情况</a> | <A href="admin_data.asp?action=RestoreData" target="main">恢复数据</A> | <A href="admin_data.asp?action=CompressData" target="main">压缩数据</A> | <A href="admin_data.asp?action=BackupData" target="main">备份数据</A></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="2">
  <tr> 
    <td  class="b1" valign="top"> 
      <%
dim action
dim admin_flag
action=trim(request("action"))



select case action
case "CompressData"		'压缩数据
		call CompressData()
case "BackupData"		'备份数据
	if request("act")="Backup" then
		call updata()
	else
		call BackupData()
	end if
case "RestoreData"		'恢复数据
		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 "SpaceSize"		'系统空间占用
		call SpaceSize()
case else
		Errmsg=ErrMsg + "<BR><li>选取相应的操作。"
end select

'====================系统空间占用=======================
sub SpaceSize()
on error resume next
%>
 <TABLE border=0 cellPadding=0 cellSpacing=0 width=100% align=center class="TableBorder">
        <tr align="center"> 
          <td  height=23 class="TableTitle1"><STRONG>系统空间占用情况 </STRONG> </td>
        </tr>
        <tr> 
          <td class="TableRow2"> 
            <blockquote> <br>
              常规数据占用空间:<br>
              &nbsp;<img src="IMAGES/bar1.gif" width=<%=drawbar("data")%> height=10>&nbsp; 
              <%showSpaceinfo("data")%>
              <br>
              <br>
              备份数据占用空间:<br>
              &nbsp;<img src="IMAGES/bar2.gif" width=<%=drawbar("../dbbak")%> height=10>&nbsp; 
              <%showSpaceinfo("../dbbak")%>
              <br>
              <br>
              前台图片占用空间:<br>
              &nbsp;<img src="IMAGES/bar4.gif" width=<%=drawbar("../IMAGES")%> height=10>&nbsp; 
              <%showSpaceinfo("../IMAGES")%>
              <br>
              <br>
              后台图片占用空间:<br>
              &nbsp;<img src="IMAGES/bar5.gif" width=<%=drawbar("IMAGES")%> height=10>&nbsp; 
              <%showSpaceinfo("IMAGES")%>
              <br>
              <br>
              后台占用空间总计:<br>
              &nbsp;<img src="IMAGES/bar9.gif"height=10> 
              <%showspecialspaceinfo("All")%>
              <br>
              <br>
              系统占用空间总计:<br>
              &nbsp;<img src="IMAGES/bar6.gif" width=<%=drawbar("../")%> height=10>&nbsp; 
              <%showSpaceinfo("../")%>
          </blockquote>          </td>
        </tr>
      </table>
      <%
end sub

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

'====================备份数据库=========================
sub BackupData()
%>
       <TABLE border=0 cellPadding=0 cellSpacing=0 width=100% align=center class="tableBorder">
        <tr align="center"> 
         <td height=23 class="TableTitle1"> &nbsp;&nbsp;<B>备份系统数据</B>( 需要FSO支持,FSO相关帮助请看微软网站 
            ) </td>
        </tr>
        <form method="post" action="ADMIN_data.asp?action=BackupData&act=Backup">
          <tr> 
            <td height=100 class="TableRow2"> &nbsp;&nbsp; 当前数据库路径(相对路径):
              <input type=text size=22 name=DBpath value="<%=db%>">
              <BR>
              &nbsp;&nbsp; 备份数据库目录(相对路径):
              <input type=text size=22 name=bkfolder value=../dbbak>
              &nbsp;如目录不存在,程序将自动创建<BR>
              &nbsp;&nbsp; 备份数据库名称(填写名称): 
              <input type=text size=22 name=bkDBname value=bak.mdb>
              &nbsp;如备份目录有该文件,将覆盖,如没有,将自动创建<BR>
              &nbsp;&nbsp;
              <input type=submit value="确定">
              <br>            </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 cellPadding=0 cellSpacing=0 width=100% align=center class="TableBorder">
     <form action="Admin_data.asp?action=CompressData" method="post">
              <tr align="center"> 
         <td height=23 class="TableTitle1"> &nbsp;&nbsp;<B>压缩系统数据</B> </td>
        </tr>
        <tr>
          <td class="TableRow2" height=35>
			<p style="text-indent: 8px"><b>注意:</b><span class="tdbg2"><br>
            输入数据库所在相对路径,并且输入数据库名称(正在使用中数据库不能压缩,请选择备份数据库进行压缩操作) </span></td>
        </tr>
        <tr> 
          <td class="TableRow2" height="31">压缩数据库: 
            <input type="text" name="dbpath" value=../dbbak/bak.mdb size="20">
            &nbsp; 
            <input type="submit" value="开始压缩">          </td>
        </tr>
        <tr> 
          <td class="TableRow2"> 
            <input type="checkbox" name="boolIs97" value="True">
            如果使用 Access 97 数据库请选择 (默认为 Access 2000 数据库)<br>
            <br>
          </td>
        </tr><td class="TableRow2"><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


'=====================系统空间参数=========================
	Sub ShowSpaceInfo(drvpath)
 		dim fso,d,size,showsize
 		set fso=server.createobject("scripting.filesystemobject") 		
 		drvpath=server.mappath(drvpath) 		 		
 		set d=fso.getfolder(drvpath) 		
 		size=d.size
 		showsize=size & "&nbsp;Byte" 
 		if size>1024 then
 		   size=(size\1024)
 		   showsize=size & "&nbsp;KB"
 		end if
 		if size>1024 then
 		   size=(size/1024)
 		   showsize=formatnumber(size,2) & "&nbsp;MB"		
 		end if
 		if size>1024 then
 		   size=(size/1024)
 		   showsize=formatnumber(size,2) & "&nbsp;GB"	   
 		end if   
 		response.write "<font face=verdana>" & showsize & "</font>"
 	End Sub	
 	
 	Sub Showspecialspaceinfo(method)
 		dim fso,d,fc,f1,size,showsize,drvpath 		
 		set fso=server.createobject("scripting.filesystemobject")
 		drvpath=server.mappath("pic")
 		drvpath=left(drvpath,(instrrev(drvpath,"\")-1))
 		set d=fso.getfolder(drvpath) 		
 		
 		if method="All" then 		
 			size=d.size
 		elseif method="Program" then
 			set fc=d.Files
 			for each f1 in fc
 				size=size+f1.size
 			next	
 		end if	
 		
 		showsize=size & "&nbsp;Byte" 
 		if size>1024 then
 		   size=(size\1024)
 		   showsize=size & "&nbsp;KB"
 		end if
 		if size>1024 then
 		   size=(size/1024)
 		   showsize=formatnumber(size,2) & "&nbsp;MB"		
 		end if
 		if size>1024 then
 		   size=(size/1024)
 		   showsize=formatnumber(size,2) & "&nbsp;GB"	   
 		end if   
 		response.write "<font face=verdana>" & showsize & "</font>"
 	end sub 	 	 	
 	
 	Function Drawbar(drvpath)
 		dim fso,drvpathroot,d,size,totalsize,barsize
 		set fso=server.createobject("scripting.filesystemobject")
 		drvpathroot=server.mappath("pic")
 		drvpathroot=left(drvpathroot,(instrrev(drvpathroot,"\")-1))
 		set d=fso.getfolder(drvpathroot)
 		totalsize=d.size
 		
 		drvpath=server.mappath(drvpath) 		
 		set d=fso.getfolder(drvpath)
 		size=d.size
 		
 		barsize=cint((size/totalsize)*5)
 		Drawbar=barsize
 	End Function 	
 	
 	Function Drawspecialbar()
 		dim fso,drvpathroot,d,fc,f1,size,totalsize,barsize
 		set fso=server.createobject("scripting.filesystemobject")
 		drvpathroot=server.mappath("pic")
 		drvpathroot=left(drvpathroot,(instrrev(drvpathroot,"\")-1))
 		set d=fso.getfolder(drvpathroot)
 		totalsize=d.size
 		
 		set fc=d.files
 		for each f1 in fc
 			size=size+f1.size
 		next	
 		
 		barsize=cint((size/totalsize)*400)
 		Drawspecialbar=barsize
 	End Function 	
%>
    </td>
  </tr>
</table>

 			<!--#include file="copyright.asp" -->
</BODY></HTML>

⌨️ 快捷键说明

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