<!--#include file="Inc.asp"-->
<!-- #include file=pet_conn.asp -->
<%
If Not BBS94KK.Founduser Then BBS94KK.GoToErr(10)
BBS94KK.Head("宠物宝贝 → 宠物事务所")
    dim  money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
    dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
    
   Dim Rs,SQL

	set rs=bbs94kk.execute("select * from [kk_User] where  name='"&bbs94kk.myname &"'")
      	
    money=rs("coin")
    Form_userphoto = Rs("pic")
	DEF_PointsName="金币"

		Form_FaceWidth = Rs("picW")
		Form_FaceHeight = Rs("picH")
    rs.close    
	

	
	sql = "SELECT * FROM mypetdata WHERE username='"&bbs94kk.myname&"' "
	rs.open sql,connpet,1,3
	if rs.eof then
		call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
		else
		dim mypet,mypetsexmoney,pknow
		
		mypet = rs("mypet")
		mypetsexmoney = money
		pknow=rs("pktime")
			
	end if
	
	select case request("action")
		case "changename"
			if(len(request("petsname")) > DEF_PET_namelong) then
				SQL = "UPDATE mypetdata SET mypet='请重新填写' WHERE username='"&bbs94kk.myname&"'"
				connpet.ExeCute(SQL)
				call alter("你的宝宝名字是不是太长了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
				dim petname
				petname = request("petsname")
				select case request("smart")
					case 1
						petname = "<font color=red>"& request("petsname") &"</font>"
					case 2
						petname = "<font color=blue>"& request("petsname") &"</font>"
					case 3
						petname = "<font color=green>"& request("petsname") &"</font>"
					case 4
						petname = "<font color=purple>"& request("petsname") &"</font>"
				end select
				SQL = "UPDATE mypetdata SET mypet='"& petname &"' WHERE username='"&bbs94kk.myname&"'"
				connpet.ExeCute(SQL)
				call showmessage("改名成功，你的宝宝改名为 "& petname &" ！","petmypet.asp")
			end if
		case "changesex"
			if(mypetsexmoney<DEF_PET_changesexmoney) then
				call showmessage("对不起你没有那么多钱为宝宝做变性手术","petmypet.asp")
			elseif(request("petsex") = "") then
				call showmessage("你还没有选定你宝宝的性别啊，难道要做人妖？","petother.asp")
			elseif(request("petsex") = 1) then
				bbs94kk.execute("UPDATE [kk_user] SET coin=coin-"&DEF_PET_changesexmoney&" WHERE name='"&bbs94kk.myname&"'")
Session(CacheName & "MyInfo") = Empty
				connpet.ExeCute("UPDATE mypetdata SET mypetsex=1 WHERE username='"&bbs94kk.myname&"'")
				call showmessage("改变性别成功，你的宝宝变为雄性 ！","petmypet.asp")

			elseif(request("petsex") = 2) then
				bbs94kk.execute("UPDATE [kk_user] SET coin=coin-"&DEF_PET_changesexmoney&" WHERE name='"&bbs94kk.myname&"'")
Session(CacheName & "MyInfo") = Empty
				connpet.ExeCute("UPDATE mypetdata SET mypetsex=2 WHERE username='"&bbs94kk.myname&"'")
				call showmessage("改变性别成功，你的宝宝变为雌性 ！","petmypet.asp")

			end if
		case "openpk"
'if DateDiff("h", pknow, now())<12 then
'call showmessage("刚打完人就想溜？再等等吧！","petmypet.asp")
'else
			if(request("openpetpk") = 1) then
				connpet.ExeCute("UPDATE mypetdata SET openpk=1 WHERE username='"&bbs94kk.myname&"'")
				call showmessage("成功开启PK模式！","petmypet.asp")
			elseif(request("openpetpk") = 2) then
				connpet.ExeCute("UPDATE mypetdata SET openpk=2 WHERE username='"&bbs94kk.myname&"'")
				call showmessage("成功关闭PK模式！","petmypet.asp")
			end if
'end if
        case "presentpet"
            if(BBS94KK.Myname = request("newname")) then
              call showmessage("干吗啊，自己送宠物给自己！","petother.asp")
            else
                SQL = "SELECT username FROM [kk_user] WHERE name='"&replace(request("newname"),"'","''")&"'"
                set rs = BBS94KK.Execute(SQL)
                if rs.eof then
                    call showmessage("坊里面没有这个人","petother.asp")
                end if
                rs.close
                dim rs1
                SQL = "SELECT username FROM mypetdata WHERE username='"&replace(request("newname"),"'","''")&"'"
                set rs1 = connpet.ExeCute(SQL)
                if not rs1.eof then
                    call showmessage("他已经有宠物了，你还是把宠物留给自己吧~","petother.asp")
                    else
                    connpet.ExeCute("UPDATE mypetdata SET username='"&replace(request("newname"),"'","''")&"' WHERE username='"&bbs94kk.myname&"'")
                    
                end if
                rs1.close
            end if
            call showmessage("赠送成功，你的宝宝已经送给了 "&request("newname")&" ！","petshop.asp")
		case "setimg"
			if rs("imgset")=-1 then
				if not isnumeric(request("imgset")) then
					call showmessage("等级必须是数字！","petother.asp")
				elseif cint(request("imgset"))>cint(rs("mypetlevel")/10) then
					call showmessage("等级不得超过宠物现有等级！","petother.asp")
				elseif mypetsexmoney < DEF_Pet_ImgMoney then
					call showmessage("你的钱不够啊！","petother.asp")
				else
					bbs94kk.execute("UPDATE [kk_user] SET coin=coin-"& DEF_Pet_ImgMoney &" WHERE name='"&bbs94kk.myname&"'")
Session(CacheName & "MyInfo") = Empty

					connpet.ExeCute("UPDATE mypetdata SET imgset="&cint(request("imgset"))&" WHERE username='"&bbs94kk.myname&"'")
					response.redirect "petother.asp"
				end if
			else
				connpet.ExeCute("UPDATE mypetdata SET imgset=-1 WHERE username='"&bbs94kk.myname&"'")
				response.redirect "petother.asp"
			end if
	end select
%>
<table width="760" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
    <td height=27 align="center" class=tbhead2></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">
					<img border='0' src='<%=Form_userphoto%>' width="<%=Form_FaceWidth%>" height="<%=Form_Faceheight%>">
					<br><img src=images/blank.gif width=2 height=5><br>
                    </div></td>
					
                    </tr>
                    <tr>
                    <td> <div align="center">
                        <nobr>用户金币: <%=money%><%=DEF_PointsName%></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>
                  <div align="center">
                    <center>
                  <table width="90%" border="0" cellspacing="0" cellpadding="0" height="25" bordercolor="#CCCCCC">
                    <tr>
                      <td height="30">
                        <form action="petother.asp" mtehod="post">
                          <table width="100%" border="0" align="center" cellpadding="3" cellspacing="3">
                            <tr>
                              <td width="25%">
                                <div align="right">
                                  <p align="left">
                                  为宝宝改名字：
                                </div>
                              </td>
                              <td width="71%"><input name="petsname" type="text" value="<%=mypet%>" size="17" 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="25%">
                                <div align="right">
                                  <p align="left">为宝宝做变性：
                                </div>
                              </td>
                              <td width="71%"><input type="radio" name="petsex" value="1" checked> 
                                雄&nbsp;&nbsp;&nbsp;<input type="radio" name="petsex" value="2">    
                                雌&nbsp;&nbsp;&nbsp; <input type="hidden" name="action" value="changesex">&nbsp; 
                                <input type="submit" name="Submit" value="改变">&nbsp;&nbsp;&nbsp;&nbsp; 
                                <font color="#FF0000">注意：需要花费<%=DEF_PET_changesexmoney%>
                                <%=DEF_PointsName%>   
                                </font></td>
                            </tr>
                          </table>
                        </form>
                        <form action="petother.asp" mtehod="post">
                          <input type="hidden" name="action" value="openpk">
                          <table width="100%" border="0" align="center" cellpadding="3" cellspacing="3">
                            <tr>
                              <td width="25%">
                                <div align="right">
                                  <p align="left">是否接受挑战：
                                </div>
                              </td>
                              <td width="71%"><input type="radio" name="openpetpk" value="1" checked> 
                                开&nbsp;&nbsp;&nbsp; <input type="radio" name="openpetpk" value="2">  
                                关 &nbsp;&nbsp; <input type="submit" value="确定"> 
                                &nbsp;&nbsp;&nbsp;</td>  
                            </tr>
                          </table>
                        </form>
                      </td>
                    </tr>
                  </table>
                    </center>
                  </div>
                </td>
              </tr>
            </table>
            

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


<%bbs94kk.footer()%>
