<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<%
 '=========================================================
' File: klatchuser.asp
' Version:3.0
' Date: 2005-9-17
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================
dim kid,action
response.buffer=true
Kid=checkStr(Request("kid"))
action=checkStr(Request("action"))
%>
<STYLE type=text/css>
TD {
	FONT-SIZE: 12px; COLOR: #d66b00; FONT-FAMILY: "宋体"
}
</STYLE>
<%Select Case action
	Case "photo"
		Call show_photo()
	Case "user"
		Call show_user()
	Case "join"
		Call show_join()
	Case "savephoto"
		Call savephoto()	
End Select
if founderr then call Mslove_error()

sub show_photo()''精彩图片%>
<table width="340" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  <%dim iph,klphotoid
	set rs=server.createobject("adodb.recordset")
sql="select Klphoto from Ms_klatch where Kid="&kid&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
klphotoid=rs("Klphoto")
else
klphotoid=""
end if
rs.close
	set rs=server.createobject("adodb.recordset")
sql="select Filename,Readme from Ms_Upfile where FID in ("&klphotoid&") order by Fid desc"
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
iph=0
do while not rs.eof%>
    <td align="center"> 
      <table width="99" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="371" height="57"><a href=<%=SaveUpFilesPath&"/"&rs("Filename")%> target=_blank title=点击放大><img src=<%=SaveUpFilesPath&"/"&rs("Filename")%> width="102" height="57" border="0"></a></td>
        </tr>
        <tr> 
          <td height="18" align="center"><%=left(rs("Readme"),5)%></td>
        </tr>
      </table>
	  
    </td>
<%iph=iph+1
if iph>0 and iph mod 3=0 then
response.Write("</tr><tr>")
end if
if iph>=6 then exit do
rs.movenext
  loop
  else
  response.Write("<img src=Skins/Default/klatch/xx.jpg>")
  end if
  rs.close%>
  </tr>
</table>
<%end sub


sub show_user()''报名用户
dim Countnum
sql="select Count(id) from [Ms_kljoin] where Kid="&Kid&""
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
Countnum=rs(0)
else
Countnum=0
end if
rs.close%>
<TABLE cellSpacing=0 cellPadding=0 width=358 align=center border=0>
  <TBODY>
    <TR> 
      <TD height="24"><STRONG>[目前报名人数]：<%=Countnum%>人</STRONG></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=1 cellPadding=1 width=358 align=center bgColor=#b5b1ca 
border=0>
  <TBODY>
    <TR> 
      <TD bgColor=#ffffff> <TABLE cellSpacing=1 cellPadding=3 width="100%" bgColor=#ffffff 
        border=0>
          <TBODY>
            <TR align=middle> 
              <TD bgColor=#d9d3ed>报名状态</TD>
              <TD bgColor=#d9d3ed>用户名</TD>
              <TD bgColor=#d9d3ed>照片</TD>
            </TR>
            <%dim Checked,joinname,Klphoto,ik
			set rs=server.createobject("adodb.recordset")
sql="select top 4 k.username,k.checked,u.UserPhoto from Ms_kljoin k inner join Ms_User u on k.Username=u.Username where k.Kid="&kid&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
ik=0
do while not rs.eof
Checked=rs("Checked")
joinname=rs("Username")
Klphoto=rs("UserPhoto")
%>
            <TR align=middle bgColor=#f4f5f9> 
              <TD><%if Checked=0 then
			  response.Write("等待审核")
			  elseif Checked=1 then
			  response.Write("正式参加")
			  end if%></TD>
              <TD><a href=dispuser.asp?username=<%=joinname%>><%=joinname%></a></TD>
              <TD><%if Klphoto<>"" then
			  response.Write("<img src="&Klphoto&" border=0 height=60 width=60>")
			  else
			  response.Write("<img src=Skins/Default/klatch/strnophoto.gif border=0 height=60 width=60>")
			  end if%> </TD>
            </TR>
			<%ik=ik+1
  rs.movenext
  loop
  if ik=4 then
  response.Write("<TR align=middle bgColor=#f4f5f9><TD colspan=3>更多>>></TD></tr>")
  end if
  else
  response.Write("")
  end if
  %>
          </TBODY>
        </TABLE></TD>
    </TR>
  </TBODY>
</TABLE>
<%rs.close
end sub

