<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->
<%call head()

Call saycardc("申请"&zonene&"")
dim action,name,txt
name=trim(request("name"))
txt=trim(request("txt"))
action=trim(request.querystring("action"))
dim zonejb,zonenum
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select zonejb,zonenum from twapp where id=1",conn,1,1
if rs.eof then
  Call Error("系统没有配置！")
  end if
zonejb=rs("zonejb")
zonenum=rs("zonenum")
rs.close
set rs=nothing
if action="ok" then
if name="" then
  Call Error(""&zonene&"名称不能为空！")
end if
if txt="" then
  Call Error(""&zonene&"T简介不能为空！")
end if
if len(name)>10 then
  Call Error(""&zonene&"名称最多十字！")
end if
if len(txt)>200 then
  Call Error(""&zonene&"简介最多200字！")
end if
if myjb < zonejb then 
  Call Error("你的"&getcent&"不够开"&zonene&"哦！开"&zonene&"需支付"&zonejb&getcent)
  end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from ydbbs where adminusid="&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 * from ydbbs where name='"&name&"' and city=2",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 * from ydbbs",conn,1,2
rs.addnew
rs("name")=name
rs("grouptxt")=txt
rs("adminusid")=myid
rs("zonedate")=now()
rs("yc")=1
rs("lx")=1
rs("city")=2
rs.update
rs.close
set rs=nothing
'取ID
dim tid
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select top 1 ID from [ydbbs] order by id desc",conn,1,1
tid=rs("ID")
rs.close
set rs=nothing
'减币,设置
conn.Execute("update Users set myjb=myjb-"&zonejb&" ,zoneid="&tid&", adminzone="&tid&" Where id="&myid)

    response.write"恭喜,您的"&zonene&"申请成功!"
else
if saytk=>2 then
	Response.write "<form name=""form"" method=""post"" action=""zoneadd.asp?action=ok&amp;saytk="&saytk&"&amp;sid="&sid&""">"
end if

response.write"提示:创建"&zonene&"需支付"&zonejb&getcent
response.write"<br/>拥有"&zonene&"成员"&zonenum&"人即自动开放论坛"
response.write"<br/>"&zonene&"名称<br/>"
response.write"<input name='name' title='"&zonene&"名称'/><br/>"
response.write""&zonene&"宣言<br/>"
response.write"<input name='txt' title='"&zonene&"宣言'/><br/>"
if saytk=>2 then
%>

<input type="submit" name="Submit" value="确认申请"></form><br/><%
else




response.write"<anchor>[确定申请]<go href='zoneadd.asp?action=ok&amp;saytk="&saytk&"&amp;sid="&sid&"' method='post' accept-charset='utf-8'>"
response.write"<postfield name='name' value='$(name)'/>"
response.write"<postfield name='txt' value='$(txt)'/>"
response.write"</go></anchor>"
end if
end if
conn.close
set conn=nothing
    response.write"<br/><a href=""zone.asp?saytk="&saytk&"&amp;sid="&sid&""">"&zonene&"交流</a>"&chr(13)
%>
<!--#include file="fanhui.asp"-->
<%
call headsay()
%>