<!-- #include file="include/onlogin.asp" -->
<!-- #include file="include/conn.asp" -->
<%
dim admin_menu
admin_menu="<a href='?'>论坛管理</a> | " & _
	   "<a href='?action=mod'>合并论坛</a> | " & _
	   "<a href='?action=order'>重新排序</a> | " & _
	   "<a href='?action=js'>JS 生成</a>"
response.write header(11,admin_menu)
response.write admin_bar("论坛管理",1,"99%")
select case action
case "mod"
  call forum_mod()
case "order"
  call forum_order()
  call forum_main()
case "orderc"
  call forum_orderc()
  call forum_main()
case "orders"
  call forum_orders()
  call forum_main()
case "forum_add"
  call forum_add()
case "forum_edit"
  call forum_edit()
case "del_forum"
  call del_forum()
case "class_add"
  call class_add()
case "class_edit"
  call class_edit()
case "del_class"
  call del_class()
case "js"
  call fso_js()
case else
  call forum_main()
end select
response.write admin_bar("",2,"99%")
call close_conn()
'response.write ender()

sub forum_order_board(cid,fid,ff)
  dim rsboard,strsqlboard,forumid,fff,fj
  fff=ff:fj=1
  strsqlboard="select forum_id from bbs_forum where forum_f="&fid&" and class_id=" & cid & " order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id")
    conn.execute("update bbs_forum set forum_order="&fj&" where forum_id="&forumid)
    call forum_order_board(cid,forumid,ff+1)
    rsboard.movenext
    fj=fj+1
  loop
  conn.execute("update bbs_forum set forum_n="&fj-1&" where forum_id="&fid)
  rsboard.close:set rsboard=nothing
end sub

sub forum_order()
  dim rs,sql,i,cid:i=1
  conn.execute("update bbs_forum set forum_n=0")
  sql="select class_id from bbs_class order by class_order,class_id"
  set rs=conn.execute(sql)
  do while not rs.eof
    cid=rs(0)
    conn.execute("update bbs_class set class_order="&i&" where class_id="&cid)
    call forum_order_board(cid,0,0)
    rs.movenext
    i=i+1
  loop
  rs.close:set rs=nothing
end sub

sub forum_orders()
  dim fid,classid,forumid,actions,tmp_id_1,tmp_id_2,tmp_order_1,tmp_order_2,sqladd,update_ok,rssum
  classid=trim(request.querystring("class_id"))
  forumid=trim(request.querystring("forum_id"))
  fid=trim(request.querystring("fid"))
  actions=trim(request.querystring("actions"))
  if not(isnumeric(fid)) or not(isnumeric(classid)) or not(isnumeric(forumid)) or (actions<>"up" and actions<>"down") then exit sub
  update_ok="no":sqladd=""
  if actions="up" then sqladd=" desc"
  sql="select forum_order from bbs_forum where forum_id="&forumid&" and class_id="&classid
  set rs=conn.execute(sql)
  if rs.eof and rs.bof then rs.close:set rs=nothing:exit sub
  rs.close:set rs=nothing
  sql="select forum_id,forum_order from bbs_forum where forum_f="&fid&" and class_id="&classid&" order by forum_order"&sqladd&",forum_id desc"
  set rs=conn.execute(sql)
  do while not rs.eof
    if int(rs("forum_id"))=int(forumid) then
      tmp_id_1=forumid
      tmp_order_1=rs("forum_order")
      rs.movenext
      if not rs.eof then
        tmp_id_2=rs("forum_id")
        tmp_order_2=rs("forum_order")
        update_ok="yes"
        exit do
      end if
      exit do
    end if
    rs.movenext
  loop
  rs.close:set rs=nothing
  if update_ok="yes" then
    sql="update bbs_forum set forum_order="&tmp_order_2&" where forum_id="&tmp_id_1
    conn.execute(sql)
    sql="update bbs_forum set forum_order="&tmp_order_1&" where forum_id="&tmp_id_2
    conn.execute(sql)
  end if
