<!-- #include file="setup.asp" -->
<%
if Request.Cookies("username")=empty then error("<li>您还未<a href=login.asp>登录</a>社区")

id=int(Request("id"))

sql="select * from [user] where username='"&Request.Cookies("username")&"'"
Set Rs=Conn.Execute(sql)
faction=rs("faction")
experience=rs("experience")
money=rs("money")
rs.close

top


if Request("menu")="factionadd" then
if ""&Request("sessionid")&""<>""&session.sessionid&"" then error("<li>效验码错误<li>请重新返回刷新后再试")

if faction<>"" then error("<li>您已经加入 "&faction&" 了！<li>请先退出 "&faction&" 才能加入新帮派！")

factionname=Conn.Execute("Select factionname From faction where id="&id&"")(0)
conn.execute("update [user] set faction='"&factionname&"' where username='"&Request.Cookies("username")&"'")

message=message&"<li>加入成功<li><a href=faction.asp>返回社区帮派</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&message&"<meta http-equiv=refresh content=3;url=faction.asp>")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif Request("menu")="factionout" then
if ""&Request("sessionid")&""<>""&session.sessionid&"" then error("<li>效验码错误<li>请重新返回刷新后再试")
if faction=empty then error("<li>您目前没有加入任何帮派！")
conn.execute("update [user] set faction='' where username='"&Request.Cookies("username")&"'")
message=message&"<li>退出帮派成功<li><a href=faction.asp>返回社区帮派</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&message&"<meta http-equiv=refresh content=3;url=faction.asp>")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif Request("menu")="factiondel" then
if ""&Request("sessionid")&""<>""&session.sessionid&"" then error("<li>效验码错误<li>请重新返回刷新后再试")
sql="select * from faction where id="&id&""
Set Rs1=Conn.Execute(sql)
if rs1("buildman")<>""&Request.Cookies("username")&"" then error("<li>您不是该帮的帮主无法解散该帮")
conn.execute("update [user] set faction='' where faction='"&rs1("factionname")&"'")
conn.execute("delete from [faction] where id="&id&"")
message=message&"<li>解散帮派成功<li><a href=faction.asp>返回社区帮派</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&message&"<meta http-equiv=refresh content=3;url=faction.asp>")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif Request("menu")="look" then
sql="select * from faction where id="&id&""
Set Rs=Conn.Execute(sql)
%>
<table border=0 width=97% align=center cellspacing=1 cellpadding=4 class=a2>
<tr class=a3>
<td height=25>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → 
<a href="faction.asp">社区帮派</a></td>
</tr>
</table><br>

<title><%=rs("factionname")%> - Powered By BBSxp</title>

<table width="82%" border="0" align="center" cellspacing="1" cellpadding="2"  class=a2 height="150">
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>帮派简称:</b></font></div>
</td>
<td width="82%"><%=rs("factionname")%></td>
</tr>
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>帮派名称:</b></font></div>
</td>
<td width="82%"><%=rs("allname")%></td>
</tr>
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>帮派宗旨:</b></font></div>
</td>
<td width="82%"><%=rs("tenet")%></td>
</tr>
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>创建时间:</b></font></div>
</td>
<td width="82%"><%=rs("addtime")%></td>
</tr>
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>帮主名称:</b></font></div>
</td>
<td width="82%"><%=rs("buildman")%></td>
</tr>
<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>现有会员:</b></font></div>
</td>
<td width="82%">
<%
sql="select username from [user] where faction='"&rs("factionname")&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
i=i+1
list=list&""&rs("username")&" "
RS.MoveNext
loop
%><%=i%>人</td>
</tr>

<tr bgcolor="FFFFFF">
<td width="15%">
<div align="center"><font color="000066"><b>会员名单:</b></font></div>
</td>
<td width="82%">
<%=list%>
</td>
</tr>

</table>
<br><center><INPUT onclick=history.back(-1) type=button value=" << 返 回 ">
<%

htmlend

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif Request("menu")="addok" then

factionname=HTMLEncode(Request.Form("factionname"))
allname=HTMLEncode(Request.Form("allname"))
tenet=HTMLEncode(Request.Form("tenet"))

