<!-- #include file="include/con_forum.asp" -->
<!-- #include file="include/jk_page_cute.asp" -->
<!-- #include file="include/jk_pagecute.asp" -->
<%
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
dim secrecy_u,nummer,nums,rssum,page,viewpage,thepages
nummer=dim_num(0)
nums=nummer
page=1

tit="『ko』手机信息网-论坛回收站"

call web_head(2,0,h_var3,0,0)
if login_mode<>"admin" then
  call forum_redirect("forum.asp")
end if
call forum_load()
'----------------------------中间 开始----------------------------
select case action
case "handle"
  call recycle_handle()
case "clear"
  call recycle_clear()
case else
  call recycle_list()
end select
'----------------------------中间 结束----------------------------
call forum_end()
call web_end(0,0)

sub recycle_clear()
  dim selid,snum
  snum=-1
  sql="select id from bbs_topic where forum_id=999999999 order by id"
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    selid=rs.getrows()
    snum=ubound(selid,2)
  end if
  if snum<0 then
    call web_js_msg(1,"论坛回收站已经被清空或还没有记录！\n\n点击返回...","?")
  end if
  for i=0 to snum
    'call joekoe_cms.upload_del(index_url,selid(0,i))
    call joekoe_cms.exec("delete from bbs_data where reply_id="&selid(0,i),0)
    call joekoe_cms.exec("delete from bbs_topic where id="&selid(0,i),0)
  next
  erase selid
  call web_js_msg(1,"已成功清空了论坛回收站！（共 "&snum+1&" 条记录）\n\n点击返回...","?")
end sub

sub recycle_handle()
      response.write forumid
  dim selid,handle,snum,fid,fparent,numd
  selid=trim(request.form("sel_id"))
  selid=replace(selid," ","")
  if selid="" then
    call recycle_list()
    exit sub
  end if
  snum=0
  handle=trim(request.form("handle"))
  selid=split(selid,",")
  for i=0 to ubound(selid)
    if isnumeric(selid(i)) then
      fid=0
      sql="select top 1 form_id from bbs_topic where forum_id=999999999 and id="&selid(i)
      set rs=joekoe_cms.exec(sql,1)
      if not rs.eof then fid=rs(0)
      rs.close
      sql="select top 1 forum_parent from bbs_forum where forum_id="&fid
      set rs=joekoe_cms.exec(sql,1)
      if not rs.eof then fparent=var_null(rs(0))
      rs.close
      if handle="revert" and fparent<>"" then
        sql="select count(id) from bbs_data where forum_id="&selid(i)&" and reply_id="&fid
        set rs=joekoe_cms.exec(sql,1)
        numd=rs(0)
        rs.close
        if not isnumeric(numd) then numd=0
        call joekoe_cms.exec("update bbs_data set forum_id="&fid&" where reply_id="&selid(i),0)
        call joekoe_cms.exec("update bbs_topic set forum_id="&fid&",form_id=0 where id="&selid(i),0)
        call joekoe_cms.exec("update bbs_forum set forum_topic_num=forum_topic_num+1,forum_data_num=forum_data_num+"&numd&" where forum_id in ("&fparent&")",0)
        call joekoe_cms.exec("update configs set num_topic=num_topic+1,num_data=num_data+"&numd,0)
      else
        'call joekoe_cms.upload_del(index_url,selid(i))
        call joekoe_cms.exec("delete from bbs_data where reply_id="&selid(i),0)
        call joekoe_cms.exec("delete from bbs_topic where id="&selid(i),0)
      end if
      snum=snum+1
    end if
  next
  erase selid
  call web_js_msg(1,"已成功操作 "&snum&" 条记录！\n\n点击返回...","?")
end sub