end sub

sub forum_orderc()
  dim classid,actions
  classid=trim(request.querystring("class_id"))
  actions=trim(request.querystring("actions"))
  if not(isnumeric(classid)) or (actions<>"up" and actions<>"down") then exit sub
  dim tmp_id_1,tmp_id_2,tmp_order_1,tmp_order_2,sqladd,update_ok
  update_ok="no":sqladd=""
  if actions="up" then sqladd=" desc"
  sql="select * from bbs_class where class_id="&classid
  set rs=conn.execute(sql)
  if rs.eof and rs.bof then rs.close:set rs=nothing:exit sub
  rs.close:set rs=nothing
  sql="select * from bbs_class order by class_order"&sqladd
  set rs=conn.execute(sql)
  do while not rs.eof
    if int(rs("class_id"))=int(classid) then
      tmp_id_1=classid
      tmp_order_1=rs("class_order")
      rs.movenext
      if not rs.eof then
        tmp_id_2=rs("class_id")
        tmp_order_2=rs("class_order")
        update_ok="yes"
        exit do
      end if
      exit do
    end if
    rs.movenext
  loop
  rs.close:set rs=nothing
  if update_ok="yes" then
    sql="update bbs_class set class_order="&tmp_order_2&" where class_id="&tmp_id_1
    conn.execute(sql)
    sql="update bbs_class set class_order="&tmp_order_1&" where class_id="&tmp_id_2
    conn.execute(sql)
  end if
end sub

sub fso_js()
  dim filetype,file_name,sql,rs,topic
  file_name="style/forum_go.js"
  filetype=forum_go()
  call create_file(file_name,filetype)
  
  'filetype="document.write ("""&code_fso(filetype,1)&""");"
  
  response.write "<script language=javascript>alert(""生成 JS 成功！"");location.href='?';</script>"
end sub

sub forum_go_board(cid,fid,ff,fo)
  dim rsboard,strsqlboard,forumid,forumname,fi,foo
  strsqlboard="select forum_id,forum_name,forum_power,forum_hidden from bbs_forum where forum_f="&fid&" and class_id=" & cid & " order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id"):forumname=rsboard("forum_name")
    foo=vbcrlf&"document.write (""<option value='forum_list.asp?forum_id=" &forumid& "'>"
    for fi=0 to ff
      if fi=ff then
        foo=foo&"├"
      else
        foo=foo&"│"
      end if
    next
    foo=foo&forumname & "</option>"");"
    fo=fo&foo
    call forum_go_board(cid,forumid,ff+1,fo)
    rsboard.movenext
  loop
  rsboard.close:set rsboard=nothing
end sub

function forum_go()
  dim rsclass,strsqlclass,rsboard,strsqlboard,fb:fb=""
  forum_go=vbcrlf & "document.write (""<select onchange=\""if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}\"">"");" & _
	   vbcrlf & "document.write (""<option selected>快速跳转论坛至...</option>"");"
  strsqlclass="select class_id,class_name from bbs_class order by class_order"
  set rsclass=conn.execute(strsqlclass)
  if not(rsclass.bof and rsclass.eof) then
    do while not rsclass.eof
      call forum_go_board(rsclass("class_id"),0,0,fb)
      forum_go=forum_go & vbcrlf & "document.write (""<option class=bg_2>╋ "& rsclass("class_name") &"</option>"");"
      forum_go=forum_go & fb
      fb=""
      rsclass.movenext
    loop
  end if
  set rsclass=nothing:set rsboard=nothing
  forum_go=forum_go & vbcrlf & "document.write (""<option class=bg_2>————————</option>"");" & _
	   vbcrlf & "document.write (""<option value='forum.asp' class=bg_1>　论坛首页</option>"");" & _
	   vbcrlf & "document.write (""<option class=bg_2>————————</option>"");" & _
	   vbcrlf & "document.write (""<option value='forum_action.asp?action=new'>　♀ 论坛新贴</option>"");" & _
	   vbcrlf & "document.write (""<option value='forum_action.asp?action=tim'>　♀ 回复新贴</option>"");" & _
	   vbcrlf & "document.write (""<option value='user_action.asp?action=list'>　♀ 用户列表</option>"");" & _
	   vbcrlf & "document.write (""<option value='help.asp?action=forum'>　♀ 论坛帮助</option>"");" & _
	   vbcrlf & "document.write (""</select>"");"
