<%@ LANGUAGE=VBScript codepage ="936" %>
<!--#include file="../config.asp"-->
<!--#include file="../pass.asp"-->
<%Response.Expires=0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Pragma","No-Cache"
Response.AddHeader "Cache-Control","Private"
Response.CacheControl = "No-Cache"
zhbg_name=Session("zhbg_name")
zhbg_grade=Session("zhbg_grade")
zhbg_jhdj=Session("zhbg_jhdj")
nowinroom=session("nowinroom")
if zhbg_name="" then Response.Redirect "../error.asp?id=440"
if Instr(LCase(Application("zhbg_useronlinename"&session("nowinroom")))," "&LCase(zhbg_name)&" ")=0 then
	Response.Write "<script Language=Javascript>alert('你不能进行操作，进行此操作必须进入聊天室！');location.href = 'javascript:history.go(-1)';</script>"
	Response.End
end if
pass= md5(trim(Request.form("pass")))
hygrade=int(abs(Request.form("hygrade")))
hymonth=int(abs(Request.form("hymonth")))
money=abs(int(Request.form("money")))
'if not isnumeric(hygrade) then 
if hygrade<>1 and hygrade<>2 and hygrade<>3 then
	Response.Write "<script language=JavaScript>{alert('提示：会员等级输入错！');location.href = 'javascript:history.go(-1)';}</script>"
	Response.End 
end if
if hymonth<1 or hymonth>1 then
	Response.Write "<script language=JavaScript>{alert('提示：会员申请时间出错！');location.href = 'javascript:history.go(-1)';}</script>"
	Response.End 
end if
for each element in Request.Form
if instr(element,"'")<>0 or instr(element,"|")<>0 or instr(element," ")<>0 or instr(Request.Form(element),"'")<>0 or instr(Request.Form(element)," ")<>0 or instr(Request.Form(element),"|")<>0 then 
		Response.Write "<script Language=Javascript>alert('提示：输入数据有问题，请查看！');location.href = 'javascript:history.go(-1)';</script>"
		Response.End
end if
next
userip=Request.ServerVariables("REMOTE_ADDR")
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
conn.open Application("zhbg_usermdb")
rs.open "SELECT * FROM q WHERE a='"&session("zhbg_name")&"'",conn,2,2
If not(Rs.Bof OR Rs.Eof) Then
			rs.close
			set rs=nothing
			conn.close
			set conn=nothing
			Response.Write "<script Language=Javascript>alert('提示：你已经在线申请过会员并且未结账\n系统拒绝您的申请！！');location.href = 'javascript:history.go(-1)';</script>"
			Response.End
end if
rs.close
rs.open "SELECT * FROM 用户 WHERE 姓名='"&session("zhbg_name")&"' and 密码='"&pass&"'",conn,1,2
If Rs.Bof OR Rs.Eof Then
			rs.close
			set rs=nothing
			conn.close
			set conn=nothing
			Response.Write "<script Language=Javascript>alert('提示：密码输入不正确！');location.href = 'javascript:history.go(-1)';</script>"
			Response.End
end if
oldhy=rs("会员等级")
if rs("会员等级")<>hygrade and oldhy<>0 then
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
	Response.Write "<script Language=Javascript>alert('提示：你现在已经是会员，只能办理续时服务\n也就是说现在只能申请["&oldhy&"]会员\n要想升级请与站长联系！！');location.href = 'javascript:history.go(-1)';</script>"
	Response.End
end if
if rs("会员金卡")<money then
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
	Response.Write "<script Language=Javascript>alert('提示：您与那么多会员金卡吗？');location.href = 'javascript:history.go(-1)';</script>"
	Response.End
end if
'if rs("会员等级")>0 then
'	rs.close
'	set rs=nothing
'	conn.close
'	set conn=nothing
'	Response.Write "<script Language=Javascript>alert('提示：你现在已经是会员了请与站长联系\n办理会员续费！！');location.href = 'javascript:history.go(-1)';</script>"
'	Response.End
'end if
if rs("会员等级")>1 then
	hydate=rs("会员日期")
	
else
	hydate=date()
end if
n=Year(hydate)
y=Month(hydate)
r=Day(hydate)
y=y+hymonth
if y<1 then 
	y=y+1
	n=n
end if
jy=0


if hygrade=1 then jy=31250 
if hygrade=2 then jy=90000
if hygrade=3 then jy=250000

if oldhy=1 then oldjy=31250
if oldhy=2 then oldjy=90000
if oldhy=3 then oldjy=250000
if oldhy=4 then oldjy=490000

sj=n & "-" & y & "-" & r
rs("会员等级")=hygrade
rs("会员日期")=cdate(sj)
rs("allvalue")=rs("allvalue")+jy-oldjy
rs("会员金卡")=rs("会员金卡")-money
rs.Update
conn.execute "insert into q(a,b,d,e,f) values ('"& zhbg_name &"',date(),'已付','会员等级："&hygrade&",会员时间："&hymonth&"个月,金额："&money&"元!','"&userip&"')"
rs.close
set rs=nothing
conn.close
set conn=nothing
says="<font color=red><b>【会员】</b></font><font color=blue>恭喜<b><font color=red>【"&zhbg_name&"】</font></b>["&hygrade&"级]免费会员申请完成,会员截止日期为：【<b><font color=red>"&sj&"</font></b>】"
says=replace(says,chr(39),"\'")
says=replace(says,chr(34),"\"&chr(34))
act="消息"
towhoway=0
towho="大家"
addwordcolor="660099"
saycolor="008888"
addsays="对"
saystr="<script>parent.sh("& chr(39) & addwordcolor & chr(39) &","& chr(39) & saycolor & chr(39) &","& chr(39) & act & chr(39) &","& chr(39) & zhbg_name & chr(39) &","& chr(39) & addsays & chr(39) &","& chr(39) & towho & chr(39) &"," & chr(39) & says & chr(39) &"," & towhoway &  ","& session("nowinroom") & ");<"&"/script>"
addmsg saystr
Function Yushu(a)
	Yushu=(a and 31)
End Function
Sub AddMsg(Str)
Application.Lock()
Application("SayCount")=Application("SayCount")+1
i="SayStr"&YuShu(Application("SayCount"))
Application(i)=Str
Application.UnLock()
End Sub
Response.Write "<script Language=Javascript>alert('提示：恭喜，您的会员申请完成,会员截止日期为："&sj&"\n请您退出国度重新进入！');location.href = '../chat/hy.asp';</script>"
Response.End 
%>