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

<%
Response.Buffer = True 
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache" 
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 DvBBS.UserId = 0 then
	AlarmErrmsg
else
	'宠物插件状态
	if DEF_PET_close>1 then
		'暂时关掉开始
		if not dvbbs.master then
			call showmessage("调试中,请以后再来~","index.asp")
		end if
		'暂时关掉结束
	end if
	dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
	dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
	Dim Rs,SQL,item1,item2,item3,item4,item5
	set rs=Dvbbs.execute("select userWealth from [Dv_User] where UserID="&DvBBS.UserId)
	money=rs("userWealth")
	rs.close
	sql = "SELECT * FROM mypetdata WHERE username='"&DvBBS.MemberName&"' "
	rs.open sql,connpet,1,3
	if rs.eof then
		call showmessage("你还没有宠物啊，快攒钱去买吧~","YD_petshop.asp")
	else
		item1=0
		item2=0
		item3=0
		item4=0
		item5=0

		if rs("item1")<>0 then item1=1 end if
		if rs("item2")<>0 then item2=1 end if
		if rs("item3")<>0 then item3=1 end if
		if rs("item4")<>0 then item4=1 end if
		if rs("item5")<>0 then item5=1 end if

		dim tmoney,sword,tmp,necklace,head,body,foot,rndNum
		
		if request("action") = ""  or request("action")="showsword" then
			action = "marketroom"
		else
			action = lcase(request("action"))
		end if

		'注册宠物物品箱中物品
		Dim Rs2,SQL2,hpitem,spitem,expitem,liveitem,weopitem,amoritem,jewel,ring,it1,it1n,it2,it2n,it3,it3n,it4,it4n,it5,it5n,it6,it6n,it7,it7n,it8,it8n
		dim tempname,tempclass,tempNum,tempN,it,temp
		sql2 = "SELECT * FROM useritem WHERE username='"&Dvbbs.MemberName&"' "
		set rs2=connpet.ExeCute(sql2)
		hpitem=rs2("hpitem")
		spitem=rs2("spitem")
		expitem=rs2("expitem")
		liveitem=rs2("liveitem")	
		weopitem=rs2("weopitem")
		amoritem=rs2("amoritem")
		jewel=rs2("jewel")
		ring=rs2("ring")
		it1=rs2("it1")
		it1n=rs2("it1n")
		it2=rs2("it2")
		it2n=rs2("it2n")
		it3=rs2("it3")
		it3n=rs2("it3n")
		it4=rs2("it3")
		it4n=rs2("it4n")
		it5=rs2("it5")
		it5n=rs2("it5n")
		it6=rs2("it6")
		it6n=rs2("it6n")
		it7=rs2("it7")
		it7n=rs2("it7n")
		it8=rs2("it8")
		it8n=rs2("it8n")

		select case action
			case "sell"				'卖东西啊
				dim itemmoney,itemN,itemNum,itemuesr,itemclass,itemName
				itemmoney = clng(request("itemmoney"))
				itemuesr = Dvbbs.MemberName
				itemclass = Checkstr(request("itemclass"))
				itemName = Checkstr(request("itemName"))
				itemNum=0
				itemN = cint(request("itemn"))

				'统计用户待出售物品个数
				Dim Rs4,SQL4,kkk
				sql4 = "SELECT COUNT(id) FROM itemmarket WHERE itemuesr='"&Dvbbs.MemberName&"' "
				set rs4=connpet.ExeCute(sql4)
				kkk=rs4(0)
				rs4.close
				if kkk>10 then
					call showmessage("您待出售的物品已经超过10个，请酌情出售您的物品！","YD_petitemmarket.asp")
				end if
				set rs = connpet.execute("select * from mypetdata where username='"&DvBBS.MemberName&"'")
				'补丁，防刷装备
				select case itemclass
					case "sword"
						if item1=0 then call showmessage("刷装备者，杀无赦！","YD_petitemmarket.asp?action=givesell") end if
						itemNum=rs("item1Num")
					case "necklace"
						if item2=0 then call showmessage("刷装备者，杀无赦！","YD_petitemmarket.asp?action=givesell") end if
						itemNum=rs("item2Num")
					case "head"
						if item3=0 then call showmessage("刷装备者，杀无赦！","YD_petitemmarket.asp?action=givesell") end if
						itemNum=rs("item3Num")
					case "body"
						if item4=0 then call showmessage("刷装备者，杀无赦！","YD_petitemmarket.asp?action=givesell") end if
						itemNum=rs("item4Num")
					case "foot"
						if item5=0 then call showmessage("刷装备者，杀无赦！","YD_petitemmarket.asp?action=givesell") end if
						itemNum=rs("item5Num")
					case "update"
						itemNum = Clng(request("itemNum"))
						itemN = cint(request("itemn"))
				end select

				if not isnumeric(itemmoney) then
					call showmessage("价钱必须是数字！","YD_petitemmarket.asp?action=givesell")
				elseif clng(itemmoney)<1 then
					call showmessage("赔本的生意啊？没毛病吧？！","YD_petitemmarket.asp?action=givesell")
				elseif not isnumeric(itemNum) then
					call showmessage("数量必须是数字！","YD_petitemmarket.asp?action=givesell")
				elseif clng(itemNum)<1 then
					if itemclass="update" then
						call showmessage("一个都不卖，扰乱市场持续？","YD_petitemmarket.asp?action=givesell")
					else
						call showmessage("0级装备不能卖出！","YD_petitemmarket.asp?action=givesell")
					end if
				elseif itemclass="update" and ((itemn=0 and rs2("weopitem")<itemnum) or (itemn=1 and rs2("amoritem")<itemnum)) then
					call showmessage("你没有那么多东西卖啊","YD_petitemmarket.asp?action=givesell")
				else
					sql = "INSERT INTO [itemmarket] (itemname, itemMoney, itemNum, itemUesr, ItemClass, ItemN) VALUES ('"&itemname&"', "&itemMoney&", "&itemNum&", '"&DvBBS.MemberName&"', '"&ItemClass&"', "&ItemN&")"
					connpet.execute(SQL)

					select case itemclass
						case "sword"
							connpet.execute("update [mypetdata] set item1=0,item1num=0 where username='"&DvBBS.MemberName&"'")
							call showmessage("您的 "&itemName&" （+"&itemNum&"）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
						case "necklace"
							connpet.execute("update [mypetdata] set item2=0,item2num=0 where username='"&DvBBS.MemberName&"'")
							call showmessage("您的 "&itemName&" （+"&itemNum&"）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
						case "head"
							connpet.execute("update [mypetdata] set item3=0,item3num=0 where username='"&DvBBS.MemberName&"'")
							call showmessage("您的 "&itemName&" （+"&itemNum&"）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
						case "body"
							connpet.execute("update [mypetdata] set item4=0,item4num=0 where username='"&DvBBS.MemberName&"'")
							call showmessage("您的 "&itemName&" （+"&itemNum&"）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
						case "foot"
							connpet.execute("update [mypetdata] set item5=0,item5num=0 where username='"&DvBBS.MemberName&"'")
							call showmessage("您的 "&itemName&" （+"&itemNum&"）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
						case "update"

							if itemN=0 then
								connpet.execute("update [useritem] set weopitem=weopitem-"&itemnum&" where username='"&DvBBS.MemberName&"'")
								call showmessage("您的 "&itemName&" （"&itemNum&"个）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
							else
								connpet.execute("update [useritem] set amoritem=amoritem-"&itemnum&" where username='"&DvBBS.MemberName&"'")
								call showmessage("您的 "&itemName&" （"&itemNum&"个）已卖出，等人购买！售价 "&itemMoney&" 元！","YD_petitemmarket.asp?action=show"&itemclass)
							end if
					end select
				end if
				rs.close
			case "buy"		'买东西啊~~
				dim buyid,rsbuy
				buyid=cint(Checkstr(request("id")))
				set rs = connpet.execute("select * from [itemmarket] where id="&buyid)
				if rs.eof and rs.bof then call showmessage("查无此物，或已经卖出！","YD_petitemmarket.asp?action=show"&request("itemclass"))
				if rs("itemuesr")= Dvbbs.MemberName then call showmessage("此货物原本就是你的，你无法购买！","YD_petitemmarket.asp?action=show"&request("itemclass"))
				if money < rs("itemmoney") then call showmessage("你的钱不够，凑齐了再来买！","YD_petitemmarket.asp?action=show"&request("itemclass"))

				select case request("itemclass")
					case "sword"
						if item1<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新购买","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item1="&cint(rs("itemn"))&",item1num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具中心BUG修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)	
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							Call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if
					case "necklace"
						if item2<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新购买","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item2="&cint(rs("itemn"))&",item2num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if
					case "head"
						if item3<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新购买","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item3="&cint(rs("itemn"))&",item3num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if
					case "body"
						if item4<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新购买","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item4="&cint(rs("itemn"))&",item4num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if
					case "foot"
						if item5<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新购买","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item5="&cint(rs("itemn"))&",item5num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if
					case "update"
						if request("itemN")=0 then
							connpet.execute("update [useritem] set weopitem=weopitem+"&cint(rs("itemnum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						else
							connpet.execute("update [useritem] set amoritem=amoritem+"&cint(rs("itemnum"))&" where username='"&DvBBS.MemberName&"'")
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth-"&clng(rs("itemmoney"))&" where username='"&DvBBS.MemberName&"'")
							'道具Bug修正
							Call UpdateUserInfo(-clng(rs("itemmoney")),0,0,0,0,0)
							Dvbbs.execute("update [Dv_User] set userWealth=userWealth+"&clng(rs("itemmoney"))&" where username='"&rs("itemuesr")&"'")
							Dvbbs.execute("INSERT INTO [Dv_Message] (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&rs("itemuesr")&"','宠物中心','交易成功','您的商品 "&rs("itemname")&" 被 "&DvBBS.MemberName&" 购买，您在交易中获得 "&rs("itemmoney")&" 元，请查收！','"&now&"','0','1')")
							connpet.execute("DELETE from [itemmarket] where id="&buyid)
							call showmessage("恭喜您购得了"&request("itemname")&"！","YD_petitemmarket.asp")
						end if			
				end select
		
			case "nosell"
				dim nosellid
				nosellid=cint(Checkstr(request("id")))
				set rs = connpet.execute("select * from [itemmarket] where id="&nosellid)
				if rs.eof and rs.bof then call showmessage("查无此物，或已经卖出！","YD_petitemmarket.asp?action=show"&request("itemclass"))
				if rs("itemuesr")<> Dvbbs.membername then call showmessage("此货物原本不是你的，你无法取消销售！","YD_petitemmarket.asp?action=show"&request("itemclass"))

				select case request("itemclass")
					case "sword"
						if item1<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新取回","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item1="&cint(rs("itemn"))&",item1num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if
					case "necklace"
						if item2<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新取回","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item2="&cint(rs("itemn"))&",item2num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if
					case "head"
						if item3<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新取回","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item3="&cint(rs("itemn"))&",item3num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if
					case "body"
						if item4<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新取回","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item4="&cint(rs("itemn"))&",item4num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if
					case "foot"
						if item5<>0 then
							call showmessage("你的身上装备了同类型物品<br>请卸下身上的物品后重新取回","YD_petitemmarket.asp")
						else
							connpet.execute("update [mypetdata] set item5="&cint(rs("itemn"))&",item5num="&clng(rs("itemNum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if
					case "update"
						if request("itemN")=0 then
							connpet.execute("update [useritem] set weopitem=weopitem+"&cint(rs("itemnum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						else
							connpet.execute("update [useritem] set amoritem=amoritem+"&cint(rs("itemnum"))&" where username='"&DvBBS.MemberName&"'")
							connpet.execute("DELETE from [itemmarket] where id="&nosellid)
							call showmessage("您的物品 "&request("itemname")&" 回到了您手中！","YD_petitemmarket.asp")
						end if			
				end select		
		end select
	end if
	rs.close
	call main()		'调用主页面
End If
Set Dv_plus=Nothing
Dvbbs.Footer

'===============主页面部分=====================
sub main()
%>
<table class=tableborder1 cellspacing=1 cellpadding=3 align=center>
  <tr>
    <th height=27 align=center><%=Dvbbs.stats%></th>
  </tr>
  <tr>
    <td class=TableBody1 valign=top>
      <table width="100%" cellspacing="0" cellpadding="0">
	<tr>
	  <td width="28%" rowspan="2" valign=top>
	    <table width="79%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td width="100%" align="center">我的资料</td>
	      </tr>
	      <tr>
		<td align="center">
		<%
		'用户头像调用开始
		If IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text) And IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text) And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text<>"" And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text<>"" Then
			If Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text)=Clng(Dvbbs.Forum_Setting(39)) And Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text)=Clng(Dvbbs.Forum_Setting(38)) Then
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&">"
			Else
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&" width=100 height=100>"
			End If
		Else
			response.write "<img src=images/logo_2.gif>"
		End If
		'用户头像调用结束
		%>
		</td>
	      </tr>
	      <tr>
		<td align="center"><nobr>现金货币: <%=money%></nobr></td>
	      </tr>
	    </table>
	    <br>
	    <table width="90%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td align="center"><!--#include file="YD_petnav.asp"--></td>
	      </tr>
	    </table>
	    <br>
	    <table width="79%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td width="100%" align="center"><img src="YD_plus/YD_pet/PET/27.gif"><br><br>
		<font color="#FF0000">玩家二手交易市场</font>
		</td>
	      </tr>
	    </table>
	  </td>
	  <td align="center">
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<th colspan="7" align=center>@@下面相关柜台可以卖或者买相关二手货，价格请看仔细咯！对于胡乱出价的物品将没收@@</th>
	      </tr>
	      <tr>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=givesell"><font color="#FF0000">我要卖东西</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=marketroom"><font color="#FF0000">武器柜台</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=shownecklace"><font color="#FF0000">项链柜台</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=showhead"><font color="#FF0000">头盔柜台</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=showbody"><font color="#FF0000">盔甲柜台</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=showfoot"><font color="#FF0000">鞋子柜台</font></a></td>
		<td class=TableBody2 align="center"><a href="YD_petitemmarket.asp?action=showupdate"><font color="#FF0000">升级柜台</font></a></td>
	      </tr>
	    </table>
	  </td>
	</tr>
	<tr>
	  <td width="72%" valign=top>
<%
if action<>"buy" and action<>"sell" and action<>"givesell" then
	call buy()		'调用买装备页面
elseif action = "givesell" then
	call sell()		'调用卖装备页面
end if
%>
	  </td>
	</tr>
      </table>
    </td>
  </tr>
</table>
<%
end sub

'===============买装备页面部分=====================
sub buy()
	dim atkdef,showname
	atkdef=""
	select case action
		case "marketroom"
			showname="武器柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='sword' order by itemnum"
			atkdef="攻击力"
		case "shownecklace"
			showname="项链柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='necklace' order by itemnum"
			atkdef="攻击力"
		case "showhead"
			showname="头盔柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='head' order by itemnum"
			atkdef="防御力"
		case "showbody"
			showname="盔甲柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='body' order by itemnum"
			atkdef="防御力"
		case "showfoot"
			showname="鞋子柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='foot' order by itemnum"
			atkdef="防御力"
		case "showupdate"
			showname="升级柜台"
			sql = "SELECT * FROM itemmarket WHERE itemclass='update' order by itemnum"
			atkdef="数量"
	end select
	rs.open sql,connpet,1,1
	if rs.bof and rs.eof then
%>
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <TR>
		<TH align=center><%=showname%></TH>
	      </TR>
	      <TR>
		<TD class=TableBody1 align=center>目前没有人贩卖此类道具</TD>
	      </TR>
	    </table>
<%
		rs.close
	else
%>
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <TR>
		<TH colspan=6 align=center><%=showname%></TH>
	      </TR>
	      <TR> 
		<TD class=TableBody2 width=100 align=center>卖主</TD>
		<TD class=TableBody2 width=100 align=center>名字</TD>
		<TD class=TableBody2 width=100 align=center>形象</TD>
		<TD class=TableBody2 width=100 align=center><%=atkdef%></TD>
		<TD class=TableBody2 width=100 align=center>价格</TD>
		<TD class=TableBody2 width=100 align=center>购买选项</TD>
	      </TR>
<%
		do while not rs.eof
			if atkdef<>"数量" then
%>
	      <form action="YD_petitemmarket.asp" name="name" method=post>
	      <TR>
		<TD class=TableBody1 width=100 align="center"><%=rs("itemuesr")%></TD>
		<TD class=TableBody1 width=100 align="center"><%=rs("ItemName")%></TD>
		<TD class=TableBody1 width=100 align="center"><IMG height=30 src="YD_plus/YD_pet/PET/<%=rs("ItemClass")%>/<%=rs("itemn")%>.gif" width=30></TD>
		<TD class=TableBody1 width=100 align="center">＋ <%=rs("itemNum")%></TD>
		<TD class=TableBody1 width=100 align="center"><%=rs("itemmoney")%></TD>
		<TD class=TableBody1 width=100 align="center">
				<%if rs("itemuesr") <> Dvbbs.MemberName then%>
					<input type="submit" value="购买">
					<input type="hidden" name="action" value="buy">
				<%else%>
					<input type="submit" value="取消销售">
					<input type="hidden" name="action" value="nosell">
				<%end if%>
		</TD>
		<input type="hidden" name="itemname" value="<%=rs("itemname")%>">
		<input type="hidden" name="itemclass" value="<%=rs("itemclass")%>">
		<input type="hidden" name="itemNum" value="<%=rs("itemNum")%>">
		<input type="hidden" name="itemN" value="<%=rs("itemN")%>">
		<input type="hidden" name="id" value="<%=rs("id")%>">
	      </TR>
	      </form>
			<%else%>
	      <form action=YD_petitemmarket.asp name="name" method=post>
	      <TR>
		<TD class=TableBody1 width=100 align="center"><%=rs("itemuesr")%></TD>
		<TD class=TableBody1 width=100 align="center"><%=rs("ItemName")%></TD>
		<TD class=TableBody1 width=100 align="center">
				<%if rs("itemN") = 0 then%>
					<IMG height=40 src="YD_plus/YD_pet/PET/wp.gif" width=40>
				<%else%>
					<IMG height=40 src="YD_plus/YD_pet/PET/am.gif" width=40>
				<%end if%>
		</TD>
		<TD class=TableBody1 width=100 align="center"><%=rs("itemNum")%> 个</TD>
		<TD class=TableBody1 width=100 align="center"><%=rs("itemmoney")%></TD>
		<TD class=TableBody1 width=100 align="center">
				<%if rs("itemuesr") <> DvBBS.MemberName then%>
					<input type="submit" value="购买">
					<input type="hidden" name="action" value="buy">
				<%else%>
					<input type="submit" value="取消销售">
					<input type="hidden" name="action" value="nosell">
				<%end if%>
		</TD>
		<input type="hidden" name="itemname" value="<%=rs("itemname")%>">
		<input type="hidden" name="itemclass" value="<%=rs("itemclass")%>">
		<input type="hidden" name="itemNum" value="<%=rs("itemNum")%>">
		<input type="hidden" name="itemN" value="<%=rs("itemN")%>">
		<input type="hidden" name="id" value="<%=rs("id")%>">
	      </TR>
	      </form>
<%
			end if 
			rs.movenext
		loop
		rs.close
	end if
%>
	  </table>
<%
end sub

'===============卖装备页面部分=====================
sub sell()
	SQL = "SELECT * FROM mypetdata WHERE username='"&DvBBS.MemberName&"'"
	set rs = connpet.execute(SQL)
	'用很无聊的循环使用变量得到每种道具的名字……
	dim rs3,swordname,necklacename,headname,bodyname,footname
	set rs3 = connpet.execute("select * from petitemshop where itemclass='sword' and itemnum="&rs("item1"))
	swordname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='necklace' and itemnum="&rs("item2"))
	necklacename = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='head' and itemnum="&rs("item3"))
	headname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='body' and itemnum="&rs("item4"))
	bodyname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='foot' and itemnum="&rs("item5"))
	footname = rs3("itemname")
	rs3.close
%>
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<th align=center colspan="4">出售宠物装备/道具请将其装备在身上，物品箱里的东西这里不接受贩卖！</th>
	      </tr>
	      <tr>
		<td class=TableBody2 width="25%" height="30" align=center>宠物装备/道具</td>
		<td class=TableBody2 width="25%" height="30" align=center>加强值/数量</td>
		<td class=TableBody2 width="25%" height="30" align=center>定价(总价)</td>
		<td class=TableBody2 width="25%" height="30" align=center>卖出</td>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img height=30 src="YD_plus/YD_pet/PET/sword/<%=rs("item1")%>.gif" alt="<%=swordname%>"></td>
		<td class=TableBody1 width="25%" height="30" align=center>＋ <%=rs("item1Num")%></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemnum" value="<%=rs("item1Num")%>">
		<input type="hidden" name="itemname" value="<%=swordname%>">
		<input type="hidden" name="itemclass" value="sword">
		<input type="hidden" name="itemn" value="<%=rs("item1")%>">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img height=30 src="YD_plus/YD_pet/PET/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%>"></td>
		<td class=TableBody1 width="25%" height="30" align=center>＋ <%=rs("item2Num")%></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemnum" value="<%=rs("item2Num")%>">
		<input type="hidden" name="itemname" value="<%=necklacename%>">
		<input type="hidden" name="itemclass" value="necklace">
		<input type="hidden" name="itemn" value="<%=rs("item2")%>">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img height=30 src="YD_plus/YD_pet/PET/head/<%=rs("item3")%>.gif" alt="<%=headname%>"></td>
		<td class=TableBody1 width="25%" height="30" align=center>＋ <%=rs("item3Num")%></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemnum" value="<%=rs("item3Num")%>">
		<input type="hidden" name="itemname" value="<%=headname%>">
		<input type="hidden" name="itemclass" value="head">
		<input type="hidden" name="itemn" value="<%=rs("item3")%>">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img height=30 src="YD_plus/YD_pet/PET/body/<%=rs("item4")%>.gif" alt="<%=bodyname%>"></td>
		<td class=TableBody1 width="25%" height="30" align=center>＋ <%=rs("item4Num")%></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemnum" value="<%=rs("item4Num")%>">
		<input type="hidden" name="itemname" value="<%=bodyname%>">
		<input type="hidden" name="itemclass" value="body">
		<input type="hidden" name="itemn" value="<%=rs("item4")%>">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img height=30 src="YD_plus/YD_pet/PET/foot/<%=rs("item5")%>.gif" alt="<%=footname%>"></td>
		<td class=TableBody1 width="25%" height="30" align=center>＋ <%=rs("item5Num")%></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemnum" value="<%=rs("item5Num")%>">
		<input type="hidden" name="itemname" value="<%=footname%>">
		<input type="hidden" name="itemclass" value="foot">
		<input type="hidden" name="itemn" value="<%=rs("item5")%>">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img src="YD_plus/YD_pet/PET/wp.gif" width="40" height="40" border="0" alt="武器升级材料"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemnum" size="5"> 共<font color=red><%=rs2("weopitem")%></font>个</td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemname" value="武器升级材料">
		<input type="hidden" name="itemclass" value="update">
		<input type="hidden" name="itemn" value="0">
		</form>
	      </tr>
	      <tr>
		<form action="YD_petitemmarket.asp" method="post">
		<td class=TableBody1 width="25%" height="30" align=center><img src="YD_plus/YD_pet/PET/am.gif" width="40" height="40" border="0" alt="防具升级材料"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemnum" size="5"> 共<font color=red><%=rs2("amoritem")%></font>个</td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="text" name="itemmoney" size="20"></td>
		<td class=TableBody1 width="25%" height="30" align=center><input type="submit" value="贩卖"></td>
		<input type="hidden" name="action" value="sell">
		<input type="hidden" name="itemname" value="防具升级材料">
		<input type="hidden" name="itemclass" value="update">
		<input type="hidden" name="itemn" value="1">
		</form>
	      </tr>
	    </table>
<%
	rs2.close
	rs.close
end sub
%>