<%@ LANGUAGE=VBScript codepage ="936" %>
<!-- #include file="setup.asp" -->
<%Response.Expires=0
Response.Buffer=true
cwjh_name=Session("cwjh_name")
cwjh_grade=Session("cwjh_grade")
cwjh_jhdj=Session("cwjh_jhdj")
if cwjh_name="" then Response.Redirect "../error.asp?id=440"
if session("cwjh_adminok")<>true then Response.end
if cwjh_grade<>10 or instr(Application("cwjh_admin"),cwjh_name)=0  then Response.Redirect "../error.asp?id=439"
%>
<html>
<head>
<title>论坛管理菜单</title>
<meta http-equiv="Content-Type" content="text/html;" charset="gb2312">
<link href="images/bbs.css" rel="stylesheet">
</head>
<script>function checkclick(msg){if(confirm(msg)){event.returnValue=true;}else{event.returnValue=false;}}</script>
<body text="000000" vLink="800080" aLink="ff0000" link="0000ff" background="images/bei.gif" topMargin="0">
<center><br>
<table borderColor="B7C6E1" cellSpacing="0" cellPadding="0" width="90%" border="1" height="90%" style="border-collapse:collapse">
<tr>
<td vAlign="top" width="19%" bgColor="ffffff" align="center">
<table borderColor="A4B6D7" height="19" cellPadding="6" width="100%" border="1" cellspacing="0" style="border-collapse:" collapse>
<tr>
<td align="middle" bgColor="A4B6D7" height="25" bordercolor="A4B6D7">
<font color="#FFFFFF"><b>江湖社区</b></font></td>
</tr>
</table>
<p align="center"><select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
<option selected>论坛管理</option>
<option value="?menu=classs">管理类别</option>
<option value="?menu=bbsadd">新建版块</option>
<option value="?menu=bbslist">版块设置</option>
<option value="?menu=bbsmanage">贴子管理</option>
</select>
</p>
<p align="center"><select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}"> <option selected>设置管理</option>
<option value="?menu=link">友情链接</option>
<option value="?menu=upclubconfig">更新资料</option>
</select>
</p>
<p align="center"><select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}">
<option selected>其他操作</option>
<option value="?menu=log">操作记录</option>
</select>
</p>
</form>
<p align="center"><a href="index.asp">退出管理菜单</a></p>
</td>
<td vAlign="top" width="81%" bgColor="ffffff" rowspan="2">
<table borderColor="A4B6D7" cellPadding="6" width="100%" border="1" cellspacing="0" style="border-collapse:" collapse>
<tr>
<center>
<td align="middle" width="100%" bgColor="A4B6D7" height="25">
<font color="FFFFFF"><b><%
bbs_menu = Request.querystring("menu")
select case bbs_menu
case "userok"
userok
endhtml
case "userdel"
userdel
endhtml
case "userdeltopic"
userdeltopic
endhtml
case "classs"
classs
endhtml
case "classxiu"
classxiu
endhtml
case "bbsadd"
bbsadd
endhtml
case "bbsaddok"
bbsaddok
endhtml
case "bbsmanage"
bbsmanage
endhtml
case "bbslist"
bbslist
endhtml
case "bbsmanagexiu"
bbsmanagexiu
endhtml
case "bbsmanagexiuok"
bbsmanagexiuok
endhtml
case "log"
log
endhtml
case "upclubconfig"
upclubconfig
endhtml
case "upclubconfigok"
upclubconfigok
endhtml
case "link"
link
endhtml
case "linkok"
linkok
endhtml

case "clean"
conn.execute("delete * from [forum] where deltopic=1")
error2("已经清空回收站了！")
case "delforumok"
if cwjh_name<>Application("cwjh_user") then
error2("你不是官府十级掌门(江湖总站长)，没有权限使用这个功能。" )
end if

TimeLimit=Cint(request.form("TimeLimit"))
if TimeLimit="" then
error2("您没有选择日期！")
end if
conn.execute("delete * from [forum] where lasttime<#"&Format_D(now()-TimeLimit)&"# and goodtopic<>1")
writestr="为加快论坛运行速度已经将论坛"&request("TimeLimit")&"天没有用户回复的主题（精华帖子除外）删除了！"
call showchat("<font color=ff0000>【论坛管理】</font>" & writestr & "<font color=blue>[ " & nickname & " ]</font>")
error2(writestr)
case "delforumok2"
if cwjh_name<>Application("cwjh_user") then
error2("你不是官府十级掌门(江湖总站长)，没有权限使用这个功能。" )
end if

