📄 data.asp
字号:
<!--#include file = "../inc/dbclass.inc.asp"-->
<!--#include file = "../inc/syslogincheck.inc.asp" -->
<%
' =============================================================
' made by xiasp & 智多网络 http://www.cq70.com/ qq群:12403617
' =============================================================
%>
<%
sub backupdata()
' on error resume next
dim fileconnstr, fileconn, b_dbpath, b_bkpath, b_filename
b_dbpath = request.form("b_dbpath")
b_dbpath = server.mappath(b_dbpath)
b_bkpath = request.form("b_bkpath")
b_bkpath = server.mappath(b_bkpath)
b_filename = request.form("b_filename")
fileconnstr = "provider = microsoft.jet.oledb.4.0;data source = " & b_dbpath
set fileconn = server.createobject("adodb.connection")
fileconn.open fileconnstr
if err then
response.write err.description
err.clear
set fileconn = nothing
call alertmsg("备份的文件并非合法的数据库。")
exit sub
else
set fileconn = nothing
end if
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(b_dbpath) then
if checkdir(b_bkpath) = true then
fso.copyfile b_dbpath,b_bkpath& "\"& b_filename
else
makenewsdir(b_bkpath)
fso.copyfile b_dbpath,b_bkpath& "\"& b_filename
end if
call alertmsg("备份数据库成功,您备份的数据库路径为" & b_bkpath & "\"& b_filename &"")
else
call alertmsg("找不到您所需要备份的文件。。")
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
'=====================压缩参数=========================
function compressdata()
dim fso, engine, strdbpath, jet_3x, dbpath
dbpath = trim(request.form("y_dbpath"))
dbpath = server.mappath(dbpath)
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")
engine.compactdatabase "provider=microsoft.jet.oledb.4.0;data source=" & strdbpath & "temp.mdb", _
"provider=microsoft.jet.oledb.4.0;data source=" & strdbpath & "temp1.mdb"
fso.copyfile strdbpath & "temp1.mdb",dbpath
fso.deletefile(strdbpath & "temp.mdb")
fso.deletefile(strdbpath & "temp1.mdb")
set fso = nothing
set engine = nothing
call alertmsg("你的数据库"&dbpath&"已经压缩成功!")
else
call alertmsg("数据库名称或路径不正确,请重新操作!")
end if
end function
%>
<%
dim fso,fso1, action, h_level
action = getsafestr(trim(request("action")))
h_level = session("sys_level")
select case action
case "compressdata" '压缩数据
if h_level <> 3 then
call alertmsg("您的权限不够进行此操作!")
else
call compressdata()
end if
case "backupdata" '备份数据
if h_level <> 3 then
call alertmsg("您的权限不够进行此操作!")
else
call backupdata()
end if
case "restoredata" '恢复数据
if h_level <> 3 then
call alertmsg("您的权限不够进行此操作!")
else
dim h_dbpath, h_backpath
h_dbpath = request.form("h_dbpath")
h_backpath = request.form("h_backpath")
if h_dbpath = "" then
call alertmsg("请输入您要恢复成的数据库全名!")
else
h_dbpath = server.mappath(h_dbpath)
end if
h_backpath = server.mappath(h_backpath)
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(h_backpath) then
fso.copyfile h_backpath,h_dbpath
call alertmsg("成功恢复数据!")
else
call alertmsg("备份目录下并无您的备份文件!")
end if
end if
end select
'====================恢复数据库=========================
call header("数据库操作处理")
call content()
call footer()
' 开始写入内容
sub content()
%>
<!--#include file="admin_index_top.asp" -->
<br>
<%'====================恢复数据库=========================%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25"><b>
<% = homepage_title%> - <font color="#ff0000">数据库操作</font></b></td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="3" align=center width="98%">
<tr>
<td bgcolor="#aabfec" ><b>恢复系统数据 </b>(所有路径都是相对与程序空间根目录的相对路径)</td>
</tr>
<form method="post" action="data.asp?action=restoredata">
<tr>
<td> 备份数据库路径(绝对路径):
<input name=h_backpath type=text id="h_backpath" value="<%=rooturl%>/databackup/cq70_news.asp" size=30 class="button1"> </td>
</tr>
<tr>
<td>目标数据库路径(绝对路径):
<input name=h_dbpath type=text id="h_dbpath" value="<%=datebase%>" size=30 class="button1">
<input name="submit" type=submit value="恢复数据" class="button2"></td>
</tr>
<tr>
<td>-----------------------------------------------------------------------------------------<br>
<b>注意:</b>在上面填写本程序的数据库路径全名,本程序的默认备份数据库文件为“databackup\cq70_news.asp”,请按照您的备份文件自行修改。<br>
您可以用这个功能来备份您的法规数据,以保证您的数据安全!</td>
</tr>
</form>
</table>
<%'====================备份数据库=========================%>
<table border="0" cellspacing="1" cellpadding="3" align=center width="98%">
<tr>
<td bgcolor="#aabfec"> <b>备份论坛数据 </b>(所有路径都是相对与程序空间根目录的相对路径)</td>
</tr>
<form method="post" action="data.asp?action=backupdata">
<tr>
<td> 当前数据库路径(绝对路径):
<input name="b_dbpath" type=text id="b_dbpath" value="<%=datebase%>" size=26 class="button1"></td>
</tr>
<tr>
<td>备份数据库目录(绝对路径):
<input name="b_bkpath" type=text id="b_bkpath" value="<%=rooturl%>/databackup" size=26 class="button1"></td>
</tr>
<tr>
<td>备份数据库名称(填写名称):
<input name="b_filename" type=text id="b_filename" value="cq70_news.asp" size=26 class="button1">
<input name="submit2" type=submit value="确定备份" class="button2"></td>
</tr>
<tr>
<td>-----------------------------------------------------------------------------------------<br>
<b>注意:</b>您可以用这个功能来备份您的法规数据,以保证您的数据安全!如备份目录不存在,程序将自动创建;如备份目录有该数据库文件,将覆盖,如没有,将自动创建。在上面填写本程序的数据库路径全名,本程序的默认数据库文件为“data\cq70_news.asp”,<font color="#ff0000">请不要用默认名称命名备份数据库。</font></td>
</tr>
</form>
</table>
<%'====================压缩数据库 =========================%>
<table border="0" cellspacing="1" cellpadding="3" align=center width="98%">
<form action="data.asp?action=compressdata" method="post">
<tr>
<td bgcolor="#aabfec" ><b>压缩系统数据 </b>(所有路径都是相对与程序空间根目录的相对路径)</td>
</tr>
<tr>
<td>压缩数据库:
<input name="y_dbpath" type="text" id="y_dbpath" value="<%=rooturl%>/databackup/cq70_news.asp" size="38" class="button1">
<input name="submit3" type="submit" value="开始压缩" class="button2"></td>
</tr>
<tr>
<td><b>注意:</b>输入数据库所在相对路径,并且输入数据库名称。(本系统采用 access 2000 数据库)</td>
</tr>
</form>
<form>
</form>
</table>
<p> </p>
<%
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -