<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=pet_conn.asp -->
<!--#include file=pet_config.asp-->
<%
DEF_BBS_HomeUrl = "../../"
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr

chentitle="宠物事务所"
chenbackasp="petcenter.asp"
stats="宠物事务所"
BBS_SiteHead DEF_SiteNameString&" "&DEF_BBS_Name,GBL_board_ID,">>&nbsp;<a href=petcenter.asp>宠物中心</a>&nbsp;>>&nbsp;" & chentitle

if GBL_CHK_User="" then
	AlarmErrmsg
else
    dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
    dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
    
    Dim Rs,SQL

	OpenDatabase	
    set rs=con.execute("select * from [leadbbs_user] where username='"&GBL_CHK_User&"' ")
      	
    money=rs("points")

	Form_userphoto = Rs("Userphoto")
	If DEF_AllDefineFace = 1 Then
		Form_FaceUrl = Rs("FaceUrl")
		Form_FaceWidth = Rs("FaceWidth")
		Form_FaceHeight = Rs("FaceHeight")
	End If    

    rs.close
    

    
    sql = "SELECT * FROM mypetdata WHERE username='"&GBL_CHK_User&"' "
    rs.open sql,connpet,1,3
    if rs.eof then
        call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
        else
        dim mypet,mypetsexmoney
        
        mypet = rs("mypet")
        mypetsexmoney = money
            
    end if
    rs.close
    
    select case lcase(request("action"))
        case "changename"
            if(len(request("petsname")) > DEF_PET_namelong) then
                call showmessage("你的宝宝名字是不是太长了","petother.asp")
            elseif(request("petsname")="") then
                call showmessage("你没有填写宝宝的名字","petother.asp")
            else
                '宝宝名字过滤
                if len(DEF_PET_nameexpt) > 0 then
                    if(instr(DEF_PET_nameexpt,"|")) > 0 then
                            dim tarr,inum,errorflag
                            tarr = split(DEF_PET_nameexpt,"|")
                            for inum = 0 to ubound(tarr)
                                if(instr(request("petsname"),tarr(inum))) > 0 then
                                    errorflag = 1
                                    Exit For
                                end if
                            next
                            if(errorflag = 1) then
                                call showmessage("你的宝宝名字含有系统规定不允许的字符，还是换一个吧~","petother.asp")
                            end if
                        else
                            if(instr(request("petsname"),DEF_PET_nameexpt)) > 0 then
                                call showmessage("你的宝宝名字含有系统规定不允许的字符，还是换一个吧~","petother.asp")
                            end if
                    end if
                end if
                
                SQL = "UPDATE mypetdata SET mypet='"& request("petsname") &"' WHERE username='"&GBL_CHK_User&"'"
                connpet.ExeCute(SQL)
                call showmessage("改名成功，你的宝宝改名为 "& request("petsname") &" ！","mypet.asp")
            end if
        case "changesex"
            if(mypetsexmoney<DEF_PET_changesexmoney) then
                call showmessage("对不起你没有那么多钱为宝宝做变性手术","mypet.asp")
            elseif(request("petsex") = "") then
                call showmessage("你还没有选定你宝宝的性别啊，请重新选择","petother.asp")
            elseif(request("petsex") = 1) then
                con.ExeCute("UPDATE [leadbbs_user] SET points=points-"&DEF_PET_changesexmoney&" WHERE username='"&GBL_CHK_User&"'")
                connpet.ExeCute("UPDATE mypetdata SET mypetsex=1 WHERE username='"&GBL_CHK_User&"'")
                call showmessage("改变性别成功，你的宝宝变为雄性 ！","mypet.asp")
            elseif(request("petsex") = 2) then
                con.ExeCute("UPDATE [leadbbs_user] SET points=points-"&DEF_PET_changesexmoney&" WHERE username='"&GBL_CHK_User&"'")
                connpet.ExeCute("UPDATE mypetdata SET mypetsex=2 WHERE username='"&GBL_CHK_User&"'")
                call showmessage("改变性别成功，你的宝宝变为雌性 ！","mypet.asp")
            end if
        case "openpk"
            if(request("openpetpk") = 1) then
                connpet.ExeCute("UPDATE mypetdata SET openpk=1 WHERE username='"&GBL_CHK_User&"'")
                call showmessage("成功开启PK模式！","mypet.asp")
            elseif(request("openpetpk") = 2) then
                connpet.ExeCute("UPDATE mypetdata SET openpk=2 WHERE username='"&GBL_CHK_User&"'")
                call showmessage("成功关闭PK模式！","mypet.asp")
            end if
        case "presentpet"
            if(GBL_CHK_User = request("newname")) then
              call showmessage("干吗啊，自己送宠物给自己！","petother.asp")
            else
                SQL = "SELECT username FROM [leadbbs_user] WHERE username='"&request("newname")&"'"
                rs.open SQL,con,1,3
                if rs.eof then
                    call showmessage("社区里面没有这个人","petother.asp")
                end if
                rs.close
                SQL = "SELECT username FROM mypetdata WHERE username='"&request("newname")&"'"
                rs.open SQL,connpet,1,3
                if not rs.eof then
                    call showmessage("他已经有宠物了，你还是把宠物留给自己吧~","petother.asp")
                    else
                    connpet.ExeCute("UPDATE mypetdata SET username='"&request("newname")&"' WHERE username='"&GBL_CHK_User&"'")
                    con.ExeCute("INSERT INTO LeadBBS_InfoBox (ToUser, FromUser, Title, Content, SendTime,ReadFlag) values('"&request("newname")&"','宠物管理员','"&GBL_CHK_User&" 送给你一个宠物，快来看看','你得到了一个宠物宝宝,快去宠物中心看看','"&GetTimeValue(now)&"','0')")
                    con.execute("update leadbbs_user set messageflag=1 where username='"&request("newname")&"'")'新消息提示
                end if
                rs.close
            end if
            call showmessage("赠送成功，你的宝宝已经送给了 "&request("newname")&" ！","petshop.asp")
    end select