sub recycle_list()
  dim pageurl
  pageurl="?"
  sql="Select count(forum_id) from bbs_topic where forum_id=999999999"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from bbs_topic where forum_id=999999999 order by re_tim desc"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if rs.eof then
    nums=0
  else
    if int(viewpage)>1 then
      rs.move (viewpage-1)*nummer
    end if
    if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  end if
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr align=center height=20>
<td class=td width='5%'> </td>
<td class=td width='65%'>回收站主题（每页<%response.write rssum%>贴,点击<%response.write img_skin("fk_plus")%>可展开贴子列表）</td>
<td class=td width='20%'>作者</td>
<td class=td width='5%'>回复</td>
<td class=td width='5%'>浏览</td>
</tr>
<form name=recycle_frm action='?action=handle' method=post>
<%
  if  nums=0 then
%>
<tr><td colspan=5 class=bg_td><font class=gray>暂时没有可操作的记录！</font></td></tr>
<%
  else
  for i=1 to nums
    call forum_topic_type(rs("id"),rs("form_id"),rs("topic"),rs("tim"),rs("username"),rs("re_username"),rs("re_tim"),rs("counter"),rs("re_counter"),rs("istop"),rs("islock"),rs("isgood"),rs("isvote"),rs("vote_num"))
    rs.movenext
  next
  end if
  rs.close
%>
<tr><td colspan=5 class=bg_tds>
  <table border=0 cellspacing=0 cellpadding=0 width='100%'>
  <tr>
  <td>
    <table border=0 cellspacing=0 cellpadding=0>
    <tr>
    <td width=3></td>
    <td>共有<font class=red><%response.write rssum%></font>条记录</td>
    <td width=3></td>
    <td>页次：<font class=red><%response.write viewpage&"</font>/<font class=red>"&thepages%></font>&nbsp;</td>
    <td>分页：</td>
    <td><%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,10,"#ff0000") %></td>
    </tr>
    </table>
  </td>
  <td align=right>
    <table border=0 cellspacing=0 cellpadding=2>
    <tr>
    <td><input type=button onclick="javascript:recycle_clear();" value='清空所有'></td>
    <td width=3></td>
    <td><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);" class=bg_tds>&nbsp;选择所有</td>
    <td><select name=handle><option value='delete'>删除</option><option value='revert'>还原</option></select></td>
    <td><input type=submit name=submit value='操作' onclick="javascript:return sel_click(this.form);"></td>
    </tr>
    </table>
  </td>
  </tr>
  </table>
</td></tr>
</form>
</table>
<script language=javascript>
<!--
function recycle_clear()
{
  if (click_return('清空所有的回收站主题',0))
  { location.href='?action=clear'; }
}
-->
</script>
<%
  response.write CMS_Skin.skukong
end sub

sub forum_topic_type(t_id,t_forum_id,t_topic,t_tim,t_username,t_re_username,t_re_tim,t_counter,t_re_counter,t_istop,t_islock,t_isgood,t_isvote,t_vote_num)
%>
<tr class=bg_td align=center>
<td><%response.write base_forum_is(t_re_counter,t_istop,t_islock,t_isgood,t_isvote,t_vote_num)%></td>
<td align=left><input type=checkbox name=sel_id value='<%response.write t_id%>' class=bg_td><a href='forum_view.asp?forum_id=<%response.write t_forum_id%>&view_id=<%response.write t_id%>&recycle=yes' target=_blank alt='<b><%response.write joekoe_cms.code_html(t_topic,1,0)%></b><br>发表时间：<%response.write t_tim%><br>最后回复：<%response.write t_re_username%><br>回复时间：<%response.write t_re_tim%>'><%response.write joekoe_cms.code_html(t_topic,1,28)%></a><%'response.write joekoe_cms.cms_pagecute_topic(dim_num(1),t_re_counter,"forum_view.asp?forum_id="&t_forum_id&"&view_id="&t_id)%></td><td><%response.write format_user_view(t_username,1,1)%></td><td><%response.write t_re_counter%></td><td><%
  if t_isvote=true then
    response.write "<font class=red>"&t_vote_num&"</font>"
  else
    response.write t_counter
  end if
%></td></tr><%
end sub
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
%>