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

📄 database.asp

📁 个人网站系统,本人基于第三方源码进行更改!
💻 ASP
字号:
<%@language=vbscript codepage=936 %>
<!--#Include file="../Common/Inc_DatConn.asp"-->
<!--#Include file="Common/Inc_Config.asp"-->
<!--#Include file="Common/Inc_Function.asp"-->
<%if IsTimeOut(Session("strAccount"),Session("strPassWord")) then Response.Redirect "index.asp"%>
<%Function GetFileSize(file)
   Dim fso,fs,GetFile
   On Error Resume Next
   Set Fso = Server.createobject("scripting.filesystemobject")
   Set GetFile=fso.getfile(server.mappath(file))
   GetFileSize=GetFile.size
   Set getfile=nothing
   Set fso=nothing
End Function%>
<html>
<head>
<title><% = strSiteName%> - 网站后台管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Common/Site.css" type="text/css">
</head>

<body leftMargin="0" topMargin="2">
<!--#Include file="Common/inc_Top.asp"-->
<table width="750" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="105" valign="top" style="border-left: 1px solid rgb(0,0,0); border-right: 1px solid rgb(0,0,0)" class="bottom"><br>
	<!--#Include file="Common/Inc_Button.asp"-->
    </td>
    <td valign="top" style="border-right: 1px solid rgb(0,0,0)" align="center">
      <table width="96%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
         <td height="50">当前位置:<a href="Main.asp">管理首页</a> -&gt; <%if request("kj")="fyasp" then%>空间占用<%else%>数据库管理<%end if%></td>
        </tr>
      </table>
      <table border="0" width="96%" cellspacing="0" cellpadding="0" align="center">
	    <tr>
		<td>
<%
response.buffer=true	
Const PurviewLevel=1
Const CheckChannelID=0
Const PurviewLevel_Others="Database"
%>
<%
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
dim dbpath
dim ObjInstalled
dbpath=ddstrFilePath
%>
<style type="text/css">
<!--
body {
	margin-left: 15px;
	margin-top: 15px;
	margin-right: 15px;
	margin-bottom: 15px;
}
-->
</style></head>
<%
if Action="Backup" or Action="BackupData" then
    set conn=nothing
	call ShowBackup()
elseif Action="Compact" or Action="CompactData" then
    set conn=nothing
	call ShowCompact()
elseif Action="Restore" or Action="RestoreData" then
	set conn=nothing
	call ShowRestore()
elseif Action="SpaceSize" then
	call SpaceSize()
	set conn=nothing
else
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
	set conn=nothing
end if

sub ShowBackup()
%>
<form method="post" action="Database.asp?action=BackupData">
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="table001" style="border:1PX SOLID #9BB375; ">
  <tr class="title"> 
      <td height="22" align="center" valign="middle" class="table003"><b>备 份 数 据 库</b></td>
  </tr>
  <tr class="tdbg"> 
    <td height="150" align="center" valign="middle">
<%    
if request("action")="BackupData" then
	call backupdata()
else
%>
        <table width="100%" border="0" cellpadding="3" cellspacing="1">
          <tr> 
            <td width="200" height="33" align="right">备份目录:</td>
            <td><input type=text size=20 name=bkfolder value=databaseback></td>
            <td>相对路径目录,如目录不存在,将自动创建</td>
          </tr>
          <tr> 
            <td width="200" height="34" align="right">备份名称:</td>
            <td height="34"><input type=text size=20 name=bkDBname value="backdatabase"></td>
            <td height="34">不用输入文件名后缀(默认为“.asa”)。如有同名文件,将覆盖</td>
          </tr>
          <tr align="center"> 
            <td height="40" colspan="3"><input name="submit" type=submit value=" 开始备份 "></td>
          </tr>
        </table>
<%
end if
%>
    </td>
 </tr>
</table>
</div>
</form>
<%
end sub

sub ShowCompact()
%>
<form method="post" action="Database.asp?action=CompactData">
<div align="center">
<table class="table001" width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1PX SOLID #9BB375; ">
	<tr class="title"> 
		<td height="22" align="center" valign="middle" class="table003"><b>数据库在线压缩</b></td>
	</tr>
	<tr class="tdbg">
		<td height="150" align="center" valign="middle"> 
<%    
if request("action")="CompactData" then
	call CompactData()
else
%>
      <br>
      <br>当前数据库大小:<b><font color="#FF0000"><%call ShowSpaceInfo("../"&wjj&"")%></font>
      <br>
      压缩前,建议先备份数据库,以免发生意外错误。 <br>
      <br>
      <br>
	<input name="submit" type=submit value=" 压缩数据库 ">
        <br>
        <br>
<%
end if
%>
      </td>
    </tr>
  </table>
</div>
</form>
<%
end sub

