<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=conn.asp -->
<%
dim rs,sql
DEF_BBS_homeUrl="../../"
initdatabase
WPD_Getconfig

BBS_SiteHead DEF_SiteNameString & " " & DEF_BBS_Name,GBL_board_ID," >> 社区商店"
if not WPD_founduser then
	WPD_Errmsg=WPD_Errmsg+"<br>"+"<li>您没有在社区商店购物的权限，请登陆或者注册。"
	WPD_Error
end if
if request.servervariables("content_length")<>0 then
	call buy()
else
	call main()
end if
closeshopdatabase
closedatabase
SiteBottom

sub buy()
dim wpd_shop_id,wpd_shop_item,wpd_shop_price,wpd_shop_howuse

wpd_shop_id=request.form("itemid")
if wpd_shop_id="" then
WPD_WriteCenter "ID不能为空！"
exit sub
end if
wpd_shop_id=cLng(wpd_shop_id)
set rs=conn.execute("select name,price,howuse from wpd_shop where id="&wpd_shop_id)
if rs.bof and rs.eof then
	set rs=nothing
	closeshopdatabase
	WPD_Errmsg=WPD_Errmsg+"<br>"+"<li>错误的物品ID参数，可能此物品已经删除。"
	WPD_Error
	exit sub
else
	wpd_shop_item=rs(0)
	wpd_shop_price=rs(1)
	wpd_shop_howuse=split(rs(2),"|")
	set rs=nothing
	if wpd_mymoney<=wpd_shop_price then
		closeshopdatabase
		WPD_Errmsg=WPD_Errmsg+"<br>"+"<li>你的<font color=red>积分</font>不够支付购买费用！"
		WPD_Error
		exit sub
	end if
	sql = "update leadbbs_user set Points=Points-"&wpd_shop_price&",OnlineTime=OnlineTime"&wpd_shop_howuse(0)&",CharmPoint=CharmPoint"&wpd_shop_howuse(1)&",CachetValue=CachetValue"&wpd_shop_howuse(2)&" where username='"&gbl_chk_user&"'"
	con.execute sql
	WPD_Sucmsg=WPD_Sucmsg+"<li>成功购买物品　<b>"&wpd_shop_item&"</b>　！</li><li>你的经验"&wpd_shop_howuse(0)&"！</li><li>你的魅力"&wpd_shop_howuse(1)&"！</li><li>你的威望"&wpd_shop_howuse(2)&"！</li>"
	WPD_Suc
end if
end sub

sub main()
dim wpd_shop_arr,wpd_shop_temp
set rs=server.createobject("adodb.recordset")
rs.open "select id,name,images,price,howuse from wpd_shop",conn,1,1
wpd_shop_temp=rs.RecordCount-1
wpd_shop_arr=rs.getrows(rs.RecordCount)
rs.close
set rs=nothing
%>
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center>
    <td class=TBHead colspan=5><font color=#ffffff class=HeadFont><b>社区商店欢迎您的光临</b></font></td>
  </tr>
  <tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
    <td colspan=5>社区商店说明：<br><br>购买物品需要使用社区积分。<br>积分的获得方法：参与社区建设，积极发帖赚取积分。<br><font color=red>注：</font>以下的经验值是除以60之后才是社区中真正使用的经验值，魅力值为正常。</td>
  </tr>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center>
    <td class=TBHead width=35><font color=#ffffff class=HeadFont><b>图片</b></font></td>
    <td class=TBHead width=100><font color=#ffffff class=HeadFont><b>物品名称</b></font></td>
    <td class=TBHead width=100><font color=#ffffff class=HeadFont><b>物品价格</b></font></td>
    <td class=TBHead width=300><font color=#ffffff class=HeadFont><b>物品价值</b></font></td>
    <td class=TBHead><font color=#ffffff class=HeadFont><b>购买</b></font></td>
  </tr>
<%
dim wpd_shop_n,wpd_shop_howuse
For wpd_shop_n=0 to wpd_shop_temp
wpd_shop_howuse=split(wpd_shop_arr(4,wpd_shop_n),"|")
%>
  <tr bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
    <td><img src="<%=wpd_shop_arr(2,wpd_shop_n)%>" border=0></td>
    <td><%=wpd_shop_arr(1,wpd_shop_n)%></td>
    <td><%=wpd_shop_arr(3,wpd_shop_n)%></td>
    <td>经验 <font color=#FF0000><%=wpd_shop_howuse(0)%></font> 魅力 <font color=#FF0000><%=wpd_shop_howuse(1)%></font> </td>
    <td><form method="post" name="wpdshop" action="index.asp"><INPUT name=itemid size="20" value="<%=wpd_shop_arr(0,wpd_shop_n)%>" type=hidden><input type=submit value="点击购买" name="submit"></form></td>
  </tr>
<%
Next
%>
</table>
<%end sub%>