<%@ LANGUAGE=VBScript codepage ="936" %>
<!--#include file="../../mywp.asp"-->
<!--#include file="../../showchat.asp"-->
<%Response.Expires=0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Pragma","No-Cache"
Response.AddHeader "Cache-Control","Private"
Response.CacheControl = "No-Cache"
cwjh_name=Session("cwjh_name")
cwjh_grade=Session("cwjh_grade")
cwjh_jhdj=Session("cwjh_jhdj")
if cwjh_name="" then Response.Redirect "../../error.asp?id=440"
http = Request.ServerVariables("HTTP_REFERER") 
if InStr(http,"chat")=0 then 
Response.Write "<script language=javascript>{alert('对不起，程序拒绝您的操作！！！\n     按确定返回！');parent.history.go(-1);}</script>" 
Response.End 
end if
wpnameid=trim(request("id"))
if not isnumeric(wpnameid) then Response.Redirect "../../error.asp?id=54"
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("cwjh_usermdb")
rs.open "SELECT * FROM 技能 where ID=" & wpnameid,conn,2,2
wpname=rs("技能")
jinbig=rs("g")
jinbi=int(jinbig/320)
rs.close
rs.open "select * from 用户 where 姓名='"&cwjh_name&"'",conn,3,3
sj=DateDiff("s",rs("操作时间"),now())
if sj<30 then
	s=30-sj
	rs.close
	set rs=nothing	
	conn.close
	set conn=nothing
	Response.Write "<script language=JavaScript>{alert('对不起系统限制，请等["&s&"秒钟]再操作！');location.href = 'javascript:history.go(-1)';}</script>"
	Response.End
end if	
if jinbi>rs("金币") then
	Response.Write "<script Language=Javascript>alert('提示：购买不成功，原因：你的金币不够');location.href = 'javascript:history.go(-1)';</script>"
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
	response.end
end if
zstemp=add(rs("w11"),wpname,1)
conn.execute "update 用户 set 金币=金币-"&jinbi&",操作时间=now(),w11='"&zstemp&"' where 姓名='"&cwjh_name&"'"
   	says="<font color=red>【购买技能书】</font>"&cwjh_name&"找到了藏经阁的智空大师，花了（"&jinbi&"）金币偷偷购买了一本<font color=blue>【"&wpname&"】技能书</font>,好好修炼定能成为绝顶高手呀！"
rs.close
set rs=nothing
conn.close
set conn=nothing
call showchat(says)
Response.Write "<script Language=Javascript>alert('提示：购买角色技能书【"&wpname&"】一本成功！');location.href = 'javascript:history.go(-1)';</script>"
%>