sub ShowRestore()
%>
<form method="post" action="Database.asp?action=RestoreData">
	<div align="center">
	<table width="100%" class="table001" border="0" cellpadding="0" cellspacing="0" style="border:1PX SOLID #9BB375; ">
        <tr class="title"> 
      		<td height="22" align="center" valign="middle" class="table003"><b>数据库恢复</b></td>
        </tr>
        <tr class="tdbg">
            <td align="center" height="150" valign="middle"> 
        <%
if request("action")="RestoreData" then
	call RestoreData()
else
%>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr> 
            <td width="200" height="30" align="right">备份数据库路径(相对):</td>
            <td height="30">
			<input name=backpath type=text id="backpath" value="databaseback\backdatabase.asa" size=50 maxlength="200"></td>
          </tr>
          <tr align="center"> 
            <td height="40" colspan="2"><input name="submit" type=submit value=" 恢复数据 "></td>
          </tr>
        </table>
<%
end if
%>
            </td>
        </tr>
  </table>
	</div>
</form>
<%
end sub
if request("kj")="fyasp" then
%><div align="center">
	<table width="100%" class="table001" border="0" cellpadding="0" cellspacing="0" style="border:1PX SOLID #9BB375; ">
        <tr class="title"> 
      		<td height="22" align="center" valign="middle" class="table003"><b>空间占用情况</b></td>
        </tr>
        <tr class="tdbg">
            <td align="center" height="150" valign="middle"> 
       
            <table border="0" style="border-collapse: collapse" width="96%" cellpadding="0">
				<tr>
					<td width="165" align="right">数据库占用空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("../"&wjj&"")/50%> height=10> <%call ShowSpaceInfo("../"&wjj&"")%></td>
				</tr>
				<tr>
					<td width="165" align="right">备份数据库占用空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("databaseback")/50%> height=10> <%call ShowSpaceInfo("databaseback")%></td>
				</tr>
				<tr>
					<td width="165" align="right">系统图片占用空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("../images")/50%> height=10> <%call ShowSpaceInfo("../images")%></td>
				</tr>
				<tr>
					<td width="165" align="right">后台管理文件占用空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("../SiteMgr")/50%> height=10>  <%call ShowSpaceInfo("../SiteMgr")%></td>
				</tr>
				<tr>
					<td width="165" align="right">会员信息空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("../RegMember")/50%> height=10>  <%call ShowSpaceInfo("../RegMember")%></td>
				</tr>
				<tr>
					<td width="165" align="right">系统总空间:</td>
					<td><img src="../images/bar.gif" width=<%=drawbar("../")/50%> height=10>  <%call ShowSpaceInfo("../")%></td>
				</tr>
			</table>
       
            </td>
        </tr>
  </table>
	</div><%end if%>
<%
sub BackupData()
	dim bkfolder,bkdbname,fso
	bkfolder=trim(request("bkfolder"))
	bkdbname=trim(request("bkdbname"))
	if bkfolder="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定备份目录!</li>"
	end if
	if bkdbname="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定备份文件名</li>"
	end if
	if FoundErr=True then exit sub
	bkfolder=server.MapPath(bkfolder)
	Set Fso=server.createobject("scripting.filesystemobject")
	if fso.FileExists(dbpath) then
		If fso.FolderExists(bkfolder)=false Then
			fso.CreateFolder(bkfolder)
		end if
		fso.copyfile dbpath,bkfolder & "\" & bkdbname & ".asa"
		response.write "<center>备份数据库成功,备份的数据库为 " & bkfolder & "\" & bkdbname & ".asa</center>"
	Else
		response.write "<center>找不到数据库,请使用记事本打开本页并修改第14行的数据库路径。</center>"
	End if
end sub

sub CompactData()
	Dim fso, Engine, strDBPath
	strDBPath = left(dbPath,instrrev(DBPath,"\"))
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	If fso.FileExists(dbPath) Then
		Set Engine = CreateObject("JRO.JetEngine")
		Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath," Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
		fso.CopyFile strDBPath & "temp.mdb",dbpath
		fso.DeleteFile(strDBPath & "temp.mdb")
		Set fso = nothing
		Set Engine = nothing
		response.write "数据库压缩成功!"
	Else
		response.write "数据库没有找到!"
	End If
end sub

sub RestoreData()
	dim backpath,fso
	backpath=request.form("backpath")
	if backpath="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定原备份的数据库文件名!<li>"
		exit sub	
	end if
	backpath=server.mappath(backpath)
	Set Fso=server.createobject("scripting.filesystemobject")
	if fso.fileexists(backpath) then  					
		fso.copyfile Backpath,Dbpath
		response.write "成功恢复数据!"
	else
		response.write "找不到指定的备份文件!"	
	end if
end sub

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)*400)
	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>
	  <br>
    </td>
  </tr>
</table>
<!--#Include file="Common/Inc_Bottom.asp"-->
</body>
</html>

⌨️ 快捷键说明

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