end function

sub class_edit()
  dim classid,rs,strsql,class_name,class_order
  classid=trim(request("class_id"))
  if not(isnumeric(classid)) then
    response.redirect "admin_forum.asp"
    response.end
  end if
  set rs=server.createobject("adodb.recordset")
  strsql="Select * from bbs_class where class_id="&classid
  rs.open strsql,conn,1,3
%><font class=time>修改论坛分类</font><br><br><br>
<table width='100%' border=0 align=center cellpadding=2 cellspacing=1>
<%
if trim(request("edit"))="ok" then
  class_name=objv7.code_form(request.form("class_name"))
  if class_name="" then
    response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center><font class=time>论坛分类名称不能为空！</font><br><br>"&go_back&"</td></tr>")
  else
    rs("class_name")=class_name
    rs.update
    response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center>成功的修改了论坛分类：<font class=time>" & class_name & "</font></td></tr>")
  end if
else
%>
<tr>
<form method=post action='admin_forum.asp?action=class_edit&class_id=<%=classid%>&edit=ok'>
<td width='40%' align=center></td><td width='60%'></td>
</tr>
<tr height=30 class=tdbg-dark>
<td align=center>论坛分类名称：</td> 
<td><input type=text name=class_name value='<%=rs("class_name")%>' size=20 maxlength=20></td> 
</tr>
<tr height=30 class=tdbg-dark> 
<td colspan=2 align=center height=30><input type=submit value=' 提 交 修 改 '></td>
</form>
</tr><%
  end if
  rs.close:set rs=nothing
%></table><%
end sub

sub class_add()
%><font class=time>添加论坛分类</font><br><br><br>
<table width='100%' border=0 align=center cellpadding=2 cellspacing=1>
<%
if trim(request.querystring("add"))="ok" then
  dim rs,strsql,class_name,class_order
  class_name=objv7.code_form(request.form("class_name"))
  if class_name="" then
    response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center><font class=time>论坛分类名称不能为空！</font><br><br>"&go_back&"</td></tr>")
  else
    set rs=server.createobject("adodb.recordset")
    strsql="Select top 1 * from bbs_class order by class_order desc"
    rs.open strsql,conn,1,1
    if rs.eof and rs.bof then
      class_order=0
    else
      class_order=rs("class_order")
    end if
    class_order=class_order+1
    rs.close
    strsql="Select * from bbs_class"
    rs.open strsql,conn,1,3
    rs.addnew
    rs("class_order")=class_order
    rs("class_name")=class_name
    rs.update
    response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center>成功的添加了论坛分类：<font class=time>" & class_name & "</font></td></tr>")
    rs.close:set rs=nothing
  end if
else
%>
<tr>
<form method=post action='admin_forum.asp?action=class_add&add=ok'>
<td width='40%' align=center></td><td width='60%'></td>
</tr>
<tr height=30 class=tdbg-dark>
<td align=center>论坛分类名称：</td> 
<td><input type=text name=class_name size=20 maxlength=20></td> 
</tr>
<tr height=30 class=tdbg-dark> 
<td colspan=2 align=center height=30><input type=submit value=' 提 交 添 加 '></td>
</form>
</tr><%
end if
%></table><%
end sub