sub show_join()''报名
if Cint(GroupSetting(181))=0 then
	ErrMsg=ErrMsg+"<Br>"+"<li>您没有参加聚会的权限，请与管理员联系。"
   	FoundErr=True
end if
dim Joinname,usersex,youage
sql="select Username,usersex,UserBirthday from [Ms_user] where Username='"&trim(MemberName)&"'"''判断用户是否站内用户
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
Joinname=rs("Username")
usersex=rs("usersex")
youage=rs("UserBirthday")
else
  	errmsg=errmsg+"<br>"+"<li>对不起，用户名不存在。"
	founderr=true
end if
rs.close

dim Joinnum,Enddate,Quota,Klatchsex,Minage,Maxage,oksex,klname
sql="select Joinnum,Enddate,Quota,Klatchsex,Minage,Maxage,Username from [Ms_klatch] where Kid="&Kid&""''读取聚会参数
set rs=conn.execute(sql)
if rs.eof or rs.bof then
  	errmsg=errmsg+"<br>"+"<li>对不起，没有找到该聚会。"
	founderr=true
else
Klname=rs("Username")
Joinnum=rs("Joinnum")
Enddate=rs("Enddate")
Quota=rs("Quota")
Klatchsex=rs("Klatchsex")
Minage=rs("Minage")
Maxage=rs("Maxage")
end if
rs.close
if Klname=Joinname then
  	errmsg=errmsg+"<br>"+"<li>自己不能报名自己的聚会哦。"
	founderr=true
end if
if Joinnum=Quota then
  	errmsg=errmsg+"<br>"+"<li>对不起，该聚会报名已满。"
	founderr=true
end if
if datediff("d",Enddate,date())>1 then
  	errmsg=errmsg+"<br>"+"<li>对不起，该聚会报名时间已经过。"
	founderr=true
end if
if Klatchsex<>2 and Klatchsex<>usersex then
  	errmsg=errmsg+"<br>"+"<li>对不起，该聚会限制报名性别。"
	founderr=true
end if
if datediff("yyyy",youage,Now())<Minage or datediff("yyyy",youage,Now())>Maxage then
  	errmsg=errmsg+"<br>"+"<li>对不起，该您的年龄不符合聚会的年龄要求。"
	founderr=true
end if
if founderr then exit sub
set rs=server.createobject("adodb.recordset")
sql="select * from Ms_kljoin where Username='"&trim(membername)&"' and Kid="&Kid&""
rs.Open sql,conn,1,3
if rs.eof or rs.bof then
rs.addnew()
rs("Kid")=Kid
rs("Username")=trim(MemberName)
rs("Jointime")=now()
rs.update()
rs.close
conn.execute("update Ms_klatch set Joinnum=Joinnum+1 where kid="&kid&"")
conn.execute("update Ms_user set UserWealth=UserWealth "&GroupSetting(182)&Cint(GroupSetting(183))&",UserEP=UserEP "&GroupSetting(184)&Cint(GroupSetting(185))&",UserCP=UserCP "&GroupSetting(186)&Cint(GroupSetting(187))&" where Username='"&trim(membername)&"")
response.Redirect("klview.asp?id="&kid&"")
else
  	errmsg=errmsg+"<br>"+"<li>对不起，你曾报过名，请不要重复报名。"
	founderr=true
	rs.close
end if
end sub

sub savephoto()''保存图片数据
dim Klphotoid,Maxphoto,Title
Title=checkStr(Request("Title"))
if Title="" or strLength(Title)>50 then
	errmsg=errmsg+"<br>"+"<li>图片说明文字不能为空长度不大于50个字符。"
	founderr=true
end if
if founderr=true then exit sub
set rs=server.createobject("adodb.recordset")''读出数据表中的图片数组
sql="select Klphoto from Ms_klatch where Kid="&Kid&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
Klphotoid=rs("Klphoto")
rs.close
end if
Klphotoid=split(Klphotoid,",")
Maxphoto=ubound(Klphotoid)
sql="update Ms_Upfile set Readme='"&title&"' where Fid="&Klphotoid(Maxphoto)&""
conn.execute(sql)
sucmsg=sucmsg+"<br>"+"<li><b>您成功提交图片说明。</b>"
call Mslove_suc()
end sub
%>
</body>
</html> 