lastdata=Cint(request.form("lastdata"))
if lastdata="" then
error2("您没有填写日期！")
end if
if lastdata<30 then
error2("您必须输入一个大于3的数字！")
end if
conn.execute("delete * from [forum] where lasttime<#"&Format_D(now()-lastdata)&"# and goodtopic<>1")
writestr="为加快论坛运行速度已经将最后更新超过"&lastdata&"天的全部帖子（精华帖子除外）删除了！"
call showchat("<font color=ff0000>【论坛管理】</font>" & writestr & "<font color=blue>[ " & nickname & " ]</font>")
error2(writestr)
case "deltopicok"
conn.execute("delete * from [forum] where topic='"&Request.form("topic")&"'")
error2("已经将标题为 "&request("topic")&" 的帖子全部删除了！")
case "uniteok"
if Request("hbbs") = Request("ybbs") then
error2("不能选择相同论坛！")
end if
if cwjh_name<>Application("cwjh_user") then
error2("你不是官府十级掌门(江湖总站长)，没有权限使用这个功能。" )
end if
conn.execute("update [forum] set forumid="&Request("hbbs")&" where forumid="&Request("ybbs")&"")
conn.execute("update [reforum] set forumid="&Request("hbbs")&" where forumid="&Request("ybbs")&"")
error2("已经成功将2个论坛的资料合并了！")
case "bbsmanagedel"
conn.execute("delete * from [bbsconfig] where id="&Request("id")&"")
bbslist
endhtml
case "dellink"
conn.execute("delete * from [link] where id="&Request("id")&"")
link
endhtml
case "classdel"
id=Request("id")
	if id=3 then 
		error2("不充许删除ID3:[七门八派]类别")
	else   
                on error resume next
		conn.execute("delete * from [class] where id="&Request("id")&"")
                if err <> 0 then error2("这个类别已经有了贴子无法删除。")
	end if
classs
endhtml
case "classxiuok"
	classname=Request("classname")
	id=Request("id")
	if id=3 and classname<>"七门八派" then 
		error2("ID3:[七门八派] 是保留类别，不能改名。")
	else
		conn.execute("update [class] set classname='"&classname&"',id="&id&" where id="&Request("oldid")&"")
	end if
	classs
endhtml
case "classadd"
if Request("classname")="" then
error2("请填写类别名称")
end if
sql="select * from class"
rs.Open sql,Conn,1,3
rs.addnew
rs("id")=Request("id")
rs("classname")=Request("classname")
rs.update
rs.close
classs
endhtml
end select

sub userdeltopic
conn.execute("delete * from [forum] where username='"&Request("username")&"'")
conn.execute("delete * from [reforum] where username='"&Request("username")&"'")
sql="select * from log"
rs.Open sql,Conn,1,3
rs.addnew
rs("username")=""&Request.Cookies("username")&""
rs("ip")=""&userip&":"&Request.ServerVariables("REMOTE_PORT")&""
rs("windows")=Request.Servervariables("HTTP_USER_AGENT")
rs("remark")="删除<font color=red>"&Request("username")&"</font>的所有帖子"
rs("logtime")=now()
rs.update
rs.close
%>
删除成功</b></font></td>
</tr></table><br>已经将 <%=Request("username")%> 所有发表过的文章全部删除<br><br><a href=javascript:history.back()>返 回</a>
<%
end sub