sub forum_edit()
  dim classid,classid2,forumid,forumid2,formid,rs,strsql,classname,forum_name
  classid=trim(request.querystring("class_id"))
  forumid=trim(request.querystring("forum_id"))
  if not(isnumeric(classid)) or not(isnumeric(forumid)) then call forum_main():exit sub
  strsql="select class_name from bbs_class where class_id="&classid
  set rs=conn.execute(strsql)
  if rs.eof and rs.bof then rs.close:set rs=nothing:call forum_main():exit sub
  classname=rs("class_name")
  rs.close:set rs=nothing
%><font class=time>修改论坛</font>（<font class=hit_1><%=classname%></font>）<br><br><br>
<table width='100%' border=0 align=center cellpadding=2 cellspacing=1><%
  set rs=server.createobject("adodb.recordset")
  strsql="Select * from bbs_forum where forum_id="&forumid
  rs.open strsql,conn,1,3
  if trim(request.querystring("edit"))="ok" then
    formid=trim(request.form("formid"))
    if len(formid)<3 or instr(1,formid,"-")<=0 then call forum_main():exit sub
    classid2=left(formid,instr(1,formid,"-")-1)
    forumid2=right(formid,len(formid)-instr(1,formid,"-"))
    forum_name=objv7.code_form(request.form("forum_name"))
    if forum_name="" then
      response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center><font class=time>论坛名称不能为空！</font><br><br>"&go_back&"</td></tr>")
    else
      if int(classid2)<>int(classid) then rs("class_id")=classid
      if int(forumid2)<>int(forumid) then rs("forum_f")=forumid2
      if request.form("forum_w")="yes" then
        rs("forum_w")=true
      else
        rs("forum_w")=false
      end if
      rs("forum_name")=forum_name
      rs("forum_pic")=trim(request.form("forum_pic"))
      if request.form("forum_hidden")="no" then
        rs("forum_hidden")=false
      else
        rs("forum_hidden")=true
      end if
      rs("forum_type")=request.form("forum_type")
      rs("forum_remark")=request.form("forum_remark")
      rs("forum_power")=objv7.code_form(request.form("forum_power"))
      rs.update
      response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center>成功的修改了论坛：<font class=time>" & forum_name & "</font></td></tr>")
    end if
  else
%><form method=post action='admin_forum.asp?action=forum_edit&class_id=<%=classid%>&forum_id=<%=forumid%>&edit=ok'>
<tr class=tdbg-dark><td width='20%' align=center></td><td width='80%'></td></tr>
<tr height=30 class=tdbg-dark><td align=center>论坛名称：</td><td><input type=text name=forum_name value='<%=rs("forum_name")%>' size=30 maxlength=20></td></tr>
<tr height=30 class=tdbg-dark><td align=center>所属分类：</td><td><select name=formid size=1><%
dim crs,csql,cid,ctype
csql="select * from bbs_class order by class_order"
set crs=conn.execute(csql)
do while not crs.eof
  cid=crs("class_id")
  response.write vbcrlf & "<option value='"&cid&"-0'"
  if int(classid)=int(cid) then
    response.write " selected class=bg_1"
  end if
  response.write ">╋"&crs("class_name")&"</option>"
  call forum_edit_board(cid,0,0,forumid)
  crs.movenext
loop
ctype=int(rs("forum_type"))
%></select></td></tr>
<tr class=tdbg-dark><td align=center>论坛说明：</td><td><textarea name=forum_remark rows=5 cols=50><%=rs("forum_remark")%></textarea></td></tr>
<tr class=tdbg-dark><td align=center>论坛类型：</td><td><select name=forum_type size=1><%
  dim tdim,t2
  tdim=split(forum_type,"|")
  for i=0 to ubound(tdim)
    response.write vbcrlf&"<option value='"&i+1&"'"
    if ctype=i+1 then response.write " selected"
    response.write ">"&right(tdim(i),len(tdim(i))-instr(tdim(i),":"))&"</option>"
  next
  erase tdim
