<%@ Language=VBScript %>

<object runat=server id=conn1 progid="adodb.connection"></object>
<%application.Lock
conn1.Open Application("p_jyzx")
Application.UnLock
%>


<%
user_name=replace(Request("user_name")," ","~",1,-1,1)
password=trim(request("password"))
sql="select * from user where user_name='"&user_name&"'"
set rs=server.CreateObject ("ADODB.recordset")
 rs.Open sql,conn1,3
if rs.RecordCount =0 then
	rs.Close
    set rs=nothing
	Response.Redirect "error.asp?cause=0"  'cause=0 表示没有这个会员
elseif rs("passwd")<>password then
    rs.Close
    set rs=nothing
    Response.Redirect "error.asp?cause=1"  'cause=1 表示密码错误
else
 '//////////////////////////////////////////////////
 qq_flag=0
 if Request("ECall")="1" then
	qq_flag=1
 end if
   	session("Current_user")=replace(rs("user_name"),"~"," ",1,-1,1)
   Session("weight")=rs("weight")
    nickname=rs("nickname")
    sex=rs("sex")
    byear=clng(rs("byear"))
    email=rs("email")
    rs.Close
    set rs=nothing
    
   set rs1=server.CreateObject ("ADODB.recordset")
   rs1.Supports ( adUpdate )
   sql="select * from user where user_name='"&user_name&"'"
   rs1.Open sql,conn1,2,3
   rs1("counter")=rs1("counter")+1
   rs1("charisma")=rs1("charisma")+Application("counter_value")
   '////////对today_visited清零
   if rs1("last_time")<>date then
   rs1("today_visited")=0
   end if
   rs1("last_time")=date
   
   rs1.Update
   
    set rs=server.createobject("adodb.recordset")
	sql="delete * from online where session_id="&  session.sessionID
	sql=sql&" or user_name='"&user_name&"'"
	rs.open sql,conn1,3,2 
	   
    Set rs = Server.CreateObject("ADODB.Recordset")
	rs.Open "online",conn1,3,2
	rs.addnew
	rs("session_id")=session.SessionID
	rs("nickname")=nickname
	rs("user_name")=user_name
	
	rs("sex")=sex
	rs("age")=year(date)-byear
	rs("time")=now()
	rs.update
	'///////////////////白金用户会员期提醒
	if Session("weight")=2 then
		set rs_vip=server.createobject("adodb.recordset")
		sql="select * from vip_user where checked=1 and warnning=0 and end_date>#"&dateadd("d",-20,date)&"#"
		sql=sql&" and end_date<#"&date&"#"
		rs_vip.open sql,conn1,3,2 
		if rs_vip.RecordCount<>0 then
			while not rs_vip.EOF 
			  
			      SMTPServer_username=Application("SMTPServer_username")
					SMTPServer_passwd=Application("SMTPServer_passwd")
					SMTPServer=Application("SMTPServer")
					SystemEmail=Application("SystemEmail")
					SenderName=Application("SenderName")
	
					topic=Application("web_name")&"的来信"
					mailbody=mailbody&"-------------------------------------"&chr(13)
					mailbody=mailbody&rs_vip("user_name")&"，您好！您的VIP会员有效期将在"
					mailbody=mailbody&rs_vip("end_date")&"到期。"&chr(13)
					mailbody=mailbody&" 如果您未能在有效期到来以前给我们汇款充值。"&chr(13)
					mailbody=mailbody&" 我们将自动将您降级为普通会员。"&chr(13)
					mailbody=mailbody&" 谢谢您一如既往的支持！"&chr(13)
					on error resume next
					dim msg,SendMail
					Set msg = Server.CreateObject("JMail.Message")

					msg.silent = true
					msg.Logging = true
					msg.Charset = "gb2312"
					msg.MailServerUserName = SMTPServer_username
					msg.MailServerPassword = SMTPServer_passwd
					msg.From = SystemEmail
					msg.FromName = SenderName
					msg.AddRecipient email,rs_vip("user_name")
					msg.Subject = topic
					msg.Body = mailbody
					msg.Send (SMTPServer)
					set msg=nothing
					
					sql11="update vip_user set warnning=1 where id="&rs_vip("id")
					conn1.Execute(sql11)
				
			rs_vip.MoveNext
			wend
	
		end if
	end if
    '//////////////////////////////
	
	
    if Session("weight")=3 then
		 Response.Redirect "../default.asp" 
	end if
    Response.Redirect "my_personal_status.asp?qq_flag="&qq_flag  '成功，进入到定制的这个公司主页中
end if
%>
    	