if faction<>empty then message=message&"<li>您已经加入了帮派！"
if experience< 5000 then message=message&"<li>您的经验值小于 5000 ！"
if money< 5000 then message=message&"<li>您的金币少于 5000 ！"
if factionname="" then message=message&"<li>帮派简称没有填写"
if Len(factionname)>7 then message=message&"<li>帮派简称最多7个字符"
if allname="" then message=message&"<li>帮派名称没有填写"
if tenet="" then message=message&"<li>帮派宗旨没有填写"
If not conn.Execute("Select id From [faction] where factionname='"&factionname&"' or buildman='"&Request.Cookies("username")&"'").eof Then  message=message&"<li>社区中已存在同名帮派<li>您已经建立过帮派"
if message<>"" then error(""&message&"")

conn.Execute("insert into faction (factionname,allname,tenet,buildman) values ('"&factionname&"','"&allname&"','"&tenet&"','"&Request.Cookies("username")&"')")

conn.execute("update [user] set faction='"&factionname&"',[money]=[money]-5000 where username='"&Request.Cookies("username")&"'")


message=message&"<li>创建帮派成功<li><a href=faction.asp>返回社区帮派</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&message&"<meta http-equiv=refresh content=3;url=faction.asp>")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif Request("menu")="xiuok" then

factionname=HTMLEncode(Request.Form("factionname"))
allname=HTMLEncode(Request.Form("allname"))
tenet=HTMLEncode(Request.Form("tenet"))


if factionname="" then message=message&"<li>帮派简称没有填写"
if Len(factionname)>7 then message=message&"<li>帮派简称最多7个字符"
if allname="" then message=message&"<li>帮派名称没有填写"
if tenet="" then message=message&"<li>帮派宗旨没有填写"
if Conn.Execute("Select buildman From [faction] where id="&id&"")(0)<>Request.Cookies("username")then message=message&"<li>您不是该帮的帮主无法修改信息"
If not conn.Execute("Select id From [faction] where factionname='"&factionname&"'").eof Then  message=message&"<li>社区中已存在同名帮派"

if message<>"" then error(""&message&"")

sql="select * from faction where id="&id&""
rs.Open sql,Conn,1,3
oldfactionname=rs("factionname")
rs("factionname")=factionname
rs("allname")=allname
rs("tenet")=tenet
rs.update
rs.close

conn.execute("update [user] set faction='"&factionname&"' where faction='"&oldfactionname&"'")
message=message&"<li>修改帮派成功<li><a href=faction.asp>返回社区帮派</a><li><a href=Default.asp>返回论坛首页</a>"
succeed(""&message&"<meta http-equiv=refresh content=3;url=faction.asp>")
end if



%>
<center>

<table border=0 width=97% align=center cellspacing=1 cellpadding=4 class=a2>
<tr class=a3>
<td height=25>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → 
<a href="faction.asp">社区帮派</a></td>
</tr>
</table><br>
<%
if Request("menu")="add" then

%>
<form method=post name=form action=faction.asp?menu=addok>

<table cellspacing=1 cellpadding=2 width=442 border=0 align="center" class=a2>
<tr class=a1>
<td width=526 colspan="2" align="center" height="25">
创建门派</td>
</tr>
<tr class=a3>
<td width=187 align="right">
<b><font color="0033CC">帮派简称：</font></b></td>
<td width=339>
<input maxlength=7 name=factionname size="10"> 最多7个字符</td>
</tr>
<tr class=a3>
<td width=187>
<div align="right"><b><font color="0033CC">帮派名称： </font></b></div>
</td>
<td width=339>
<input size=30 name=allname>
</td>
</tr>
<tr class=a3>
<td width=187 height=15>
<div align="right"><b><font color="0033CC">帮派宗旨： </font></b></div>
</td>
<td width=339 height=15>
<input size=40 name=tenet>
</td>
</tr>
<tr class=a3>
<td width=526 colspan=2 height=8>
<div align=center>
<input type=submit value=" 创 建 " name=Submit23>
<input type=reset value=" 重 填 " name=Submit24>
</div>
</td>
</tr>
<tr class=a3>
<td width=526 colspan=2 height=7>
<ol>
创建门派的必要条件：
<li>您的经验值必须 5000 以上
<li>需要扣除您身上 5000 金币作为门派基金 </li>
</td>
</tr>
</table>


