<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp" -->
<!--#include file="inc/dv_clsother.asp" -->
<!--#include file="inc/GroupPermission.asp" -->
<!--#include file="inc/dv_loadcache.asp"-->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="menpaiconn.asp"-->
<%
'加入 部落 扣除 金钱，增加 经验，魄力，威望 的百分比1Meipai_inout_rate(0～3) Meipai_inout_rate((menpai_setting(0)-1)*4+0～3))
'加入 激进部落 增加 金钱，扣除 经验，魄力，威望 的百分比2Meipai_inout_rate(4～7)Meipai_inout_rate((menpai_setting(0)-1)*4+0～3))

'退出 社团 增加 金钱，扣除 经验，魄力，威望 的百分比1Meipai_inout_rate(8～11)Meipai_inout_rate(menpai_setting(0)*4+5～7)) 
'退出 激进组织 扣除 金钱，增加 经验，魄力，威望 的百分比2Meipai_inout_rate(12～15) Meipai_inout_rate(menpai_setting(0)*4+5～7))

If Not IsObject(Conn) Then ConnectionDatabase
dim sql,rs,founderr,i,errmsg
founderr=false
Dv_plus.name="menpai"
Dv_plus.checklogin()
Dvbbs.LoadTemplates("")
Dvbbs.Stats="超贴"&Mpmc
Dvbbs.nav()
Dvbbs.Head_var 0,"","超贴"&Mpmc,"menpai.asp"
dim Meipai_inout_rate,maxtitleid
dim isZangmen'是否首脑
isZangmen=false
set rs=conn.execute("select * from [Dv_GroupName] where Zangmen='"&dvbbs.membername&"'")
if not(rs.eof and rs.bof) then isZangmen=true
Meipai_inout_rate=split(conn.execute("select Meipai_inout_rate from [menpai]")(0),"|")
maxtitleid=conn.execute("select top 1 UserGroupID from [Dv_UserGroups] order by UserGroupID desc")(0)
Set Dv_plus=Nothing
dim mymp
On Error Resume next
mymp=conn.execute("select UserGroup from [Dv_user] where UserID="&dvbbs.UserID)(0)
if mymp="" or mymp="尚未加入" then
Set rs= Server.CreateObject("ADODB.Recordset")                                                                                                                                                                                                                           
sql="select usergroup from [Dv_user] where username='"&dvbbs.membername&"'"                                                                                                                                                                                                                                   
rs.open sql,conn,1,3
rs(0)=Zlmp
rs.update
rs.close
set rs=nothing
end if
'验证不存在部落
set rs=conn.execute("select * from [Dv_GroupName] where GroupName='"&mymp&"'")  
if rs.eof and rs.bof then
rs.close
Set rs= Server.CreateObject("ADODB.Recordset")                                                                                                                                                                                                                           
sql="select usergroup from [Dv_user] where username='"&dvbbs.membername&"'"                                                                                                                                                                                                                                   
rs.open sql,conn,1,3
rs(0)=Zlmp
rs.update
rs.close
set rs=nothing
end if
call main()
dvbbs.activeonline()
dvbbs.footer
'============================================================
sub main()
%>
<table cellspacing=1 align=center   class=tableborder1 border="0">
<tr><th valign=middle align=center height=24  colspan="3" ><%=Mpmc%>说明</tr>
<tr>
<td valign=middle class=tablebody2 width="5%"></td>
<td valign=middle class=tablebody1 width="90%">
<ui>
<li><u><%=Sl1%></u>可以随意加入和退出
<li>只有满足您要加入的<u><%=Sl2%></u>的条件才可以加入，加入时要花费一定的金钱，但是魅力，经验，威望等会增加；退出时要被扣除几倍的入门费，并且要减一定的魅力，经验和威望
<li>加入<u><%=Sl3%></u>金钱会增加，但是会减一定的魅力，经验和威望；退出时反之
<li>被<%=Zmmc%>踢出<%=Mpmc%>的用户会自动加入<u><%=Sl4%></u> 
<li>加入一个新的<%=Mpmc%>前，请您先退出原有的<%=Mpmc%>，<u><%=Sl4%></u>除外 
</ui>
</td>
<td valign=middle class=tablebody2 width="5%"></td>
</tr>
<tr><td height=20 class=tablebody2 colspan=3></td></tr>
</table>
<table cellspacing=1 align=center class=tableborder1>
  <tr>
    <th height=24><%=Mpmc%>名称</th>
    <th height=24><%=Zmmc%></th> 
    <th height=24>创建日期</th> 
    <th height=24>性质</th> 
    <th height=24><%=Mpmc%>人数</th> 
    <th height=24>金钱</th> 
    <th height=24>总帖数</th> 
    <th height=24>操作</th> 
  </tr>
  <%