%></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否开放：<input type=checkbox name=forum_hidden value='no'<% if rs("forum_hidden")=false then response.write " checked" %>>&nbsp;（选上为开放）</td></tr>
<tr class=tdbg-dark><td align=center>发贴模式：</td><td><input type=checkbox name=forum_w value='yes'<% if rs("forum_w")=true then response.write " checked" %>>&nbsp;（选上为可以发表新的主题）</td></tr>
<tr class=tdbg-dark><td align=center>论坛图片：</td><td><input type=text name=forum_pic value='<%=rs("forum_pic")%>' size=30 maxlength=50> 例：<a title='代表 images/forum/sample.gif 这个图片<br>也可以直接填写图片的URL地址'>$sample.gif</a></td></tr>
<tr height=50 class=tdbg-dark><td align=center>论坛版主：<br><br></td><td><input type=text name=forum_power value='<%=rs("forum_power")%>' size=50 maxlength=50><br>多个请用“|”分开，如：“shidai|admin|sczywj”</td></tr>
<tr height=30 class=tdbg-dark><td colspan=2 align=center height=30><input type=submit value=' 提 交 修 改 '></td></tr>
</form><%
  end if
%></table><%
end sub

sub forum_edit_board(cid,fid,ff,nid)
  dim rsboard,strsqlboard,forumid,forumname,fi,foo,fb
  strsqlboard="select forum_id,forum_name,forum_power,forum_hidden from bbs_forum where forum_f="&fid&" and class_id=" & cid & " order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id"):forumname=rsboard("forum_name")
    foo=vbcrlf&"<option value='"&cid&"-"&forumid&"'"
    if int(nid)=int(forumid) then foo=foo&" selected"
    foo=foo&">"
    for fi=0 to ff
      if fi=ff then
        foo=foo&"├"
      else
        foo=foo&"│"
      end if
    next
    foo=foo&"" & forumname & "</option>"
    response.write foo
    call forum_edit_board(cid,forumid,ff+1,nid)
    rsboard.movenext
  loop
  rsboard.close:set rsboard=nothing
end sub

sub forum_add()
  dim rs,strsql,classname,classid,forum_name,forum_order,fid
  classid=trim(request.querystring("class_id"))
  fid=trim(request.querystring("forum_id"))
  if not(isnumeric(fid)) then fid=0
  if not(isnumeric(classid)) then call forum_main():exit sub
  strsql="select class_name from bbs_class where class_id="&classid
  set rs=conn.execute(strsql)
  if rs.eof and rs.bof then
    rs.close:set rs=nothing
    call forum_main():exit sub
  end if
  classname=rs("class_name")
  rs.close:set rs=nothing
%><font class=time>添加论坛</font>（<font class=hit_1><%=classname%></font>）<br><br><br>
<table width='100%' border=0 align=center cellpadding=2 cellspacing=1>
<%
if trim(request("add"))="ok" then
  forum_name=objv7.code_form(request.form("forum_name"))
  if forum_name="" then
    response.write( VbCrLf & "<tr class=tdbg-dark><td height=80 align=center><font class=time>论坛名称不能为空！</font><br><br>"&go_back&"</td></tr>")
  else
    forum_order=0
    set rs=server.createobject("adodb.recordset")
    strsql="Select top 1 forum_order from bbs_forum where class_id="&classid&" and forum_f="&fid&" order by forum_order desc"
    set rs=conn.execute(strsql)
    if not(rs.eof and rs.bof) then forum_order=rs("forum_order")
    rs.close
    forum_order=forum_order+1
    strsql="Select * from bbs_forum"
    rs.open strsql,conn,1,3
    rs.addnew
    rs("class_id")=classid
    rs("forum_order")=forum_order
    rs("forum_f")=fid
    rs("forum_n")=0
    if request.form("forum_w")="yes" then
      rs("forum_w")=true
    else
      rs("forum_w")=false
    end if
    rs("forum_name")=forum_name
    rs("forum_remark")=request.form("forum_remark")
    rs("forum_power")=objv7.code_form(request.form("forum_power"))
    rs("forum_pic")=trim(request.form("forum_pic"))
    if request.form("forum_hidden")="no" then
      rs("forum_hidden")=false
    else
      rs("forum_hidden")=true
    end if
    rs("forum_type")=request.form("forum_type")
    rs("forum_topic_num")=0
    rs("forum_data_num")=0
    rs("forum_new_info")="|||"
    rs.update
    conn.execute("update bbs_forum set forum_n=forum_n+1 where forum_id="&fid)
    response.write( vbcrlf & "<tr class=tdbg-dark><td height=80 align=center>成功的添加了论坛：<font class=time>" & forum_name & "</font></td></tr>")
    rs.close:set rs=nothing
  end if
