<%
'程序名称：千纸鹤网站管理系统
'程序作者：千纸鹤
'作者邮箱：qzhxxw@sina.com
'作者 Q Q：138999501
'作者电话：0000000000
'官方主页：http://www.qqzzhh.com/
'官方论坛：http://www.qqzzhh.com/bbs
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/set.asp"-->
<!--#include file="inc/dll.asp"-->
<%
call hacker()
if session("superlogin")<>yecao then
response.Write "<script>alert('您还没有登陆！');this.location.href='index.asp';</script>"
Response.End
end if
if session("superadmin")<>"admin" then
response.Write "<script>alert('\n错误提示：您的权限不足！\n\n您不是超级管理员！');this.location.href='index.asp';</script>"
Response.End
end if%>
<LINK  href="img/admin.css" type=text/css rel=stylesheet>
<%
select case request("action")
case "resetdata"
call resetdata()
case "deldata"
call deldata()
case "godata"
call godata()
case "backdata"
if request("act")="Backup" then
call updata()
else		
call backdata()
end if
case "redata"
if request("act")="data" then
dim Dbpath,backpath,fso
			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%>
<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" rules=none class=3d>
<tr><td class=title   height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;成功恢复！</B></td></tr>
<tr height=100 class=bg><td align="center">您的数据库已经成功恢复!请到首页进行调式！ </td></tr></table>
<%else%>
<table width="98%" align="center" border="1" cellspacing="0" cellpadding="2" bordercolor=<%=border%>>
<tr><td class=title align="center"  height=30>错误提示！</td></tr>
<tr height=100><td align="center">备份目录下并无您的备份文件！ </td></tr></table>
<%end if
else
call redata()
end if
end select
%>
<%
'====================压缩数据库 =========================
sub godata()
%>
<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>
<form action="Admin_data.asp?action=godata" method="post">
<tr>
<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;压缩数据库</b></td>
</tr>
<tr>
<td  height=30>&nbsp;数据库文件：<input type="text" name="dbpath" value="<%=ACCESSPATH%>" class=yecao>&nbsp;
<input type="checkbox" name="boolIs97" value="True">如果使用 Access 97 数据库请选择
(默认为 Access 2000 数据库)
</td>
</tr><tr><td class="hr"></td></tr>
<tr>
<td class="bg" height=30 align=center>
<input type="submit" value="压 缩" class=adminbutton>
</td>
</tr>
<form>
</table>
<br>
<%
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
	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%>
<table border="1"  cellspacing="1" cellpadding="2" bordercolor=<%=border%>  width=100% class=3d>
<tr>
<td class="bg" height=30 align=center>
<%
CompactDB = "你的数据库【" & dbpath & "】已经压缩成功!" & vbCrLf
%>
<%Else%>
数据库名称或路径不正确. 请重试! 
<%End If
End Function
%>
</td>
</tr>
</table>
<%sub backdata()%>
<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>
<tr>
<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份数据库</b></td>
</tr>
<form method="post" action="Admin_data.asp?action=backdata&act=Backup">
<tr><td height=25 class=bg>
&nbsp;当前数据库路径(相对路径)：<input type=text size=25 class=yecao name=DBpath value="<%=ACCESSPATH%>"></td></tr>
<tr><td height=25>
&nbsp;备份数据库目录(相对路径)：<input type=text size=25 class=yecao name=bkfolder value="backdata">
&nbsp;如目录不存在，程序将自动创建</td></tr>
<tr><td height=25>
&nbsp;备份数据库名称(填写名称)：<input type=text size=25 class=yecao name=bkDBname value=yecao.mdb>
&nbsp;如备份目录有该文件，将覆盖，如没有，将自动创建</td></tr><tr><td class="hr"></td></tr>
<tr><td height=30 class=bg align=center>
&nbsp;<input type=submit value="备 份" class=adminbutton></td></tr></form></table>
<%end sub
sub updata()
        dim Dbpath,bkfolder,bkdbname,fso
		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%>
<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=border%> class=3d>
<tr><td class=title height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份成功！</b></td></tr>
<tr height=100 class=bg><td align="center"> 
恭喜恭喜！<br>
备份数据库成功，您备份的数据库路径为<%=bkfolder%>\<%=bkdbname%>
</td></tr></table>
<%Else%>
<table width="100%" align="center" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=border%> class=3d>
<tr><td class=title height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;备份失败！</b></td></tr>
<tr height=100 class=bg><td align="center"> 
找不到您所需要备份的文件! 
</td></tr></table>
<%End if
end sub
'------------------检查某一目录是否存在-------------------
Function CheckDir(FolderPath)
    dim fso1
	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,fso1
    Set fso1 = CreateObject("Scripting.FileSystemObject")
        Set f = fso1.CreateFolder(foldername)
        MakeNewsDir = True
    Set fso1 = nothing