sub classs
sql="select * from class"
rs.open sql,conn,1,1
do while not rs.eof
classlist=""+classlist+""&rs("id")&"."&rs("classname")&" | <a href=?menu=classxiu&id="&rs("id")&">修改分类</a> | <a href=?menu=classdel&id="&rs("id")&">删除分类</a><br>"
rs.movenext
loop
rs.close
%><form method="post" action="?menu=classadd">建立论坛类别</b></font></td>
</tr>
</table><BR>
类别名称：（例如：江湖论剑）<INPUT size=20 name=classname> 序号：<INPUT size=2 name=id readonly value=<%=conn.execute("Select count(*)from class")(0)+1%>>
<input type=submit value="建立">
<br><br>
<table width="90%">
<tr>
<td width="100%" align="left">
<%=classlist%>
</td>
</tr>
</table>
<%
end sub
sub classxiu
sql="select * from class where id="&Request("id")&""
rs.Open sql,Conn,1
%>
<form method="post" action="?menu=classxiuok">修改论坛类别</b></font></td>
</tr></table><BR><input type=hidden name=oldid value=<%=Request("id")%>>
类别名称：<INPUT size=20 name=classname value=<%=rs("classname")%>> 序号：<INPUT size=2 name=id value=<%=Request("id")%> readonly>
<input type=submit value="修改">
<%
rs.close
end sub
sub bbsadd
sql="select * from class"
rs.open sql,conn,1,1
do while not rs.eof
classlist=""+classlist+"<option value="&rs("id")&">"&rs("classname")&"</option>"
rs.movenext
loop
rs.close
%>
建立论坛资料</b></font></td>
</tr></table><br>
<fieldset style="WIDTH: 95%">
<legend>建立论坛资料</legend>
</center>
<form method="post" action="?menu=bbsaddok">
　论坛名称 <input size="10" name="bbsname"> 类别 <select name="classid">
<%=classlist%>
</select> 安全级别 <select name="b_pro">
<option value="0">禁止UBB</option>
<option value="1" selected>允许UBB</option>
<option value="2">允许贴图</option>
<option value="3">允许影视</option>
</select>
<br>
　论坛版主 <input size="30" name=moderated>2 多版主请用|分隔如：唯情|酷屋 必须是官府中人
<br>
　论坛介绍 <textarea rows="5" name="intro" cols="50"></textarea>
<br>
　访问密码 <input size="10" name="pass"> 如果此论坛为公开论坛，此项请不要填写
<br>　　　　　　　　　　　　 <input type="submit" value=" 建 立 " name="Submit"><br></form>
<%
end sub
sub bbsaddok
if Request("classid")="" then
error2("请先建立论坛类别")
end if
if Request("bbsname")="" then
error2("请输入论坛名称")
end if
moderated2="|"&replace(Request.form("moderated"),"||","|")&"|"
sql="select * from bbsconfig"
rs.Open sql,Conn,1,3
rs.addnew
rs("classid")=Request.form("classid")
rs("bbsname")=Request.form("bbsname")
rs("moderated")=replace(moderated2,"||","|")
rs("intro")=Request.form("intro")
rs("pass")=Request.form("pass")
rs("pro")=Request.form("b_pro")
rs.update
rs.close
%>
建立成功</b></font></td>
</tr></table><br><a target="_blank" href="forumdisplay.asp?forumid=<%=id%>"><%=Request("bbsname")%></a><br><br><a href=javascript:history.back()>返 回</a>
<%
end sub
sub bbsmanage
%>
论坛资料管理</b></font></td>
</tr></table><br>
数据库共有 <%=conn.execute("Select count(*)from forum")(0)%> 条主题<br>
<form method="post" action="?menu=delforumok">
<fieldset style=width:90%><legend>批量删除主题</legend>
删除 <select name=TimeLimit>
<option value="30">30</option>
<option value="60">60</option>
<option value="90">90</option>
</select> 天没有用户回复的主题（精华帖子除外）
<input type="submit" value="确定"></form>

<form method="post" action="?menu=delforumok2">
<fieldset style=width:90%><legend>批量删除删除</legend>
删除最后更新超过：<input size="2" name="lastdata" value="60"> 天的所有帖子（精华帖子除外）
<input type="submit" value="确定"></form>

<form method="post" action="?menu=deltopicok">
删除标题为： <input size="20" name="topic"> 的所有帖子 <input type="submit" value="确定"></form>
<form method="post" action="?menu=userdeltopic">
删除用户为： <input size="20" name="username"> 的所有帖子 <input type="submit" value="确定"></form>
<input type="button" value=" 清空回收站 " onclick=javascript:open('?menu=clean','_top','')>
<br><br>
</fieldset>


