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

<%call head()
dim Action,act
dim id,adminusid 
id=trim(request.querystring("id"))
Action=Request.QueryString("Action")
Act=Request.QueryString("Act")
if id="" or Isnumeric(id)=False then
  Call Error(""&zonene&"ID无效！")
end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select ID,adminusid from ydbbs where id="&id,conn,1,1
if rs.eof then
  Call Error("<card title=""err""><p>不存在的"&zonene&"！")
  end if
  adminusid =rs("adminusid")
rs.close
set rs=nothing
IF  Action="in" Then
	call zonein
else

	call zoneout
end if

sub zonein
Call saycarda("加入"&zonene&"")


set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where zoneid="&ID&" and id="&myid,conn,1,1
if NOT rs.eof then
  Call Error("你已经加入此"&zonene&",请不要重复加入！")
  end if
  rs.close
set rs=nothing
if act<>"ok" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where zoneid=0 and id="&myid,conn,1,1
if rs.eof then
response.write"你已经加入了一个"&zonene&"了,如果确定则自动退出之前"&zonene&"！"
response.write"<br/><a href=""zonefav.asp?Action=in&amp;act=ok&amp;id="&id&"&amp;saytk="&saytk&"&amp;sid="&sid&""">确定加入</a>"&chr(13)
  Response.write "<br/><anchor><prev/>取消加入</anchor>" & chr(13)
 Call headsay()
  Response.end
  end if
  rs.close
set rs=nothing
 end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where id="&myid,conn,1,2
rs("zoneid")=id
if myid<>0 then
mz="[url=/bbs/uinfo.asp?id="&myid&"&amp;saytk="&saytk&"&sid=[sid]]"&myni&"[/url]"
else
mz="游客"
end if
conn.execute("insert into sqdt(shijian,dz)values('"&now&"','"&mz&"成功的加入了(url=/bbs/zone.asp?saytk="&saytk&"&sid=[sid])"&zonene&"(/url)')")
rs.update
rs.close
set rs=nothing
    response.write"加入"&zonene&"成功！"&chr(13)
end sub

sub zoneout
Call saycarda("退出"&zonene&"")

if adminusid=myid then
  Call Error("你是"&zonene&"主人,不能退出！")
  end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where zoneid=0 and id="&myid,conn,1,1
if NOT rs.eof then
  Call Error("你没有加入任何"&zonene&",不用退出的吧！")
  end if
  rs.close
set rs=nothing
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where zoneid="&ID&" and id="&myid,conn,1,1
if rs.eof then
  Call Error("你没有加入此"&zonene&",不用退出的吧！")
  end if
  rs.close
set rs=nothing

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zoneid from USERS where id="&myid,conn,1,2
rs("zoneid")=0
if myid<>0 then
mz="[url=/bbs/uinfo.asp?id="&myid&"&amp;saytk="&saytk&"&sid=[sid]]"&myni&"[/url]"
else
mz="游客"
end if
conn.execute("insert into sqdt(shijian,dz)values('"&now&"','"&mz&"退出了(url=/bbs/zone.asp?saytk="&saytk&"&sid=[sid])"&zonene&"(/url)')")
rs.update
rs.close
set rs=nothing
    response.write"退出"&zonene&"成功！"&chr(13)
end sub
conn.close
set conn=nothing
    response.write"<br/><a href=""zoneall.asp?bbsid="&id&"&amp;saytk="&saytk&"&amp;sid="&sid&""">"&zonene&"交流</a>"&chr(13)
%><!--#include file="fanhui.asp"-->
<%
call headsay()
%>