else
%>
<form method=post action='admin_forum.asp?action=forum_add&forum_id=<%=fid%>&add=ok&class_id=<%=classid%>'>
<tr class=tdbg-dark><td width='20%' align=center></td><td width='80%'></td></tr>
<tr height=30 class=tdbg-dark><td align=center>论坛名称：</td><td><input type=text name=forum_name size=30 maxlength=20></td></tr>
<tr class=tdbg-dark><td align=center>论坛说明：</td><td><textarea name=forum_remark rows=5 cols=50></textarea></td></tr>
<tr class=tdbg-dark><td align=center>论坛类型：</td><td><select name=forum_type size=1><%
  dim tdim,t2
  tdim=split(forum_type,"|")
  for i=0 to ubound(tdim)
    response.write vbcrlf&"<option value='"&i+1&"'>"&right(tdim(i),len(tdim(i))-instr(tdim(i),":"))&"</option>"
  next
  erase tdim
%></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否开放：<input type=checkbox name=forum_hidden value='no' checked>&nbsp;（选上为开放）</td></tr>
<tr class=tdbg-dark><td align=center>发贴模式：</td><td><input type=checkbox name=forum_w value='yes' checked>&nbsp;（选上为可以发表新的主题）</td></tr>
<tr class=tdbg-dark><td align=center>论坛图片：</td><td><input type=text name=forum_pic value='' size=30 maxlength=50> 例：<a title='代表 images/forum/sample.gif 这个图片<br>也可以直接填写图片的URL地址'>$sample.gif</a></td></tr>
<tr height=50 class=tdbg-dark>
<td align=center>论坛版主：<br><br></td> 
<td><input type=text name=forum_power size=50 maxlength=50><br>多个请用“|”分开，如：“shidai|admin|sczywj”</td> 
</tr>
<tr height=30 class=tdbg-dark><td colspan=2 align=center height=30><input type=submit value=' 提 交 添 加 '></td></tr>
</form><%
  end if
  response.write "</table>"
end sub

sub forum_mod()
%>
<table width='100%' border=0 align=center cellpadding=2 cellspacing=1>
<form action='admin_forum.asp?action=mod' method=post>
<input type=hidden name=modok value='ok'>
<tr class=tdbg-dark><td align=center height=50 colspan=4><font class=time>合并论坛</font></td></tr>
<%
  if trim(request.form("modok"))="ok" then
    response.write "<tr class=tdbg-dark><td align=center height=50 colspan=4>"
    dim sel1,sel2,rs,sql
    sel1=trim(request.form("sel_1"))
    sel2=trim(request.form("sel_2"))
    if not(isnumeric(sel1)) or not(isnumeric(sel2)) then
      response.write "<font class=time>您没有选择要合并的论坛！</font>"
    else
      sql="update bbs_topic set forum_id="&int(sel2)&" where forum_id="&int(sel1)
      conn.execute(sql)
      sql="update bbs_data set forum_id="&int(sel2)&" where forum_id="&int(sel1)
      conn.execute(sql)
      response.write "<font class=time>论坛合并成功！</font>"
    end if
    response.write "</td></tr>"
  end if
