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

    dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
    dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
    
    Dim rs_pet,sql_pet

	set rs_pet=conn.execute("select money from [user] where username='"&Request.Cookies("username")&"'")
      	
    money=rs_pet("money")

	    

    rs_pet.close
    

    
    sql_pet = "SELECT * FROM mypetdata WHERE username='"&Request.Cookies("username")&"'"
    rs_pet.open sql_pet,conn_pet,1,3
    if rs_pet.eof then
       error("你还没有宠物啊，<a href=petshop.asp>快攒钱去买吧~</a>")
        else
        dim mypet,mypetsexmoney
        
        mypet = rs_pet("mypet")
        mypetsexmoney = money
            
    end if
    rs_pet.close
    
    select case lcase(request("action"))
        case "changename"
            if(len(request("petsname")) > DEF_PET_namelong) then
                message="<li>你的宝宝名字是不是太长了"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            elseif(request("petsname")="") then
                message"<li>你没有填写宝宝的名字"
				succeed(message&"<meta http-equiv=refresh content=3;url='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
                                message="<li>你的宝宝名字含有系统规定不允许的字符，还是换一个吧~"
								succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                            end if
                        else
                            if(instr(request("petsname"),DEF_PET_nameexpt)) > 0 then
                                message="<li>你的宝宝名字含有系统规定不允许的字符，还是换一个吧~"
								succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                            end if
                    end if
                end if
                 Set rs = Server.CreateObject("ADODB.Recordset")
					sql="select * from [user] where username='"&Request.Cookies("username")&"'"
rs.Open sql,Conn,1,3
rs("mypet")="<a href=petview.asp?username="&Request.Cookies("username")&" target=_blank>"&request("petsname")&"</a>"
 rs.update
                sql_pet = "UPDATE mypetdata SET mypet='"& request("petsname") &"' WHERE username='"&Request.Cookies("username")&"'"
                conn_pet.ExeCute(sql_pet)
                message="<li>改名成功，你的宝宝改名为 "& request("petsname") &" ！"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            end if
        case "changesex"
            if(mypetsexmoney<DEF_PET_changesexmoney) then
                message="<li>对不起你没有那么多钱为宝宝做变性手术"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            elseif(request("petsex") = "") then
                message="<li>你还没有选定你宝宝的性别啊，请重新选择"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            elseif(request("petsex") = 1) then
              
					Set rs = Server.CreateObject("ADODB.Recordset")
					sql="select * from [user] where username='"&Request.Cookies("username")&"'"
rs.Open sql,Conn,1,3
 rs("money")=rs("money")-DEF_PET_changesexmoney
 rs.update
				
				
                conn_pet.ExeCute("UPDATE mypetdata SET mypetsex=1 WHERE username='"&Request.Cookies("username")&"'")
                message="<li>改变性别成功，你的宝宝变为雄性 ！"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            elseif(request("petsex") = 2) then

                Set rs = Server.CreateObject("ADODB.Recordset")
					sql="select * from [user] where username='"&Request.Cookies("username")&"'"
rs.Open sql,Conn,1,3
 rs("money")=rs("money")-DEF_PET_changesexmoney
 rs.update
                conn_pet.ExeCute("UPDATE mypetdata SET mypetsex=2 WHERE username='"&Request.Cookies("username")&"'")
                message="<li>改变性别成功，你的宝宝变为雌性 ！"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            end if
        case "openpk"
            if(request("openpetpk") = 1) then
                conn_pet.ExeCute("UPDATE mypetdata SET openpk=1 WHERE username='"&Request.Cookies("username")&"'")
                message="<li>成功开启PK模式！"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            elseif(request("openpetpk") = 2) then
                conn_pet.ExeCute("UPDATE mypetdata SET openpk=2 WHERE username='"&Request.Cookies("username")&"'")
                message="<li>成功关闭PK模式！"
				succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
            end if
        case "presentpet"
		newname=HTMLEncode(Request("newname"))
		if Request.Cookies("username") = newname then
              message="<li>干吗啊，自己送宠物给自己！"
			  succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                else
                sql = "SELECT username FROM [user] WHERE username='"&request("newname")&"'"
                set rs = conn.ExeCute(sql)
                if rs.eof then
                    message="<li>论坛里面没有这个人"
					succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                end if
                rs.close
               
                sql_pet = "SELECT username FROM mypetdata WHERE username='"&request("newname")&"'"
                set rs_pet = conn_pet.ExeCute(sql_pet)
                if not rs_pet.eof then
                    message="<li>他已经有宠物了，你还是把宠物留给自己吧~"
					succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                    else
                    conn_pet.ExeCute("UPDATE mypetdata SET username='"&request("newname")&"' WHERE username='"&Request.Cookies("username")&"'")

Set rs = Server.CreateObject("ADODB.Recordset")
					sql="select * from [user] where username='"&Request.Cookies("username")&"'"
rs.Open sql,Conn,1,3
rs("mypet")="主人不要我了"
 rs.update
 Set rs = Server.CreateObject("ADODB.Recordset")

sql="select * from [user] where username='"&request("newname")&"'"
rs.Open sql,Conn,1,3
rs("mypet")="<a href=petview.asp?username="&request("newname")&" target=_blank>"&mypet&"</a>"
 rs.update

conn.Execute("insert into message (author,incept,content) values ('宠物管理员','"&request("newname")&"','【宠物管理员】："&Request.Cookies("username")&"送给你一个宠物，并且留下留言："&request("message")&"，快来看看http://www.waterbbs.net/petcenter.asp')")

conn.execute "update [user] set newmessage=newmessage+1 where username='"&request("newname")&"'"

				
					         message="<li>赠送成功，你的宝宝已经送给了 "&request("newname")&" ！"
			succeed(message&"<meta http-equiv=refresh content=3;url='petother.asp'")
                end if
                rs.close
            end if
            
    end select
%>
<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="petcenter.asp">宠物中心</a></td>
</tr>
</table><br>

    
 <table width="100%" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <td>
                  <table width="90%"  border="0" align="left" cellpadding="3" cellspacing="1">
                    <tr>
                      <td><div align="center"></div>
<!-- #include file=petnav.asp --></td>
                    </tr>
                  </table></td>
                <td>
                
                <form action="petother.asp" mtehod=post>
                    <table width="96%"  border="0" cellpadding="3" cellspacing="1" class=a2>
                      <tr class=a3> 
                        <td width="20%"> <div>为宝宝改名字： </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="96%"  border="0" cellpadding="3" cellspacing="1" class=a2>
                      <tr class=a3>
      <td width="20%"><div>为宝宝做变性手术：</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="96%"  border="0" cellpadding="3" cellspacing="1" class=a2>
                      <tr class=a3>
      <td width="20%"><div>把我的宝宝送给：</div></td>
      <td width="71%"><input name="newname" type="text" size="20" maxlength="16">&nbsp;&nbsp;&nbsp; 
          <input type="hidden" name="action" value="presentpet">
		  <br>
		  <Br>
		  <textarea name="message" size="20">赠送复言</textarea>
          <input type="submit" name="Submit" value="赠送宠物">
        </td>
    </tr>
  </table>
</form>
<form action="petother.asp" mtehod=post>
                    <table width="96%"  border="0" cellpadding="3" cellspacing="1" class=a2>
                      <tr class=a3>
              <td width="20%"> <div>是否开启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>
<table width="96%"  border="0" cellpadding="3" cellspacing="1" class=a2>
                      <tr class=a3>
              <td width="20%">宠物操作：</td>
                        <td width="71%">&nbsp;&nbsp;<a href=petorphanage.asp?action=del>丢弃宠物</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=petorphanage.asp?action=adopt>领养宠物</a>&nbsp;&nbsp;</td>

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

	<%
htmlend
%>