<form method="post" action="?menu=uniteok">
<fieldset style=width:90%><legend>合并论坛数据</legend>
将<br>
<select name="ybbs">
<%
sql="select * from bbsconfig"
rs.Open sql,Conn
do while not rs.eof
%>
<option value="<%=rs("id")%>">『<%=rs("bbsname")%>』</option>
<%
rs.movenext
loop
rs.close
%>
</select><br>
合并到<br>
<select name="hbbs">
<%
sql="select * from bbsconfig"
rs.Open sql,Conn
do while not rs.eof
%>
<option value="<%=rs("id")%>">『<%=rs("bbsname")%>』</option>
<%
rs.movenext
loop
rs.close
%>
</select>
<br><br>
<INPUT type=submit value=" 确 定 " name=submit><br><br>
</fieldset>
</form>
<%
end sub
sub bbslist
sql="select * from bbsconfig"
rs.open sql,conn,1,1
do while not rs.eof
classlist=""+classlist+"<tr><td width=350>"&rs("id")&".<a target=_blank href=forumdisplay.asp?forumid="&rs("id")&">"&rs("bbsname")&"</a> <font color=C0C0C0>（版主："&rs("moderated")&"）</font></td><td><a href=?menu=bbsmanagexiu&id="&rs("id")&">编辑论坛</a></td><td><a onclick=checkclick('您确定要删除该论坛的所有资料?') href=?menu=bbsmanagedel&id="&rs("id")&">删除论坛</a></td></tr>"
rs.movenext
loop
rs.close
%>
全部论坛列表</b></font></td>
</tr></table><br>
<table width="90%">
<%=classlist%>
</table>
<%
end sub
sub bbsmanagexiu
sql="select * from class"
rs.open sql,conn,1,1
do while not rs.eof
classlist=""+classlist+"<option value="&rs("id")&">"&rs("classname")&"</option>"
rs.movenext
loop
rs.close
sql="select * from bbsconfig where id="&Request("id")&""
rs.Open sql,Conn,1
%>
编辑论坛</b></font></td>
</tr></table><br>
<fieldset style="WIDTH: 95%">
<legend>编辑论坛资料</legend>
</center>
<form method="post" action="?menu=bbsmanagexiuok">
<input type=hidden name=id value=<%=rs("id")%>>
　论坛名称 <input size="10" name="bbsname" value="<%=rs("bbsname")%>"> 类别 <select name="classid">
<option value="<%=rs("classid")%>">默认</option>
<%=classlist%>
</select>

 安全级别 <select name="b_pro">
<option value="0">禁止UBB</option>
<option value="1" selected>允许UBB</option>
<option value="2">允许贴图</option>
<option value="3">允许影视</option>
</select><br>
　论坛版主 <input size="30" name=moderated value="<%=rs("moderated")%>"> 多版主请用|分隔如：唯情|酷屋 必须是官府中人
<br>
　论坛介绍 <textarea rows="5" name="intro" cols="50"><%=rs("intro")%></textarea>
<br>
　访问密码 <input size="10" name="pass" value="<%=rs("pass")%>"> 如果此论坛为公开论坛，此项请不要填写
<br>　　　　　　　　　　　　 <input type="submit" value=" 编 辑 " name="Submit"><br></form>
<%
end sub
sub bbsmanagexiuok
moderated2="|"&replace(Request.form("moderated"),"||","|")&"|"
sql="select * from bbsconfig where id="&Request("id")&""
rs.Open sql,Conn,1,3

rs("classid")=Request.form("classid")
rs("bbsname")=Request.form("bbsname")
rs("moderated")=replace(moderated2,"||","|")
rs("intro")=Request.form("intro")
rs("pass")=Request.form("pass")
rs("pro")=Request.form("b_pro")
rs.update