%>
<% If GBL_TableHeadString <> "" Then %><table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableHeadString%></td></tr></table><% End If %>
<table width="<%=DEF_BBS_ScreenWidth%>" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
    <td height=27 align="center" class=tbhead2><b><font class=HeadFont><%=stats%></font></b></td>
  </tr>
  <tr>
    <td class=tbbg1>
    
            <table width="100%" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <td><table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
                    <tr>
                      <td width="100%"><div align="center">我的资料</div></td>
                    </tr>
                    <tr>
                      <td><div align="center">
					<%
					If isNull(Form_FaceUrl) Then Form_FaceUrl = ""
					If DEF_AllDefineFace = 0 or Trim(Form_FaceUrl) = "" Then%>
					<img src=<%=DEF_BBS_HomeUrl%>images/face/<%=string(4-len(cstr(Form_userphoto)),"0")&Form_userphoto%>.gif align=absmiddle width=62 height=62>
					<%Else%>
						<img src="<%=htmlencode(replace(Form_FaceUrl,"../","../../"))%>" align=absmiddle width=<%=Form_FaceWidth%> height=<%=Form_FaceHeight%>>
					<%End If%>
					<br><img src=../images/blank.gif width=2 height=5><br>                      
                      </div></td>
                    </tr>
                    <tr>
                    <td> <div align="center">
                        <nobr>用户<%=DEF_PointsName%>: <%=money%></nobr>
                        </div></td>
                    </tr>
                  </table>
                  <br>
                  <table width="90%"  border="0" align="center" cellpadding="3" cellspacing="3">
                    <tr>
                      <td><div align="center"></div>
<!-- #include file=petnav.asp --></td>
                    </tr>
                  </table></td>
                <td><form action="petother.asp" mtehod=post>
                    <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr> 
                        <td width="29%"> <div align="right">为宝宝改名字： </div></td>
                        <td width="71%"> <input name="petsname" type="text" value="<%=mypet%>" size="20" maxlength="16"> 
                          &nbsp;&nbsp;&nbsp; <input type="hidden" name="action" value="changename"> 
                          <input type="submit" value="改名"> &nbsp;&nbsp;</td>
                      </tr>
                    </table>
                  </form>
<form action="petother.asp" mtehod=post>
                    <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr>
      <td width="29%"><div align="right">为宝宝做变性手术：</div></td>
      <td width="71%"><input type="radio" name="petsex" value="1"> 雄&nbsp;&nbsp;&nbsp;<input type="radio" name="petsex" value="2"> 雌&nbsp;&nbsp;&nbsp; 
          <input type="hidden" name="action" value="changesex">
          <input type="submit" name="Submit" value="改变性别">
        &nbsp;&nbsp;&nbsp; <font color="#FF0000">注意：需要花费<%=DEF_PET_changesexmoney%><%=DEF_PointsName%></font> </td>
    </tr>
  </table>
</form>
<form action="petother.asp" mtehod=post>
                    <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr>
      <td width="29%"><div align="right">把我的宝宝送给：</div></td>
      <td width="71%"><input name="newname" type="text" size="20" maxlength="16">&nbsp;&nbsp;&nbsp; 
          <input type="hidden" name="action" value="presentpet">
          <input type="submit" name="Submit" value="赠送宠物">
        </td>
    </tr>
  </table>
</form>
<form action="petother.asp" mtehod=post>
                    <table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr>
              <td width="29%"> <div align="right">是否开启PK： </div></td>
                        <td width="71%"> 
                          <input type="radio" name="openpetpk" value="1">
                          开启&nbsp;&nbsp;&nbsp; 
                          <input type="radio" name="openpetpk" value="2">
                          关闭 &nbsp;&nbsp; 
                          <input type="hidden" name="action" value="openpk">
                  <input type="submit" value="确定">
                          &nbsp;&nbsp;&nbsp;</td>

            </tr>
          </table></form></td>
              </tr>
            </table>
            

	</td></tr></table>
<% If GBL_TableBottomString <> "" Then %><table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableBottomString%></td></tr></table><% End If %>
<%    
end if

SiteBottom 
If GBL_SiteBottomString <> "" Then Response.Write GBL_SiteBottomString
%>