</form>



<%
elseif Request("menu")="xiu" then
sql="select * from faction where id="&id&""
Set Rs=Conn.Execute(SQL)
%>

<form method=post action=faction.asp?menu=xiuok&id=<%=rs("id")%>>
<table cellpadding="2" cellspacing="1" width="70%" border="0" class=a2>

<tr>
<td colspan="2" height="25" align="center" class=a1>　　门派设定</td>
</tr>


<tr class=a3>
<td>　　帮派简称： </td>
<td>
<input size="20" maxlength=7 name="factionname" value="<%=rs("factionname")%>"> 
最多7个字符</td>
</tr>
<tr class=a3>
<td>　　帮派名称： </td>
<td><input size="30" name="allname" value="<%=rs("allname")%>"> </td>
</tr>
<tr class=a3>
<td>　　帮派宗旨： </td>
<td><input size="60" name="tenet" value="<%=rs("tenet")%>"> </td>
</tr>
<tr class=a3>
<td colSpan="2">
<div align="center">
<input type="submit" value=" 修 改 " name="Submit">
<input type="reset" value=" 重 填 " name="Submit2">
</div>
</td>
</tr>
</table>
</form>
<%
else
%>


<p>&nbsp;<a href="?menu=add"><img src="images/plus/niu05.gif" width="26" height="26" border="0"><img src="images/plus/cj.gif" width="95" height="26" border="0"></a>　　　　<a href="?menu=factionout&sessionid=<%=session.sessionid%>"><img src="images/plus/niu05.gif" width="26" height="26" border="0"><img src="images/plus/tc.gif" width="95" height="26" border="0"></a><br>
</p>

<SCRIPT>valigntop()</SCRIPT>
<table border="0" cellpadding="5" cellspacing="1" class=a2 width=97%>
<tr>
<td width="15%" align="center" height="25" class=a1>派 别</td>
<td width="55%" align="center" height="25" class=a1>宗 旨</td>
<td width="15%" align="center" height="25" class=a1>创始人</td>
<td width="15%" align="center" height="25" class=a1 colspan="2">动 作</td>
</tr>


<%
faction=Conn.Execute("Select faction From [user] where username='"&Request.Cookies("username")&"'")(0)

 
sql="select * from faction order by addtime Desc"
rs.Open sql,Conn,1


pagesetup=20 '设定每页的显示数量
rs.pagesize=pagesetup
TotalPage=rs.pagecount  '总页数
PageCount = cint(Request.QueryString("ToPage"))
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>0 then rs.absolutepage=PageCount '跳转到指定页数

i=0
Do While Not RS.EOF and i<pagesetup
i=i+1





%>

<tr>
<td width="10%" align="center" height="25" bgcolor="FFFFFF"> <a href=faction.asp?menu=look&id=<%=rs("id")%>><%=rs("factionname")%></a>
<td width="50%" align="center" height="25" bgcolor="FFFFFF"><%=rs("tenet")%>
<td width="10%" align="center" height="25" bgcolor="FFFFFF"><a href=Profile.asp?username=<%=rs("buildman")%>><%=rs("buildman")%></a>
<td width="10%" align="center" height="25" bgcolor="FFFFFF"><%
if faction=rs("factionname") then
response.write "<a onclick=checkclick('您确定要退出该帮派？') href=?menu=factionout&sessionid="&session.sessionid&">退出此帮</a>"
else
response.write "<a onclick=checkclick('您确定要加入该帮派？') href=?menu=factionadd&sessionid="&session.sessionid&"&id="&rs("id")&">加入此帮</a>"
end if

if Request.Cookies("username")=rs("buildman") then
%>
<br><a href="?menu=xiu&id=<%=rs("id")%>">修改资料</a><br><a onclick=checkclick('您确定要解散该帮派？') href="?menu=factiondel&sessionid=<%=session.sessionid%>&id=<%=rs("id")%>">解散此帮</a>
<%
end if
%>
</td>
</tr>

<%
RS.MoveNext
loop
RS.Close
%>

</table>
<SCRIPT>valignbottom()</SCRIPT>
Page：[
<script>
ShowPage(<%=TotalPage%>,<%=PageCount%>,"")
</script>
 ]<br>

<%
end if


htmlend
%>