End Function
%>
<%
'====================恢复数据库=========================
sub redata()
%>
<table border="1"  cellspacing="0" cellpadding="0" bordercolor=<%=border%> rules=none  width=100% class=3d>
<tr>
<td class="title" height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;恢复数据库</b>
</td></tr>
<form method="post" action="ADMIN_data.asp?action=redata&act=data">
<tr><td height=25>
&nbsp;备份数据库路径(相对)：<input type=text size=40 name=DBpath value="<%=BACKACCESSPATH%>" class=yecao></td></tr>
<tr><td height=25>
&nbsp;目标数据库路径(相对)：<input type=text size=40 name=backpath value="<%=ACCESSPATH%>" class=yecao></td></tr><tr><td class="hr"></td></tr>
<tr><td height=30 align=center class=bg>
&nbsp;<input type=submit value="恢 复" class=adminbutton>
</td></tr></form></table>
<%end sub
sub resetdata%>

<table width="500" align="center" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=border%> class=3d>
<tr><td class=title height=22><b>&nbsp;<img src=img/ie.gif border=0 width=15 height=15 align=absMiddle>&nbsp;系统初始化</b></td></tr>
<tr height=100 class=bg><td> 


<form action="Admin_data.asp?action=deldata" method="post" name="form1" id="form1" onSubmit="return confirm('确实要清除选定的表吗？一旦清除将无法恢复！');">

&emsp;&emsp;<input name="newsclass" type="checkbox" id="newsclass" value="yes">新闻分类
<input name="artclass" type="checkbox" id="artclass" value="yes">文章分类
<input name="downclass" type="checkbox" id="downclass" value="yes">下载分类
<input name="picclass" type="checkbox" id="picclass" value="yes">图片分类
<input name="djclass" type="checkbox" id="djclass" value="yes">娱乐分类<br>

&emsp;&emsp;<input name="news" type="checkbox" id="news" value="yes">所有新闻
<input name="art" type="checkbox" id="art" value="yes">所有文章
<input name="down" type="checkbox" id="down" value="yes">所有下载
<input name="pic" type="checkbox" id="pic" value="yes">所有图片
<input name="dj" type="checkbox" id="dj" value="yes">所有娱乐<br>

&emsp;&emsp;<input name="link" type="checkbox" id="link" value="yes">友情连接
<input name="book" type="checkbox" id="book" value="yes">游客留言
<input name="pl" type="checkbox" id="pl" value="yes">所有评论
<input name="sms" type="checkbox" id="sms" value="yes">所有短信
<input name="gg" type="checkbox" id="gg" value="yes">所有公告<br><br>
<center>
<input type="submit" name="Submit" value="清除数据" class=button></center><br><br>
</form></td></tr></table>
<%end sub
sub delData()
dim z
z=0
if request("newsclass")="yes" then
conn.execute("delete From YC_newsclass")
response.write "成功清除了所有新闻栏目！<br>"
z=z+1
end if
if request("news")="yes" then
conn.execute("delete from YC_news")
response.write "成功清除了所有新闻！<br>"
z=z+1
end if
if request("artclass")="yes" then
conn.execute("delete From YC_artclass")
response.write "成功清除了所有文章栏目！<br>"
z=z+1
end if
if request("art")="yes" then
conn.execute("delete from YC_art")
response.write "成功清除了所有文章！<br>"
z=z+1
end if
if request("djclass")="yes" then
conn.execute("delete from YC_djclass")
response.write "成功清除了所有娱乐栏目!<br>"
z=z+1
end if
if request("dj")="yes" then
conn.execute("delete from YC_dj")
response.write "成功清除了所有文章评论！<br>"
z=z+1
end if
if request("downclass")="yes" then
conn.execute("delete From YC_downclass")
response.write "成功清除了所有软件栏目！<br>"
z=z+1
end if
if request("down")="yes" then
conn.execute("delete from YC_down")
response.write "成功清除了所有软件！<br>"
z=z+1
end if
if request("piclass")="yes" then
conn.execute("delete from YC_picclass")
response.write "成功清除了所有图片栏目！<br>"
z=z+1
end if
if request("pic")="yes" then
conn.execute("delete From YC_pic")
response.write "成功清除了所有图片！<br>"
z=z+1
end if
if request("shopclass")="yes" then
conn.execute("delete from YC_shopclass")
response.write "成功清除了所有产品栏目！ <br>"
z=z+1
end if
if request("shop")="yes" then
conn.execute("delete from YC_shop")
response.write "成功清除了所有产品！<br>"
z=z+1
end if
if request("book")="yes" then
conn.execute("delete from YC_book")
response.write "成功清除了所有留言！<br>"
z=z+1
end if
if request("link")="yes" then
conn.execute("delete from YC_link")
response.write "成功清除了所有连接！<br>"
z=z+1
end if
if request("pl")="yes" then
conn.execute("delete from YC_pl")
response.write "成功清除了所有评论！<br>"
z=z+1
end if
if request("sms")="yes" then
conn.execute("delete from YC_sms")
response.write "成功清除了所有短信！<br>"
z=z+1
end if
if request("gg")="yes" then
conn.execute("delete from YC_gg")
response.write "成功清除了所有频道！<br>"
z=z+1
end if
if z>0 then
response.write cstr(z) & "个数据库被清空，你可以开始添加新内容。"
else
response.write "你没有选择任何数据库，0个数据库被清空。"
end if
end sub
call closedata()%>