rs.close
%>
编辑成功</b></font></td>
</tr></table><br><a href=javascript:history.back()>返 回</a>
<%
end sub
sub upclubconfig
%>
社区资料更新</b></font></td>
</tr></table><br>
<fieldset style="WIDTH: 80%">
<legend>社区资料更新</legend>
此操作将更新论坛资料、用户资料<br>（防止论坛统计错误和用户类型显示不正确的情况发生）<br>
<a href="?menu=upclubconfigok">点击这里更新论坛统计数据</a><br>
</fieldset>
<%
end sub
sub upclubconfigok
sql="select * from bbsconfig"
rs.Open sql,Conn,1
do while not rs.eof
tmprs=conn.execute("Select count(forumid) from forum where forumid="&rs("id")&"")
allarticle=tmprs(0)
tmprs=conn.execute("Select count(forumid) from reforum where forumid="&rs("id")&"")
allrearticle=tmprs(0)
conn.execute("update [bbsconfig] set toltopic="&allarticle&",tolrestore="&allarticle+allrearticle&" where ID="&rs("id")&"")
rs.movenext
loop
rs.close
%>
社区资料更新</a></b></font></td>
</tr></table><br>
操作成功！<br>
<br>
已经更新社区所有论坛的统计数据<br>
<%
end sub
sub link
%>
友情链接管理</b></font></td>
</tr></table>
<FORM action=?menu=linkok method=post>
<TABLE cellSpacing=0 cellPadding=0 width="383" border=0>
<TBODY>
<TR>
<TD width="163">论坛名称： </TD>
<TD width="288"><INPUT size=40 name=name></TD></TR>
<tr>
<TD width="163">论坛URL： </TD>
<TD width="288"><INPUT size=40 name=url value="http://"> </TD>
</tr>
<TR>
<TD width="163">图标URL： </TD>
<TD width="288"><INPUT size=40 name=logo value="http://"> </TD></TR>
<TR>
<TD width="163" height=15>论坛简介： </TD>
<TD width="288" height=15><INPUT size=40 name=intro> </TD></TR>
<TR>
<TD colSpan=2 height=15 width="451">
<DIV align=center><INPUT type=submit value=" 添 加 " name=Submit>
<input type="reset" value=" 重 填 " name="Submit2">
</DIV></TD></TR></TBODY></TABLE></FORM>
<%
sql="select * from link"
rs.Open sql,Conn,1
do while not rs.eof
response.write "<a title='"&rs("name")&""&chr(10)&""&rs("intro")&"' href="&rs("url")&" target=_blank><img src="&rs("logo")&" border=0 width=88 height=31></a> <a href=?menu=dellink&id="&rs("id")&">删除</a>　　　"
rs.movenext
loop
rs.close
end sub
sub linkok
if Request("url")="http://" or Request("url")="" then
error2("论坛URL没有填写")
end if
sql="select * from link"
rs.Open sql,Conn,1,3
rs.addnew
rs("name")=Request("name")
rs("logo")=Request("logo")
rs("url")=Request("url")
rs("intro")=Request("intro")
rs.update
rs.close
link
end sub
sub log
%>
登陆操作纪录</b></font></td>
</tr></table><br>
<table cellpadding=0 cellspacing=0 width=100%>
<tr>
<td width=10% align="center">用户名</td>
<td width=20% align="center">IP</td>
<td width=40% align=center>操作项目</td>
<td width=20% align="center">登陆时间</td>
</tr>
<%
sql="select * from log order by logtime Desc"
rs.Open sql,Conn,1
do while not rs.eof
response.write "<tr><td align=center>"&rs("username")&"</td><td align=center>"&rs("ip")&"</td><td align=center>"&rs("remark")&"</td><td align=center>"&rs("logtime")&"</td></tr><tr><td align=center colspan=4>"&rs("windows")&"<br><br></td></tr>"
rs.movenext
loop
rs.close
response.write "</tr></table>"
end sub
sql="select * from log"
rs.Open sql,Conn,1,3
rs.addnew
rs("username")=nickname
rs("ip")=""&userip&":"&Request.ServerVariables("REMOTE_PORT")&""
rs("windows")=Request.Servervariables("HTTP_USER_AGENT")
rs("remark")="登陆论坛管理" & Request.ServerVariables("SCRIPT_NAME")
rs("logtime")=now()
rs.update
rs.close
conn.execute("delete * from [log] where logtime<#"&Format_D(now()-2)&"#")
%>
登陆管理</b></font>
</td></tr></tbody></table>
<br>
　</p>
<div align="center">
登陆成功</div>
<%
endhtml
sub endhtml
%>
</tr>
</table>
</body>
</html>
<%
Conn.close
set rs=nothing
set rs1=nothing
set conn=nothing
response.end
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
Function Format_D(v)
	n=Year(v)
	y=Fd2(Month(v))
	r=Fd2(Day(v))
	s=Fd2(Hour(v))
	f=Fd2(Minute(v))
	m=Fd2(Second(v))
	Format_D=n & "-" & y & "-" & r & " " & s & ":" & f & ":" & m
End Function

Function Fd2(t)
	if len(t)=1 then t="0" & t
	Fd2=t
End Function
%>
<!--#include file="../showchat.asp"-->