'部落显示  开始  
dim rs1
sql="select * from [Dv_GroupName]"
set rs=conn.execute(sql)
if rs.eof and rs.bof  then
response.write "<tr><td height=21 class=tablebody1 colspan=8><font color=red>本超贴暂时没有任何"&Mpmc&"</font></td></tr>"
else 
dim Zangmen,TotalArticle,TotalWealth,TotalUsernum
dim menpai_setting

do while not rs.eof
TotalArticle=0
TotalWealth=0
TotalUsernum=0
menpai_setting=split(rs("menpai_setting"),"|")
Zangmen=trim(rs("Zangmen"))
if Zangmen="" or isnull(Zangmen) then
Zangmen="<font color=#FF6666>- 竞选中 -</font>"
elseif Zangmen="-退出"&Mpmc&"-" then
Zangmen="<font color=#CC6666>退出"&Mpmc&"</font>"
else
Zangmen="<a href=dispuser.asp?name="&dvbbs.HTMLEncode(Zangmen)&" title=""查看该"&Zmmc&"的资料"" target=_blank>"&Zangmen&"</a>"
end if

'统计指定部落的文章数、金钱数 和 部落人数（包括首脑）
set rs1=conn.execute("select sum(userpost),sum(userwealth),count(*) from [Dv_user] where usergroup='"&rs("GroupName")&"'")
if rs1(0)<>"" then TotalArticle=rs1(0)
if rs1(1)<>"" then TotalWealth=rs1(1)
if rs1(2)<>"" then TotalUsernum=rs1(2)
%>
<tr>
<td valign=middle align=center height=21 class=tablebody1><a href="menpaiadd.asp?menu=1&groupname=<%=rs("groupname")%>" title="<%=Mpmc%>简介:<%=menpai_setting(7)%>"><%=rs("groupname")%></a></td>
<td valign=middle align=center height=21 class=tablebody1><%=Zangmen%></td>
    <td valign=middle align=center height=21 class=tablebody1><%=rs("addtime")%></td>
    <td valign=middle align=center height=21 class=tablebody1><%=MenpaiAttri(menpai_setting(0))%></td>
    <td valign=middle align=center height=21 class=tablebody1><%=TotalUsernum%></td>
    <td valign=middle align=center height=21 class=tablebody1><%=TotalWealth%></td>
    <td valign=middle align=center height=21 class=tablebody1><%=TotalArticle%></td>
    <td valign=middle align=center height=21 class=tablebody1><%if MenpaiState(rs("state"))<>"正常" then%><%=MenpaiState(rs("state"))%><%else%><a href="menpaiadd.asp?menu=1&groupname=<%=rs("groupname")%>">查看</a>--<a href="menpaimember.asp?GroupName=<%=rs("groupname")%>">成员</a><%end if%></td>
</tr>
<%rs.movenext
loop
rs.close
end if  
'部落显示  结束

'开创部落部分  代码开始
dim new_menpai_setting
new_menpai_setting=split(conn.execute("select new_menpai_setting from [menpai]")(0),",")

set rs=conn.execute("select userwealth,usercp,userep,userpower,userclass from [DV_user] where username='"&dvbbs.membername&"'")
dim wumenwupai'收纳不属于如何部落弟子的部落
wumenwupai=Zlmp
rs.close