%>
<tr height=50 class=tdbg-dark>
<td>从</td>
<td><select name=sel_1><% call forum_list() %></select></td>
<td>合并到</td>
<td><select name=sel_2><% call forum_list() %></select></td>
</tr>
<tr class=tdbg-dark><td align=center height=50 colspan=4><input type=submit value='开始合并'></td></tr>
</form>
</table>
<%
end sub

sub forum_list()
  dim strsqlclass,rsclass,strsqlboard,rsboard,fb:fb=""
  strsqlclass="select class_id,class_name from bbs_class order by class_order"
  set rsclass=conn.execute(strsqlclass)
  if not(rsclass.bof and rsclass.eof) then
    do while not rsclass.eof
      response.write vbcrlf & "<option class=bg_2>╋ "& rsclass("class_name") &"</option>"
      call forum_list_board(rsclass("class_id"),0,0,fb)
      response.write fb
      rsclass.movenext
    loop
  end if
  set rsclass=nothing:set rsboard=nothing
end sub

sub forum_list_board(cid,fid,ff,fo)
  dim rsboard,strsqlboard,forumid,forumname,fi,foo
  strsqlboard="select forum_id,forum_name,forum_power,forum_hidden from bbs_forum where forum_f="&fid&" and class_id=" & cid & " order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id"):forumname=rsboard("forum_name")
    foo=vbcrlf&"document.write (""<option value='forum_list.asp?forum_id=" &forumid& "'>"
    for fi=0 to ff
      if fi=ff then
        foo=foo&"├"
      else
        foo=foo&"│"
      end if
    next
    foo=foo&forumname & "</option>"");"
    fo=fo&foo
    call forum_list_board(cid,forumid,ff+1,fo)
    rsboard.movenext
  loop
  rsboard.close:set rsboard=nothing
end sub

sub form_board(cid,fid,ff)
  dim rsboard,strsqlboard,forumid,forumname,fi
  strsqlboard="select forum_id,forum_name,forum_power,forum_hidden from bbs_forum where forum_f="&fid&" and class_id=" & cid & " order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id"):forumname=rsboard("forum_name")
    response.write vbcrlf&"<tr align=center"
    if ff mod 2<>0 then response.write ""
    response.write "><td align=left class=hit>"
    for fi=0 to ff
      response.write "　"
    next
    response.write img_small("fk_plus")&"<b>" & forumname & "</b>"
    if rsboard("forum_hidden")=true then response.write " <font class=gray>隐藏</font>"
    response.write "</td><td><a href='admin_forum.asp?action=forum_add&class_id=" & cid & "&forum_id="&forumid&"'>添加分论坛</a></td><td><a href='?action=forum_edit&class_id="&cid&"&forum_id=" & forumid & "'>编辑</a></td><td><a href=""javascript:Do_del_forum(" & forumid & ");"">删除</a></td><td>排序：<a href='?fid="&fid&"&forum_id="&forumid&"&class_id="&cid&"&action=orders&actions=up'>向上</a> <a href='?fid="&fid&"&forum_id="&forumid&"&class_id="&cid&"&action=orders&actions=down'>向下</a></td></tr>"
    call form_board(cid,forumid,ff+1)
    rsboard.movenext
  loop
  rsboard.close:set rsboard=nothing
end sub

sub forum_main()
%><table width='100%' border=0 align=center cellpadding=2 cellspacing=1>
<%
dim rsclass,strsqlclass,classid
strsqlclass="select * from bbs_class order by class_order"
set rsclass=conn.execute(strsqlclass)
if rsclass.bof and rsclass.eof then
  response.write vbcrlf & "<tr class=tdbg-dark><td align=center height=200><font class=time>现在好像还没有论坛分类！</font></td></tr>"
