<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->

<%
call head()
dim TP,ids,Action,tid,bbsid,tzname,id
Action=Request.QueryString("Action")
tid=usb(request("tid"))
id=usb(request("id"))
bbsid=usb(request("bbsid"))
TP=usb(request("TP"))
IF  Action="t" Then
	call bbslist
else

	call relist
end if

sub bbslist

if TP<>"" then
if tid="" or Isnumeric(tid)=False then
  Call Error("<card title=""出错了""><p>ID无效！")
  end if
if bbsid="" or Isnumeric(bbsid)=False then
  Call Error("<card title=""出错了""><p>ID无效！")
  end if
dim fid,tztitle
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from [sell] where id="&tid,conn,1,1

if rs("fid")<>myid  and skey<>abs(bbsid) and keys<>1 and adminzone<>abs(bbsid) then
  Call Error("<card title=""出错了""><p>权限不足！")
  end if
if rs("jj")=1 then
  Call Error("<card title=""出错了""><p>先解除精华才能删除帖子！")
  end if
fid=rs("fid")
tztitle=rs("name")
rs.close
set rs=nothing
  conn.Execute("update sell set yc=1 Where id=" & tid)
  conn.Execute("update relist set yc=1 Where tid=" & tid)
  
  conn.Execute("update users set myjb=myjb-"&abs(int(selldeljb))&",myjy=myjy-"&abs(int(selldeljy))&",mysellnum = mysellnum-1 Where id=" & fid)

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from [board] ",conn,1,2
rs.addnew
rs("bbsid")=bbsid
if clng(fid)=myid then
rs("nr")="会员："&myni&"(id："&myid&")删除帖子["&tztitle&"]！"
else
rs("nr")="版主："&myni&"(id："&myid&")删除帖子["&tztitle&"]！"
end if
rs.update
rs.close
set rs=nothing
Call cardz("操作成功","board.asp?bbsid="&bbsid&"&amp;sid="&sid&"&amp;saytk="&saytk&"")


 Response.Write "成功删除！正在返回.."
 Response.Write "<br/><a href='board.asp?bbsid="&bbsid&"&amp;sid="&sid&"&amp;saytk="&saytk&"'>返回本版</a>"

Else
Call saycardd("操作成功")


 Response.Write "确认删除该帖子？<br/>"
 Response.Write "<a href='bbsdel.asp?Action=t&amp;id="&id&"&amp;tid="&tid&"&amp;bbsid="&bbsid&"&amp;sid="&sid&"&amp;TP=1&amp;saytk="&saytk&"'>是的</a><br/>"
 Response.Write "<a href='topic.asp?tid="&tid&"&amp;bbsid="&bbsid&"&amp;sid="&sid&"&amp;saytk="&saytk&"'>取消</a>"

end if

end Sub
Sub relist

if TP<>"" then
if id="" or Isnumeric(id)=False then
  Call Error("<card title=""出错了""><p>ID无效！")
  end if
if tid="" or Isnumeric(tid)=False then
  Call Error("<card title=""出错了""><p>ID无效！")
  end if
if bbsid="" or Isnumeric(bbsid)=False then
  Call Error("<card title=""出错了""><p>ID无效！")
  end if
  if skey<>abs(bbsid) and  keys<>1 and vipdj=0 and adminzone<>abs(bbsid) then
  Call Error("<card title=""出错了""><p>权限不足！")
  end if
  
  dim fid
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select fid from [relist] where id="&id,conn,1,1
if rs.eof then
  Call Error("<card title=""出错了""><p>不存在的回复！")
  end if
fid=rs("fid")
rs.close
set rs=nothing
  conn.Execute("delete from relist Where id=" & id)
  conn.Execute("update users set myjb=myjb-"&abs(int(redeljb))&",myjy=myjy-"&abs(int(redeljy))&",myrelnum = myrelnum-1  Where id=" & fid)
  


Call cardz("删除回复","topic.asp?tid="&tid&"&amp;sid="&sid&"&amp;saytk="&saytk&"")

 Response.Write "成功删除！正在返回.."
 Response.Write "<br/><a href='topic.asp?tid="&tid&"&amp;bbsid="&bbsid&"&amp;sid="&sid&"&amp;saytk="&saytk&"'>查看主帖</a>"

Else
Call saycarda("删除回复")

 Response.Write "确认删除该回复？<br/>"
 Response.Write "<a href='bbsdel.asp?Action=h&amp;id="&id&"&amp;tid="&tid&"&amp;bbsid="&bbsid&"&amp;sid="&sid&"&amp;TP=1&amp;saytk="&saytk&"'>是的</a><br/>"
 Response.Write "<a href='topic.asp?tid="&tid&"&amp;bbsid="&bbsid&"&amp;sid="&sid&"&amp;saytk="&saytk&"'>取消</a>"

end if
end Sub
call headsay()
%>