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

📄 database.asp

📁 C2C二手交易网SMRUC v2.0 全部实现了C2C电子商务功能。 特别适合高校、组织、社区实现自己的C2C电子商务。 C2C二手交易网SMRUC v2.0具有强大的用户自主发布和管理信息功能
💻 ASP
字号:
<%
if session("admin_name")="" then
    response.write "<script LANGUAGE='javascript'>alert('对不起,登陆超时!');</script>"
	response.end
end if
%>
<!--#include file="conn.asp"-->
<%
dim message1,message2,message3,message4
dbpath=server.mappath(db)
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")

action=request("action")
if action="backup" then
call BackupData()
end if

if action="restore" then
call RestoreData()
end if

if action="Compact" then
call CompactData()
end if

if action="clear" then
call clearData()
end if
%>
<html>
<head>
<link href=../css.css rel=STYLESHEET type=text/css>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>中国人民大学二手交易网--网站统计信息</title></head>

<body>
<div align="center">
  <table width="669" border="0" cellpadding="0" cellspacing="0" >
    <!--DWLayoutTable-->
    <tr> 
      <td width="40" height="23">&nbsp;</td>
      <td width="606">&nbsp;</td>
      <td width="23">&nbsp;</td>
    </tr>
    <tr> 
      <td height="191">&nbsp;</td>
      <td valign="top"><table width="100%" border="0" cellpadding="1" cellspacing="1"  bgcolor="#66CCFF">
          <!--DWLayoutTable-->
          <tr> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF"> <div align="center"><strong>数据库管理</strong>--系统空间占用情况</div></td>
          </tr>
          <TR> 
            <td width="160" height="20" valign="middle" bgcolor="#FFFFFF" >数据库占用空间</td>
            <td width="435"  valign="middle" bgcolor="#FFFFFF" ><img src="../images/bar.gif" width=<%=drawbar("../datum")%> height=10> 
              <%showSpaceinfo("../datum")%>
            </td>
          </TR>
          <TR> 
            <td width="160" height="20"  valign="middle" bgcolor="#FFFFFF" >备份数据占用空间</td>
            <td width="435"  valign="middle" bgcolor="#FFFFFF" ><img src="../images/bar.gif" width=<%=drawbar("../databackup")%> height=10> 
              <%showSpaceinfo("../databackup")%>
            </td>
          </TR>
          <TR> 
            <td width="160" height="20"  valign="middle" bgcolor="#FFFFFF" >上传图片占用空间</td>
            <td width="435"  valign="middle" bgcolor="#FFFFFF" ><img src="../images/bar.gif" width=<%=drawbar("../pic")%> height=10> 
              <%showSpaceinfo("../pic")%>
            </td>
          </TR>
          <TR> 
            <td width="160" height="20"  valign="middle" bgcolor="#FFFFFF" >程序文件占用空间</td>
            <td width="435"  valign="middle" bgcolor="#FFFFFF" ><img src="../images/bar.gif" width=<%=drawspecialbar%> height=10> 
              <%showSpecialSpaceinfo("Program")%>
            </td>
          </TR>
          <TR> 
            <td width="160" height="20"  valign="middle" bgcolor="#FFFFFF" >系统占用空间总计</td>
            <td width="435"  valign="middle" bgcolor="#FFFFFF" ><img src="../images/bar.gif" width=400 height=10> 
              <%showspecialspaceinfo("All")%>
            </td>
          </TR>
          <tr> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF"> <div align="center"><strong>数据库管理</strong>--数据库备份</div></td>
          </tr>
          <form method="post" action="database.asp?action=backup">
            <TR> 
              <td height="20" align="center" valign="middle" bgcolor="#FFFFFF" >备份目录</td>
              <td height="20" valign="middle" bgcolor="#FFFFFF" ><input type="text" name="bkfolder" value="../databackup"></td>
            </TR>
            <TR> 
              <td height="23" align="center" valign="middle" bgcolor="#FFFFFF" >备份名称</td>
              <td height="23" valign="middle" bgcolor="#FFFFFF" > <input type="text" name="bkDBname" value="<%=date()%>">
                不用输入文件后缀名(默认.asa)</td>
            </TR>
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><input type="submit" name="Submit" value="开始备份" <%If ObjInstalled=false Then response.Write "disabled"%>></td>
            </TR>
          </form>
          <TR> 
            <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><b><font color=red><%=message1%></font> 
              <%
	If ObjInstalled=false Then
		Response.Write "你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能"
	end if%>
              </b></td>
          </TR>
          <tr> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF"> <div align="center"><strong>数据库管理</strong>--数据库恢复</div></td>
          </tr>
          <form method="post" action="database.asp?action=restore">
            <TR> 
              <td width="160" height="20" align="center" valign="middle" bgcolor="#FFFFFF" >备份数据库路径</td>
              <td width="435" valign="middle" bgcolor="#FFFFFF" ><input name="backpath" type="text" size="40" value="../databackup/secondhand.mdb">
                *填写相对路径</td>
            </TR>
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><input type="submit" name="Submit2" value="恢复数据" <%If ObjInstalled=false Then response.Write "disabled"%>></td>
            </TR>
          </form>
          <TR> 
            <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><b><font color=red><%=message2%></font> 
              <%
	If ObjInstalled=false Then
		Response.Write "你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能"
	end if%>
              </b></td>
          </TR>
          <tr> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF"> <div align="center"><strong>数据库管理</strong>--数据库压缩</div></td>
          </tr>
          <form method="post" action="database.asp?action=Compact">
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" >压缩前,建议先备份数据库,以免发生意外错误。</td>
            </TR>
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><input type="submit" name="Submit2" value="压缩数据库" <%If ObjInstalled=false Then response.Write "disabled"%>></td>
            </TR>
          </form>
          <TR> 
            <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><b><font color=red><%=message3%></font> 
              <%
	If ObjInstalled=false Then
		Response.Write "你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能"
	end if%>
              </b></td>
          </TR>
		  <tr> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF"> <div align="center"><strong>数据库管理</strong>--系统还原初始状态</div></td>
          </tr>
          <form method="post" action="database.asp?action=clear"  onSubmit="return confirm('确实要还原数据库吗?一旦清除将无法恢复!');">
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" >请慎用此功能,因为一旦清除将无法恢复!</td>
            </TR>
            <TR> 
              <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><input type="submit" name="Submit2" value="系统还原"></td>
            </TR>
          </form>
          <TR> 
            <td height="20" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF" ><b><font color=red><%=message4%></font></b></td>
          </TR>
          <TR> 
            <td height="24" colspan="2" valign="middle" bgcolor="#00FFFF" > <div align="center">版权所有:中国人民大学二手交易网</div></td>
          </TR>
        </table></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td height="59">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