else
  do while not rsclass.eof
    classid=rsclass("class_id")
    response.write vbcrlf & "<tr height=20 class=tdbg-dark align=center><td align=left>" & img_small("fk2") & vbcrlf & "<font class=time><b>" & rsclass("class_name") & "</b></font></td><td><a href='admin_forum.asp?action=forum_add&class_id=" & classid & "'>添加论坛</a></td><td><a href='?action=class_edit&class_id=" & classid & "'>修改</a></td><td><a href=""javascript:Do_del_class('" & classid & "');"">删除</a></td><td>排序：<a href='?class_id="&classid&"&action=orderc&actions=up'>向上</a> <a href='?class_id="&classid&"&action=orderc&actions=down'>向下</a></td></tr>"
    call form_board(classid,0,0)
    rsclass.movenext
  loop
end if
set rsclass=nothing
%>
<tr class=tdbg-dark><td align=center height=30 colspan=5><a href='?action=class_add'>添加论坛分类</a></td></tr>
</table>
<script language=JavaScript>
<!--
function Do_del_class(data1)
{
if (confirm("此操作将删除id为 "+data1+" 的论坛分类！\n\n真的要删除吗？\n\n删除后将无法恢复！"))
  window.location="?action=del_class&class_id="+data1
}

function Do_del_forum(data1)
{
if (confirm("此操作将删除id为 "+data1+" 的论坛！\n\n真的要删除吗？\n\n删除后将无法恢复！"))
  window.location="?action=del_forum&forum_id="+data1
}
//-->
</script><%
end sub

sub del_class()
  dim classid,sql,rs,forumid
  classid=trim(request.querystring("class_id"))
  if not(isnumeric(classid)) then
    call forum_main():exit sub
  end if
  sql="delete from bbs_class where class_id="&classid
  conn.execute(sql)
  sql="select forum_id from bbs_forum where class_id="&classid
  set rs=conn.execute(sql)
  do while not rs.eof
    forumid=rs("forum_id")
    sql="delete from bbs_topic where forum_id="&forumid
    conn.execute(sql)
    sql="delete from bbs_data where forum_id="&forumid
    conn.execute(sql)
    rs.movenext
  loop
  sql="delete from bbs_forum where class_id="&classid
  conn.execute(sql)
  response.write "<script language=javascript>alert(""已成功能删除了一个论坛分类！\n\n（包括其所属的论坛的贴子）"");</script>"
  call forum_main()
end sub

sub del_forum_board(fid,ff)
  dim rsboard,strsqlboard,forumid
  strsqlboard="select forum_id from bbs_forum where forum_f="&fid&" order by forum_order"
  set rsboard=conn.execute(strsqlboard)
  if rsboard.eof and rsboard.bof then
    rsboard.close:set rsboard=nothing
    exit sub
  end if
  do while not rsboard.eof
    forumid=rsboard("forum_id")
    sql="delete from bbs_forum where forum_id="&forumid
    conn.execute(sql)
    sql="delete from bbs_topic where forum_id="&forumid
    conn.execute(sql)
    sql="delete from bbs_data where forum_id="&forumid
    conn.execute(sql)
    call del_forum_board(forumid,ff+1)
    rsboard.movenext
  loop
  rsboard.close:set rsboard=nothing
end sub

sub del_forum()
  dim classid,forumid,sql
  forumid=trim(request.querystring("forum_id"))
  if not(isnumeric(forumid)) then call forum_main():exit sub
  conn.execute("update bbs_forum set forum_n=forum_n+1 where forum_id="&forumid)
  call del_forum_board(forumid,0)
  sql="delete from bbs_forum where forum_id="&forumid
  conn.execute(sql)
  sql="delete from bbs_topic where forum_id="&forumid
  conn.execute(sql)
  sql="delete from bbs_data where forum_id="&forumid
  conn.execute(sql)
  response.write "<script language=javascript>alert(""已成功能删除了一个论坛！\n\n（包括其所属的贴子）"");</script>"
  call forum_main()
end sub
%>