<%Session.CodePage=936%>
<!--#include file="inc/function.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/Conn_User.asp"-->
<%
if CheckUserLogined()=False then
	response.Redirect "User_Login2.asp"
end if
%>
<%
dim action
action=Request("action")
if action="t" then
bgid=Request("bgid")
point=Request("point")
UserNamed=Request.Cookies("asp163")("UserName")

set rsbgs=server.createobject("adodb.recordset")
sql="select * from [bg] where bgid='"&bgid&"' and UserName='"&UserNamed&"' order by id desc"
rsbgs.open sql,Conn_User,1,1
if rsbgs.eof then 
set rsbg=server.createobject("adodb.recordset")
sql="select * from [bg]"
rsbg.open sql,Conn_User,1,3
rsbg.addnew
rsbg("bgid")=bgid
rsbg("UserName")=UserNamed
rsbg.update
set users=server.createobject("adodb.recordset")
sql="select * from [user] where UserName='"&UserNamed&"'"
users.open sql,Conn_User,1,3
point=Clng(point)
if users("UserPoint")< point then
%>
<script language="JavaScript" type="text/JavaScript">
    alert("您的点数不够！");
	window.close();
</script>
<%
else
users("UserPoint")=users("UserPoint")-point
users.update
response.Redirect "pifu.asp?userid="&users("userid")&"&mdid=man&htm=usermanage.asp?userid="&users("userid")&""
end if
else
%>
<script language="JavaScript" type="text/JavaScript">
    alert("您已经购买过此模版！");
	window.close();
</script>
<%
end if
end if
%>
<%
action=Request("action")
if action="r" then
gid=Request("gid")
point=Request("point")
UserNamed=Request.Cookies("asp163")("UserName")

set rsbgs=server.createobject("adodb.recordset")
sql="select * from [userg] where gid='"&gid&"' and UserName='"&UserNamed&"' order by id desc"
rsbgs.open sql,Conn_User,1,1
if rsbgs.eof then 
set rsbg=server.createobject("adodb.recordset")
sql="select * from [userg] order by id desc"
rsbg.open sql,Conn_User,1,3
rsbg.addnew
rsbg("gid")=gid
rsbg("UserName")=UserNamed
rsbg.update
set users=server.createobject("adodb.recordset")
sql="select * from [user] where UserName='"&UserNamed&"' order by userid desc"
users.open sql,Conn_User,1,3
point=Clng(point)
if users("UserPoint")< point then
%>
<script language="JavaScript" type="text/JavaScript">
    alert("您的点数不够！");
	window.close();
</script>
<%
else
users("UserPoint")=users("UserPoint")-point
users.update
response.Redirect "pifu.asp?userid="&users("userid")&"&mdid=man&htm=usermanage.asp?userid="&users("userid")&""
end if
else
%>
<script language="JavaScript" type="text/JavaScript">
    alert("您已经购买过此挂饰！");
	window.close();
</script>
<%
end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="img0415/css.CSS" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {
	color: #FF6600;
	font-weight: bold;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
</body>
</html>