<%
Function Drawbar(drvpath)
	dim fso,drvpathroot,d,size,totalsize,barsize
	set fso=server.createobject("scripting.filesystemobject")
	drvpathroot=server.mappath("../admin")
	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
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
Function Drawspecialbar()
	dim fso,drvpathroot,d,fc,f1,size,totalsize,barsize
	set fso=server.createobject("scripting.filesystemobject")
	drvpathroot=server.mappath("../admin")
	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
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
sub BackupData()
	dim bkfolder,bkdbname,fso
	bkfolder=trim(request("bkfolder"))
	bkdbname=trim(request("bkdbname"))
	if bkdbname="" then
		FoundErr=True
		message1="请指定备份文件名"
	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"
		message1="备份数据库成功,备份的数据库为 " & bkfolder & "\" & bkdbname & ".asa"
	Else
		message1="找不到源数据库文件,请检查inc/conn.asp中的配置。"
	End if
end sub
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 RestoreData()
	dim backpath,fso
	backpath=request.form("backpath")
	if backpath="" then
		FoundErr=True
		message2="请指定原备份的数据库文件名!"
		exit sub	
	end if
	backpath=server.mappath(backpath)
	Set Fso=server.createobject("scripting.filesystemobject")
	if fso.fileexists(backpath) then  					
		fso.copyfile Backpath,Dbpath
		message2="成功恢复数据!"
	else
		message2="找不到指定的备份文件!"	
	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
		message3="数据库压缩成功!"
	Else
		message3="数据库没有找到!"
	End If
end sub
sub clearData()
conn.execute("delete From bclass")
conn.execute("delete From sclass")
conn.execute("delete From info")
conn.execute("delete From guest")
conn.execute("delete From [note]")
conn.execute("delete From notice")
conn.execute("delete From onlinecount")
conn.execute("delete From piece")
conn.execute("delete From [user]")
conn.execute("update config set user_count=0,check_count=0,info_count=0,piece_count=0,webconfig_allowip1='0.0.0.0',webconfig_allowip2='255.255.255.255',webconfig_userday=60")
conn.execute("update logincount set logincount=0")
conn.execute("insert into bclass(bclass_name) values('测试类')")
message4="系统已还原到初始状态~!"
end sub	 
%>
</body>

</html>

⌨️ 快捷键说明

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