<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="YD_pet_conn.asp"-->

<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr,action
chentitle="宠物管理区"
Dv_plus.name="petcenter"
'Dv_plus.checklogin()
Dvbbs.LoadTemplates("")
Dvbbs.Stats="宠物管理区"
Dvbbs.Nav()
Dvbbs.Head_var 0,"","宠物中心","YD_petcenter.asp"

if not dvbbs.master then
	call showmessage("你不是社区管理员，不能进入宠物管理区~","YD_petcenter.asp")
end if

if DvBBS.UserId = 0 then
	AlarmErrmsg
else
	dim money,smoney,saveday,allmoney,Chk1,Chk2,daikuang,dkdu,daiday
	dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
	dim rs,sql
	action = request("action")
	if action = "" then 
		action = "config"
	end if

	select case action
		case "addnew"
			SQL="INSERT INTO petshopdata (pet, newpetclass, pettxt, petsx)VALUES ('"&request("newname")&"', '"&request("newclass")&"', '"&request("newtxt")&"', '"&request("newsx")&"')"
			response.write SQL
			connpet.execute(SQL)
			response.redirect "YD_pet_config_edit.asp?action=add"
			response.end
		case "changeconfig" 
			config_file

			sub config_file()
			dim filetype,file_name
			DEF_PET_close = request("DEF_PET_close")	 '宠物开关
			DEF_PET_namelong = request("DEF_PET_namelong")
			DEF_PET_basichp = request("DEF_PET_basichp")
			DEF_PET_basicsp = request("DEF_PET_basicsp")
			DEF_PET_basicsp2 = request("DEF_PET_basicsp2")
			DEF_PET_eggmoney = request("DEF_PET_eggmoney")
			DEF_PET_relmoney = request("DEF_PET_relmoney")
			DEF_PET_basichpmoney = request("DEF_PET_basichpmoney")
			DEF_PET_basicspmoney = request("DEF_PET_basicspmoney")
			DEF_PET_basicexpmoney = request("DEF_PET_basicexpmoney")
			DEF_PET_livemoney = request("DEF_PET_livemoney")
			DEF_PET_basicusehp = request("DEF_PET_basicusehp")
			DEF_PET_basicusesp = request("DEF_PET_basicusesp")
			DEF_PET_basicuseexp = request("DEF_PET_basicuseexp")
			DEF_PET_petpkhp = request("DEF_PET_petpkhp")
			DEF_PET_petpktime = request("DEF_PET_petpktime")
			DEF_PET_petpklv = request("DEF_PET_petpklv")
			DEF_PET_changesexmoney = request("DEF_PET_changesexmoney")
			DEF_PET_perswordmoney = request("DEF_PET_perswordmoney")
			DEF_PET_pernecklacemoney = request("DEF_PET_pernecklacemoney")
			DEF_PET_perheadmoney = request("DEF_PET_perheadmoney")
			DEF_PET_perbodyemoney = request("DEF_PET_perbodyemoney") 
			DEF_PET_perfootmoney = request("DEF_PET_perfootmoney")
			DEF_PET_nameexpt = request("DEF_PET_nameexpt")
			DEF_PET_newtopicexp = request("DEF_PET_newtopicexp")
			DEF_PET_replytopicexp = request("DEF_PET_replytopicexp")
			DEF_PET_sendbattlemsg = request("DEF_PET_sendbattlemsg")
			DEF_PointsName = request("DEF_PointsName")
			DEF_UpWeopMoney = request("DEF_UpWeopMoney")
			DEF_Pet_ImgMoney = request("DEF_Pet_ImgMoney")

			dim errorflag
			if not isnumeric(DEF_PET_namelong) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basichp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicsp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicsp2) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_eggmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_relmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basichpmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicspmoney) then
 				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicexpmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_livemoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicusehp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicusesp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_basicuseexp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_petpkhp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_petpktime) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_petpklv) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_changesexmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_perswordmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_pernecklacemoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_perheadmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_perbodyemoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_perfootmoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_newtopicexp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_replytopicexp) then
				errorflag = 1
			elseif  not isnumeric(DEF_PET_sendbattlemsg) then
				errorflag = 1
			elseif  not isnumeric(DEF_UpWeopMoney) then
				errorflag = 1
			elseif  not isnumeric(DEF_Pet_ImgMoney) then
				errorflag = 1  
			elseif  DEF_PointsName="" then
				errorflag = 1
			end if  

			if errorflag=1 then
				call showmessage("至少有一项设置填写有误，请按要求填写~","YD_pet_config_edit.asp")
			end if

			filetype=filetype&"<"&""&"%" & vbcrlf & _
			"dim DEF_PET_version,DEF_PET_close,DEF_PET_message,DEF_PET_namelong,DEF_PET_basichp,DEF_PET_basicsp,DEF_PET_basicsp2" & vbcrlf & _
			"dim DEF_PET_eggmoney,DEF_PET_basichpmoney,DEF_PET_basicspmoney,DEF_PET_basicexpmoney" & vbcrlf & _
			"dim DEF_PET_livemoney,DEF_PET_basicusehp,DEF_PET_basicusesp,DEF_PET_basicuseexp,DEF_PET_petpkhp" & vbcrlf & _
			"dim DEF_PET_petpktime,DEF_PET_petpklv,DEF_PET_changesexmoney,DEF_PET_perswordmoney,DEF_PET_pernecklacemoney" & vbcrlf & _
			"dim DEF_PET_perheadmoney,DEF_PET_perbodyemoney,DEF_PET_perfootmoney,DEF_PET_nameexpt,DEF_PET_author" & vbcrlf & _
			"dim DEF_PET_newtopicexp,DEF_PET_replytopicexp,DEF_PET_sendbattlemsg,DEF_PointsName,DEF_UpWeopMoney,DEF_Pet_ImgMoney" & vbcrlf & _
			"dim DEF_PET_relmoney" & vbcrlf & _
			"   " & vbcrlf & _
			"DEF_PET_author = ""梦源网络论坛""              '程序修改" & vbcrlf & _
			"DEF_PET_version = ""3.0""             '程序版本" & vbcrlf & _
			"DEF_PET_close = "&DEF_PET_close&"                     '宠物中心是否开启" & vbcrlf & _
			"DEF_PET_message = """"                  '保留" & vbcrlf & _
			"DEF_PET_namelong = "&DEF_PET_namelong&"                 '宠物的名字长度10" & vbcrlf & _
			"DEF_PET_nameexpt = """&DEF_PET_nameexpt&"""                 '宠物名字过滤字符，不允许的宠物名字" & vbcrlf & _
			"DEF_PET_basichp = "&DEF_PET_basichp&"                 '宠物的体力值,建议100" & vbcrlf & _
			"DEF_PET_basicsp = "&DEF_PET_basicsp&"               '宠物的饥饿值,建议10000" & vbcrlf & _
			"DEF_PET_basicsp2 = "&DEF_PET_basicsp2&"                '每天宠物消耗饥饿值,建议500，注意不要超过SP的基本量" & vbcrlf & _
			"DEF_PET_eggmoney = "&DEF_PET_eggmoney&"                  '基本宠物蛋价格" & vbcrlf & _
			"DEF_PET_relmoney = "&DEF_PET_relmoney&"                '转生费用" & vbcrlf & _
			"DEF_PET_basichpmoney = "&DEF_PET_basichpmoney&"             '恢复宠物体力药水的价格,建议100   " & vbcrlf & _
			"DEF_PET_basicspmoney = "&DEF_PET_basicspmoney&"              '恢复宠物饥饿值药水的价格，建议500" & vbcrlf & _
			"DEF_PET_basicexpmoney = "&DEF_PET_basicexpmoney&"           '增加宠物经验值药水的价格，建议价格设置贵一些" & vbcrlf & _
			"DEF_PET_livemoney = "&DEF_PET_livemoney&"                 '复活药水的价格" & vbcrlf & _
			"DEF_PET_basicusehp = "&DEF_PET_basicusehp&"              '使用一次增加宠物体力的数量，建议50" & vbcrlf & _
			"DEF_PET_basicusesp = "&DEF_PET_basicusesp&"             '使用一次增加宠物饥饿的数量，建议500" & vbcrlf & _
			"DEF_PET_basicuseexp = "&DEF_PET_basicuseexp&"              '使用一次增加宠物经验的数量，建议20，数量不要太大" & vbcrlf & _
			"DEF_PET_petpkhp = "&DEF_PET_petpkhp&"                   '宠物之间PK时候当一方宠物低于多少PK便停止，如果设置为1则直到一方死亡PK才告结束，如果想要一方死亡PK才结束，请设置为1" & vbcrlf & _
			"DEF_PET_petpktime = "&DEF_PET_petpktime&"                '宠物PK时的攻击间隔，为了防止恶意刷新请设置100以上,以秒为单位" & vbcrlf & _
			"DEF_PET_petpklv = "&DEF_PET_petpklv&"                  '宠物之间PK时候当两个宠物级别低于这个值时，不能PK，建议设置10以上" & vbcrlf & _
			"DEF_PET_changesexmoney = "&DEF_PET_changesexmoney&"           '宠物变性手术价格" & vbcrlf & _
			"DEF_PET_perswordmoney = "&DEF_PET_perswordmoney&"            '每1点攻击力武器价格(注意：实际是你填的1.1倍Aven这样弄我也懒得改)" & vbcrlf & _
			"DEF_PET_pernecklacemoney = "&DEF_PET_pernecklacemoney&"         '每1点攻击力项链价格(注意：实际是你填的1.1倍Aven这样弄我也懒得改)" & vbcrlf & _
			"DEF_PET_perheadmoney = "&DEF_PET_perheadmoney&"             '每1点防御力头盔价格(注意：实际是你填的1.1倍Aven这样弄我也懒得改)" & vbcrlf & _
			"DEF_PET_perbodyemoney = "&DEF_PET_perbodyemoney&"            '每1点防御力盔甲价格(注意：实际是你填的1.1倍Aven这样弄我也懒得改)" & vbcrlf & _
			"DEF_PET_perfootmoney = "&DEF_PET_perfootmoney&"             '每1点防御力鞋子价格(注意：实际是你填的1.1倍Aven这样弄我也懒得改)" & vbcrlf & _
			"DEF_PET_replytopicexp = "&DEF_PET_replytopicexp&"             '回复主题时给作者的宠物增加的exp点数    " & vbcrlf & _
			"DEF_PET_newtopicexp = "&DEF_PET_newtopicexp&"               '发表新主题时给作者的宠物增加的exp点数    " & vbcrlf & _
			"DEF_PET_sendbattlemsg = "&DEF_PET_sendbattlemsg&"             '是否发送攻击短消息，1为发送，0为不发送" & vbcrlf & _
			"DEF_UpWeopMoney = "&DEF_UpWeopMoney&"             '每次升级武器消耗的金钱，建议稍大一点" & vbcrlf & _
			"DEF_Pet_ImgMoney = "&DEF_Pet_ImgMoney&"             '固定宠物形象需要的金钱，建议10000" & vbcrlf & _
			"DEF_PointsName = """&DEF_PointsName&"""             '论坛货币名称" & vbcrlf & _
			"%"&""&">"
			file_name="YD_pet_config.asp"
			call create_file(file_name,filetype)
  
			call showmessage("成功保存各项设置~","YD_pet_config_edit.asp")
			end sub

			sub create_file(file_name,filetype)
				dim filetemp,fileos,filepath
				set fileos=CreateObject("Scripting.FileSystemObject")
				filepath=server.mappath(file_name)
				set filetemp=fileos.createtextfile(filepath,true)
				filetemp.writeline( filetype )
				filetemp.close
				set filetemp=nothing
				set fileos=nothing
			end sub

		case "orphpet"
			if request("petid") <> "" and isnumeric(request("petid")) then
				set rs=connpet.execute("SELECT * FROM mypetdata WHERE id="&cint(request("petid")))
				dim newexp
				newexp=rs("mypetexp")-int(rs("mypetexp")*20/100)
				connpet.ExeCute("INSERT INTO petdeldata (username, mypet,mypetname,mypetlevel,mypetexp,mypetmaxhp,mypetatk,mypetdef,mypetsex,mypetsx,petdeldate)VALUES ('"& rs("username") &"', '"& rs("mypet") &"', '"& rs("mypetname") &"', '"& rs("mypetlevel") &"', '"& newexp &"','"& rs("mypetmaxhp") &"', '"& rs("mypetatk") &"', '"& rs("mypetdef") &"', '"& rs("mypetsex") &"', '"& rs("mypetsx") &"', "& Pet_NowString &")")
				Dvbbs.execute("INSERT INTO DV_Message (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("username")&"','宠物中心','你的宝宝离家出走了','因为你长期不给宝宝喂食，你的宝宝不堪忍受虐待，离家出走了。现在正在宠物收容所呢！快把它找回来吧！','"&now&"','0','1')")
				connpet.ExeCute("DELETE FROM mypetdata WHERE id = " & request("petid"))
				call showmessage("丢弃完了，宠物已经放在宠物收容所了","YD_pet_config_edit.asp?action=userpet")
			else
				call showmessage("该用户还没有宠物~","YD_pet_config_edit.asp?action=userpet")
			end if

		case "delpet"
			if request("petid") <> "" and isnumeric(request("petid")) then
				connpet.ExeCute("DELETE FROM mypetdata WHERE id = " & request("petid"))
				call showmessage("成功删除该用户的宠物~","YD_pet_config_edit.asp?action=userpet")
 			else
				call showmessage("该用户还没有宠物~","YD_pet_config_edit.asp?action=userpet")
			end if
		case "delallbattlemsg"
			SQL = "DELETE FROM Dv_Message where Title = '你的宝宝受到攻击'"
			Dvbbs.ExeCute(SQL)
			call showmessage("成功删除所有竞技短消息~","YD_pet_config_edit.asp?action=battlemsg")
		case "delreadbattlemsg"    
			SQL = "DELETE FROM Dv_Message where Flag = 1 and Title = '你的宝宝受到攻击'"
			Dvbbs.ExeCute(SQL)
			call showmessage("成功删除所有已读竞技短消息~","YD_pet_config_edit.asp?action=battlemsg")
		case "changepet"   
			call chkchange
			call change_pet
			call showmessage("成功保存各项设置~","YD_pet_config_edit.asp?action=userpet")
		end select
%>
 <table class=tableborder1 cellspacing=1 cellpadding=3 align=center>
  <tr>
    <th height=27 align="center"><b><font class=HeadFont><%=stats%></font></b></th>
  </tr>
  <tr>
    <td class=TableBody2 height=22 valign="middle">
	&nbsp;&nbsp;<a href="?action=config">宠物参数设置</a>&nbsp;<img src="Skins/Default/navspacer.gif" align="absmiddle">&nbsp;
	<a href="?action=userpet">用户宠物管理</a>&nbsp;<img src="Skins/Default/navspacer.gif" align="absmiddle">&nbsp;
	<a href="?action=battlemsg">竞技消息删除</a>&nbsp;<img src="Skins/Default/navspacer.gif" align="absmiddle">&nbsp;
	<a href="?action=add">添加新宠物</a>
    </td>
  </tr>
  <tr>
    <td class=TableBody1><br>
<%
	if action="config" then
%>
      <table class=tableborder1 cellspacing=1 cellpadding=3 style="width:95%" align=center>
	<tr>
	  <th height=27 width=33% align=center>设置名称</th>
	  <th height=27 width=33% align=center>参数</th>
	  <th height=27 width=34% align=center>相关说明</th>
	</tr>
	<form action="YD_pet_config_edit.asp" method=post>
	<tr>
	  <td class=TableBody1>程序修改：</td>
	  <td class=TableBody1><%=DEF_PET_author%></td>
	  <td class=TableBody1>　</td>
	</tr>
	<tr>
	  <td class=TableBody1>版本信息：</td>
	  <td class=TableBody1><%=DEF_PET_version%></td>
	  <td class=TableBody1> </td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物名字长度：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_namelong" value="<%=DEF_PET_namelong%>" size=38 maxlength=50></td>
	  <td class=TableBody1>用户自定义宠物的名字长度</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物名字过滤：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_nameexpt" value="<%=DEF_PET_nameexpt%>" size=38 maxlength=50></td>
	  <td class=TableBody1>不允许的宠物名字,使用"|"隔开</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物的基础体力值：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basichp" value="<%=DEF_PET_basichp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议100</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物的饥饿值：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicsp" value="<%=DEF_PET_basicsp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议10000</td>
	</tr>
	<tr>
	  <td class=TableBody1>每天宠物消耗饥饿值：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicsp2" value="<%=DEF_PET_basicsp2%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议500，注意不要超过SP的基本量</td>
	</tr>
	<tr>
	  <td class=TableBody1>基本宠物蛋价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_eggmoney" value="<%=DEF_PET_eggmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%>　</td>
	</tr>
	<tr>
	  <td class=TableBody1>转生费用：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_relmoney" value="<%=DEF_PET_relmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%>，建议10000</td>
	</tr>
	<tr>
	  <td class=TableBody1>恢复宠物体力药水的价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basichpmoney" value="<%=DEF_PET_basichpmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%>，建议1000</td>
	</tr>
	<tr>
	  <td class=TableBody1>恢复宠物饥饿值药水的价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicspmoney" value="<%=DEF_PET_basicspmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%>，建议500</td>
	</tr>
	<tr>
	  <td class=TableBody1>增加宠物经验值药水的价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicexpmoney" value='<%=DEF_PET_basicexpmoney%>' size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%>，建议价格设置贵一些</td>
	</tr>
	<tr>
	  <td class=TableBody1>复活药水的价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_livemoney" value="<%=DEF_PET_livemoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>使用一次增加宠物体力的数量：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicusehp" value="<%=DEF_PET_basicusehp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议100</td>
	</tr>
	<tr>
	  <td class=TableBody1>使用一次增加宠物饥饿的数量：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicusesp" value="<%=DEF_PET_basicusesp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议100</td>
	</tr>
	<tr>
	  <td class=TableBody1>使用一次增加宠物经验的数量：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_basicuseexp" value="<%=DEF_PET_basicuseexp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议50数量不要太大</td>
	</tr>
	<tr>
	  <td class=TableBody1>PK时当一方宠物HP低于多少便停止：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_petpkhp" value="<%=DEF_PET_petpkhp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>如果设置为1则直到一方死亡PK才告结束，如果想要一方死亡PK才结束，请设置为1</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物PK时的攻击间隔：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_petpktime" value="<%=DEF_PET_petpktime%>" size=38 maxlength=50></td>
	  <td class=TableBody1>为了防止恶意刷新请设置100以上,以秒为单位</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物之间PK级别间隔：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_petpklv" value="<%=DEF_PET_petpklv%>" size=38 maxlength=50></td>
	  <td class=TableBody1>宠物之间PK时候当两个宠物级别低于这个值时，不能PK建议设置10以上</td>
	</tr>
	<tr>
	  <td class=TableBody1>宠物变性手术价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_changesexmoney" value="<%=DEF_PET_changesexmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>每1点攻击力武器价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_perswordmoney" value="<%=DEF_PET_perswordmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>每1点攻击力项链价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_pernecklacemoney" value="<%=DEF_PET_pernecklacemoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>每1点防御力头盔价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_perheadmoney" value="<%=DEF_PET_perheadmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>每1点防御力盔甲价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_perbodyemoney" value="<%=DEF_PET_perbodyemoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>每1点防御力鞋子价格：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_perfootmoney" value="<%=DEF_PET_perfootmoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1><%=DEF_PointsName%></td>
	</tr>
	<tr>
	  <td class=TableBody1>回复主题增加经验值：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_replytopicexp" value="<%=DEF_PET_replytopicexp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>EXP</td>
	</tr>
	<tr>
	  <td class=TableBody1>发表主题增加经验值：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_newtopicexp" value="<%=DEF_PET_newtopicexp%>" size=38 maxlength=50></td>
	  <td class=TableBody1>EXP</td>
	</tr>
	<tr>
	  <td class=TableBody1>是否发送攻击短消息：</td>
	  <td class=TableBody1><input type=text name="DEF_PET_sendbattlemsg" value="<%=DEF_PET_sendbattlemsg%>" size=38 maxlength=50></td>
	  <td class=TableBody1>1为发送，0为不发送</td>
	</tr>
	<tr>
	  <td class=TableBody1>每次升级武器消耗的金钱：</td>
	  <td class=TableBody1><input type=text name="DEF_UpWeopMoney" value="<%=DEF_UpWeopMoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议设置大一点</td>
	</tr>
	<tr>
	  <td class=TableBody1>固定宠物形象消耗的金钱：</td>
	  <td class=TableBody1><input type=text name="DEF_Pet_ImgMoney" value="<%=DEF_Pet_ImgMoney%>" size=38 maxlength=50></td>
	  <td class=TableBody1>建议设置大一点</td>
	</tr>
	<tr>
	  <td class=TableBody1>论坛货币名称：</td>
	  <td class=TableBody1><input type=text name="DEF_PointsName" value="<%=DEF_PointsName%>" size=38 maxlength=50></td>
	  <td class=TableBody1>默认设置为"货币"</td>
	</tr>
<%
		if DEF_PET_close>1 then		'论坛开启状态判断
			Chk1=""
			Chk2="Checked"
		else
			Chk1="Checked"
			Chk2=""
		end if
%>
	  <td class=TableBody1>宠物中心中心状态：</td>
	  <td class=TableBody1><input type="radio" name="DEF_PET_close" <% =Chk1 %> value="1">开启   <input type="radio" name="DEF_PET_close"  <% =Chk2 %> value="2"><Font color=red>关闭</Font>    
	  </td>
	  <td class=TableBody1>默认设置为"开启"</td>
	</tr>
	<tr>
	  <td colspan="3" class=TableBody1>注意：以上宠物名字过滤字符使用"|"隔开，其它各项必须填写数字。</td>
	</tr>
	<tr>
	  <td colspan="3" class=TableBody1 align="center">
		<input type="hidden" name="action" value="changeconfig"> 
		<input type="submit" value="提交修改" class=fmbtn>
	  </td>
	</tr>
	</form>
      </table>
<%
	end if

	if action="editpet" then
%>
      <table class=tableborder1 cellspacing=1 cellpadding=3 style="width:95%" align=center>
	<tr>
	  <th height=27 width="30%" align=center>设置名称</th>
	  <th height=27 width="*" align=center>参数</th>
	</tr>
<%
		if request("petid") <> "" and isnumeric(request("petid")) then
			sql = "select * from mypetdata WHERE id = " & request("petid") &""
			set rs = connpet.execute(sql)
			dim level1,petatk,petdef,Chksex1,Chksex2,Chkcon1,Chkcon2,Chkpk1,Chkpk2,hpmaxskill,maxhp,str,ski,def,vit
			level1=int(rs("mypetlevel")/2)
			petatk=rs("mypetatk")
			petdef=rs("mypetdef")
			str=rs("str")
			ski=rs("ski")
			def=rs("def")
			vit=rs("vit")
			'获取生命上限
			hpmaxskill=1
			if rs("hpmaxskill")>0 then
				hpmaxskill=1+rs("hpmaxskill")/100
			end if
			if rs("hpmaxskill")>30 then
				hpmaxskill=1.2+rs("hpmaxskill")/100
			end if
			if rs("hpmaxskill")>100 then
				hpmaxskill=1.5+rs("hpmaxskill")/100
			end if
			maxhp =int((rs("mypetmaxhp")+vit)*hpmaxskill)
%>
	<form action="YD_pet_config_edit.asp" method=post>
	<tr>
	  <td class=TableBody1>&nbsp;宠物主人：</td>
	  <td class=TableBody1><input type=text name="username" value="<%=rs("username")%>" size=20></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物名字：</td>
	  <td class=TableBody1><input type=text name="mypet" value="<% = rs("mypet")%>" size=20></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物物种：</td>
	  <td class=TableBody1><input type=text name="mypetname" value="<% = rs("mypetname")%>" size=20><br> 有dragon(泡泡龙)、bst(猫尾球)、bird(天使球)、green(苹果宝宝)、devil(幽灵球)</td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物性别：</td>
	  <td class=TableBody1>
<%
			if rs("mypetsex")>1 then 
				Chksex1=""
				Chksex2="Checked"
			else
				Chksex1="Checked"
				Chksex2=""
			end if
%>
		&nbsp;
		<input type="radio" name="mypetsex" <% =Chksex1 %> value="1">男生   <input type="radio" name="mypetsex"  <% =Chksex2 %> value="2">女生
	  </td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物状态：</td>
	  <td class=TableBody1>
<%
			if rs("mypethp")<1 or rs("mypetsp")<1 or rs("mypetdead")>0 then 
				Chkcon1=""
				Chkcon2="Checked"
			else
				Chkcon1="Checked"
				Chkcon2=""
			end if
%>
		&nbsp;
		<input type="radio" name="petcon" <%=Chkcon1%> value="0">生存  <input type="radio" name="petcon" <%=Chkcon2%> value="1">死亡
	  </td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物PK：</td>
	  <td class=TableBody1>
<%
			if rs("openpk")>1 then 
				Chkpk1=""
				Chkpk2="Checked"
			else
				Chkpk1="Checked"
				Chkpk2=""
			end if
%>
		&nbsp;
		<input type="radio" name="openpk" <%=Chkpk1%> value="1">开启  <input type="radio" name="openpk"  <%=Chkpk2%> value="2">关闭
	  </td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物属性：</td>
	  <td class=TableBody1><input type=text name="mypetsx" value="<%=rs("mypetsx")%>" size=20></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物级别：</td>
	  <td class=TableBody1><input type=text name="mypetlevel" value="<%=rs("mypetlevel")%>" size=20></td>
	</tr>
	  <td class=TableBody1>&nbsp;基础攻击力：</td>
	  <td class=TableBody1><input type=text name="petatk" value="<%=petatk%>" size=20></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;基础防御力：</td>
	  <td class=TableBody1><input type=text name="petdef" value="<%=petdef%>" size=20></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物HP：</td>
	  <td class=TableBody1><input type=text name="mypethp" value="<%=rs("mypethp")%>" size=30>/<%=maxhp%></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物基础HP：</td>
	  <td class=TableBody1><input type=text name="mypetmaxhp" value="<%=rs("mypetmaxhp")%>" size=30></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物SP：</td>
	  <td class=TableBody1><input type=text name="mypetsp" value="<%=rs("mypetsp")%>" size=30>/<%=DEF_PET_basicsp%></td>
	</tr>
	<tr>
	  <td class=TableBody1>&nbsp;宠物EXP：</td>
	  <td class=TableBody1><input type=text name="mypetexp" value="<%=rs("mypetexp")%>" size=30></td>
	</tr>
	<tr>
	  <td class=TableBody1 colspan="2" align="center">
		<input type="hidden" name="petid" value="<%=rs("id")%>"> 
		<input type="hidden" name="action" value="changepet"> 
		<input type="submit" value="提交修改" class=fmbtn>
	  </td>
	</tr>
	</form>
      </table>
<%
			rs.close
		end if
	end if

	'做数据合法性检查和改动检查
	sub Chkchange
		dim errorflag
		if request("username") = "" then
			errorflag = 1
		elseif request("mypet") = "" then
			errorflag = 1
		elseif request("mypetname") = "" then
			errorflag = 1
		elseif request("mypetsx") = "" then
			errorflag = 1
		end if
		if errorflag = 1 then
			call showmessage("至少有一项设置填写有误，请按要求填写~","YD_pet_config_edit.asp")
		end if
	end sub
  
  
	sub change_pet	'未完成
		dim SQL,maxsp
		'饥饿值的限制
		if request("mypetsp")>10000  then
			maxsp = 10000
		else
			maxsp = request("mypetsp")
		end if
		SQL = "UPDATE mypetdata SET username='"& request("username") &"' ,mypet='"& request("mypet") &"' ,mypetname='"& request("mypetname") &"',mypetsex='"& request("mypetsex") &"' ,openpk='"& request("openpk") &"',mypetsx='"& request("mypetsx") &"',mypetlevel='"& request("mypetlevel") &"' ,mypethp='"& request("mypethp") &"' ,mypetmaxhp='"& request("mypetmaxhp") &"' ,mypetatk='"& request("petatk") &"' ,mypetdef='"& request("petdef") &"' ,mypetdead='"& request("petcon") &"' ,mypetsp='"& maxsp &"',mypetexp='"& request("mypetexp") &"'  WHERE id = " & request("petid") &""
		connpet.ExeCute(SQL)
	end sub

	if action="userpet" then
%>
      <table class=tableborder1 cellspacing=1 cellpadding=3 style="width:95%" align=center>
	<form name="searchuser" method="POST" action="YD_pet_config_edit.asp?action=userpet">
	<tr>
	  <td colspan=9 align=center class=TableBody2>点击宠物名字查看详细,查找用户的宠物:  <input type="text" name="txtitle" size="13">	<input type="submit" value="查询" name="title"></td>
	</tr>
	</form>
	<tr align=center>
	  <td class=TableBody1 width=15%>宠物主人</td>
	  <td class=TableBody1 width=15%>宠物名字</td>
	  <td class=TableBody1 width=10%>宠物等级</td>
	  <td class=TableBody1 width=5%>基础攻击力</td>
	  <td class=TableBody1 width=5%>基础防御力</td>
	  <td class=TableBody1 width=10%>宠物HP</td>
	  <td class=TableBody1 width=10%>宠物SP</td>
	  <td class=TableBody1 width=15%>相关状态</td>
	  <td class=TableBody1 width=15%>相关操作</td>
	</tr>
<%
		dim title 
		title=request("txtitle") 
		if not isempty(request("page")) then 
			currentPage=cint(request("page")) 
		else
			currentPage=1 
		end if

		if title = "" then
			sql = "select * from mypetdata ORDER BY relive DESC,mypetlevel DESC"
		else
			sql = "select * from mypetdata where username like '%"& title &"%' ORDER BY mypetlevel DESC"
		end if
		set rs = server.createobject("adodb.recordset")
		rs.open sql,connpet,1,1
		if rs.eof then
%>
	<tr>
	  <td colspan=9 class=TableBody1 align=center>社区无人领养宠物</td>
	</tr>
<%
		else
			dim totalPut,currentpage,MaxAnnouncePerpage
			MaxAnnouncePerPage=25
			totalPut=rs.recordcount
			if currentpage<1 then
				currentpage=1
			end if
			MaxAnnouncePerpage=Clng(MaxAnnouncePerpage)
			if (currentpage-1)*MaxAnnouncePerPage>totalput then
				if (totalPut mod MaxAnnouncePerPage)=0 then
					currentpage= totalPut \ MaxAnnouncePerPage
				else
					currentpage= totalPut \ MaxAnnouncePerPage + 1
				end if
			end if
			if currentPage=1 then
				showContent
				showpage totalput,MaxAnnouncePerPage,"YD_pet_config_edit.asp?action=userpet"
			else                                      
				if (currentPage-1)*MaxAnnouncePerPage<totalPut then
					rs.move  (currentPage-1)*MaxAnnouncePerPage
					dim bookmark
					bookmark=rs.bookmark
					showContent
					showpage totalput,MaxAnnouncePerPage,"YD_pet_config_edit.asp?action=userpet"
				else
					currentPage=1
					showContent
					showpage totalput,MaxAnnouncePerPage,"YD_pet_config_edit.asp?action=userpet"
				end if
			end if
		end if
%>
      </table>
<%

		sub showContent
		dim i
		i=0
		dim saveday,level1,petatk,petdef,pethp1,petsp1
		do while not rs.eof
			level1=int(rs("mypetlevel")/2)
			petatk=rs("mypetatk")
			petdef=rs("mypetdef")
			pethp1=rs("mypethp")
			petsp1=rs("mypetsp")-(DateDiff("d", rs("petregdate"), date())*DEF_PET_basicsp2)
%>
	<tr align="center">
	  <td class=TableBody1><a href="dispuser.asp?name=<%=rs("username")%>" target="viewuser"><%=rs("username")%></a></td>
	  <td class=TableBody1><a href="YD_petview.asp?username=<%=rs("username")%>" target="viewpet"><%=rs("mypet")%></a></td>
	  <td class=TableBody1><%=rs("mypetlevel")%></td>
	  <td class=TableBody1><%=petatk%></td>
	  <td class=TableBody1><%=petdef%></td>
	  <td class=TableBody1><%=pethp1%></td>
	  <td class=TableBody1><%=petsp1%></td>
	  <td class=TableBody1>
<%
			if rs("mypethp")<1 or rs("mypetsp")<1 then 
				response.write "死亡"
			else
				response.write "生存"
			end if
%>
	  </td>
	  <td class=TableBody1><a href="?action=editpet&petid=<%=rs("id")%>">编辑</a>   <a href="?action=orphpet&petid=<%=rs("id")%>" onclick="javascript:{if(confirm('您确定执行抛弃操作吗?')){return true;}return false;}">抛弃</a>　<a href="?action=delpet&petid=<%=rs("id")%>" onclick="javascript:{if(confirm('您确定执行删除操作吗?')){return true;}return false;}">删除</a></td>
	</tr>
<%
			i=i+1
			if i>=MaxAnnouncePerPage then exit do
			rs.movenext
		loop
		end sub

		function showpage(totalnumber,MaxAnnouncePerPage,filename)                                          
%>
      <table cellspacing=1 cellpadding=3 style="width:95%" align=center>
	<tr>
	  <td>
<%
		dim n
		if totalnumber mod MaxAnnouncePerPage=0 then
			n= totalnumber \ MaxAnnouncePerPage
		else
			n= totalnumber \ MaxAnnouncePerPage+1
		end if
		response.write "<p align='center'> "
		if CurrentPage<2 then
			response.write "首页 上一页 "
		else
			response.write "<a href="&filename&"&page=1&txtitle="&request("txtitle")&">首页</a> "
			response.write "<a href="&filename&"&page="&CurrentPage-1&"&txtitle="&request("txtitle")&">上一页</a> "
		end if
		if n-currentpage<1 then
			response.write "下一页 尾页"
		else
			response.write "<a href="&filename&"&page="&(CurrentPage+1)&"&txtitle="&request("txtitle")&">"
			response.write "下一页</a> <a href="&filename&"&page="&n&"&txtitle="&request("txtitle")&">尾页</a>"
		end if
		response.write " 页次：</font><strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
		response.write " 共<b>"&totalnumber&"</b>个用户 <b>"&MaxAnnouncePerPage&"</b>个用户/页 "
%>
	  </td>
	</tr>
      </table>
<%
	end function

	end if

	if action="battlemsg" then
		dim allbattlemsg,readbattlemsg
		SQL = "SELECT COUNT(*) FROM Dv_Message where Title = '你的宝宝受到攻击'"
		set rs = Dvbbs.Execute(sql)
		allbattlemsg = rs(0)
		rs.close
		SQL = "SELECT COUNT(*) FROM Dv_Message where Flag = 1 and Title = '你的宝宝受到攻击'"
		set rs = Dvbbs.Execute(sql)
		readbattlemsg = rs(0)
		rs.close
%>
      <table class=tableborder1 cellspacing=1 cellpadding=3 style="width:95%" align=center>
	<tr align=center>
	  <td class=TableBody1>社区共有 <b><%=allbattlemsg%></b> 条竞技短消息，已读 <b><%=readbattlemsg%></b> 条，未读 <b><%=allbattlemsg-readbattlemsg%></b> 条。</td>
	</tr>
	<tr align=center>
	  <td class=TableBody1>
		<input type="button" value="删除已读竞技短消息" name="title" class=fmbtn onclick="javascript:window.location='YD_pet_config_edit.asp?action=delreadbattlemsg';">
		<input type="button" value="删除所有竞技短消息" name="title" class=fmbtn onclick="javascript:window.location='YD_pet_config_edit.asp?action=delallbattlemsg';">
	  </td>
	</tr>
      </table>
<%
	end if

	if action="add" then
%>
      <table>
	<form method=post action="YD_pet_config_edit.asp">
	<tr>
	  <td>名字</td>
	  <td><input type="text" name="newname" size="20"></td>
	</tr>
	<tr>
	  <td>英文识别</td>
	  <td><input type="text" name="newclass" size="20"></td>
	</tr>
	<tr>
	  <td>属性（中文）</td>
	  <td><input type="text" name="newsx" size="20"></td>
	</tr>
	<tr>
	  <td>说明</td>
	  <td><input type="text" name="newtxt" size="20"></td>
	</tr>
	<tr>
	<input type="hidden" name="action" value="addnew">
	</tr>
	<tr>
	  <td><input type="submit"></td>
	  <td><input type="reset"></td>
	</tr>
	</form>
      </table>
<%
	end if
%>
    </td>
  </tr>
</table>

<%
End If
Set Dv_plus=Nothing
Dvbbs.Footer
%>