<!--#include file="../conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/Language.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册用户邮件激活</title>
</head>
<body>
<%
Dim act

act=Trim(Request.QueryString("act"))

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	siteinfo=AskD.siteinfo
	setting=AskD.setting
    regForm=AskD.regForm

IF act="" Then
   Call chkActivated()
ElseIF act="chk" Then
   Call PostActivated()
End IF
set AskD.myConn =Nothing
Closedb
Set AskD = Nothing

Sub chkActivated()
Dim Activated,ID,rs,sql
	Activated=Trim(Request.QueryString("Activated"))
	ID=Trim(Request.QueryString("ID"))
	Set rs = Server.CreateObject("adodb.recordset")
	sql="select isLock,Activated,isActivated from "&predb&"user where id="&ID&" and Activated='"&Activated&"'"
	rs.open sql,conn,1,3
	IF rs.bof and rs.eof Then
	   Response.Write(" 抱歉，您的激活不存在，您或许已经激活完毕！")
	   rs.close
	   set rs=nothing
	Else
	   rs("isLock")=0
	   rs("Activated")=""
	   rs("isActivated")=1
	   rs.update
	   rs.close
	   set rs=nothing
	   Response.Cookies("islock")=0
	   Response.Write(" 恭喜你，激活成功了！")
	End IF
	Response.Write("<script>setTimeout(""location.href='../'"",2000)</script>")
End Sub

Sub PostActivated()
Dim rs,sql,Activat
   IF regForm(3)=0 then
	 set rs = Server.CreateObject("adodb.recordset")
	 sql="select Userid,userpass,Usermail,Activated from "&predb&"user where id="&Request.Cookies("Muser")
	 rs.open sql,conn,1,3
	    ToMail=rs("Usermail")
	    Activat=Md5(rs("Userid")&rs("Userpass")&ToMail&AskD.Activated,16)
	    Rs("Activated")=Activat
	 rs.update
	 rs.close
	 set rs=nothing
	 Dim From,FromName,Topic,MailBody,ToMail,SmtpName,SmtpPass,MailSmtp
			Topic=siteInfo(4)&" - "&Lan1
			MailBody=Lan2&" <a target='_blank' href='"&siteInfo(0)&siteInfo(1)&"User/Activated.asp?ID="&Request.Cookies("Muser")&"&Activated="&Activat&"'>"&siteInfo(0)&siteInfo(1)&"User/Activated.asp?ID="&Request.Cookies("Muser")&"&Activated="&Activat&"</a>"
			
			MailSmtp=setting(39)
			SmtpName=setting(40)
			SmtpPass=setting(41)
			From=setting(42)
			FromName=siteInfo(4)
	 '发送激活邮件
		Call AskD.SendMail(From,FromName,Topic,MailBody,ToMail,SmtpName,SmtpPass,MailSmtp)
		IF err Then  Response.Write "请管理员确认邮件发送选项是否正确！":response.End()
		IF AskD.Isgo then 
			 Response.Write "激活邮件已经发送到你的邮箱，请激活！"
		Else
			 Response.Write "激活邮件发送失败，请联系管理员激活！"
		End IF
   Else
      Response.Write "注册控制未打开注册激活，您不用激活！"
   End IF
End Sub
%>
</body>
</html>