dim mymenpai,CanCreateMenpai
CanCreateMenpai=true
set rs=conn.execute("select GroupName from [Dv_GroupName] where Zangmen='"&dvbbs.membername&"'")
if rs.eof and rs.bof then
mymenpai=conn.execute("select UserGroup from [Dv_user] where UserID="&dvbbs.UserID)(0)
if mymenpai=wumenwupai or mymenpai="" then
mymenpai="<font color=navy>"&mymenpai&"</font>"
else
mymenpai="<font color=navy>"&mymenpai&"</font><font color=red>成员</font>"
end if
else
mymenpai="<font color=navy>"&rs(0)&"</font><font color=red>"&Zmmc&"</font>"
end if    
%>
<tr><td height=21 class=tablebody2 colspan=8></td></tr>
<tr><th colspan=8 height=20>申请建立<%=Mpmc%></th></tr>
<tr>
<td align=center height=21 class=tabletitle2>项目</td>
    <td align=center height=21 class=tabletitle2>金钱</td>
<td align=center height=21 class=tabletitle2>魅力</td>
<td align=center height=21 class=tabletitle2>经验</td>
<td align=center height=21 class=tabletitle2>威望</td>
<td align=center height=21 class=tabletitle2>文章</td>
<td align=center height=21 class=tabletitle2 colspan=2><%=Mpmc%></td>
</tr>
<tr>
<td align=center height=21 class=tablebody2>建立<%=Mpmc%>要求</td>
    <td align=center height=21 class=tablebody1><%=new_menpai_setting(0)%>+<font color=red><%=new_menpai_setting(6)%></font></td>
<td align=center height=21 class=tablebody1><%=new_menpai_setting(1)%></td>
<td align=center height=21 class=tablebody1><%=new_menpai_setting(2)%></td>
<td align=center height=21 class=tablebody1><%=new_menpai_setting(3)%></td>
<td align=center height=21 class=tablebody1><%=new_menpai_setting(4)%></td>
<td align=center height=21 class=tablebody1 colspan=2><%=wumenwupai%></td>
</tr>
<tr>
<td align=center height=21 class=tablebody2>您的条件</td>
    <td align=center height=21 class=tablebody1><%=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text%></td>
<td align=center height=21 class=tablebody1><%=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text%></td>
<td align=center height=21 class=tablebody1><%=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userep").text%></td>
<td align=center height=21 class=tablebody1><%=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text%></td>
<td align=center height=21 class=tablebody1><%=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text%></td>
<td align=center height=21 class=tablebody1 colspan=2><%=mymenpai%></td>
</tr>
<tr>
<td align=center height=21 class=tablebody2>是否满足</td>
    <td align=center height=21 class=tablebody1><%if int(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text)>=(int(new_menpai_setting(0))+int(new_menpai_setting(6))) then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
<td align=center height=21 class=tablebody1><%if int(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text )>=int(new_menpai_setting(1)) then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
<td align=center height=21 class=tablebody1><%if int(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userep").text)>=int(new_menpai_setting(2)) then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
<td align=center height=21 class=tablebody1><%if int(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text)>=int(new_menpai_setting(3)) then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
<td align=center height=21 class=tablebody1><%if int(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text)>=int(new_menpai_setting(4)) then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
<td align=center height=21 class=tablebody1 colspan=2><%if instr(mymenpai,wumenwupai)<>0 or instr(mymenpai,"无"&Mpmc&"者")<>0 then%><font color=blue>√</font><%else%><%CanCreateMenpai=false%><font color=red>×</font><%end if%></td>
</tr>

<tr><td align=center height=21 class=tablebody1 colspan=8>
<%if CanCreateMenpai then%>
<a href="menpaiadd.asp?menu=8"><font color=blue>创建新<%=Mpmc%></font></a>

<%else%>
<font color=red>您至少有一个条件不满足创立<%=Mpmc%>的要求</font>
<%end if%>
&nbsp;&nbsp;<a href=menpaicompare.asp><font color=red><%=Mpmc%>大比拼</font></a>
</td>
</tr>
<tr><td align=center height=21 class=tablebody2 colspan=8></td></tr>
</table>
<%
'开创部落部分  代码结束 
end sub
%>