%
'==================================
' 用户注册页面
' 更新时间: 2006-5-29
'==================================
if blog_Disregister then showmsg "错误信息","站点不允许注册新用户
单击返回","ErrorIcon",""
%>
<%
IF Request.QueryString("action")="agree" then
logout(true)
%>
<%
ElseIF Request.form("action")="save" then
dim reg
reg=register
%>
<%
function register
dim ReInfo
dim username,password,Confirmpassword,Gender,email,homepage,validate,HideEmail,checkUser
ReInfo=Array("错误信息","","MessageIcon")
username=trim(CheckStr(request.form("username")))
password=trim(CheckStr(request.form("password")))
Confirmpassword=trim(CheckStr(request.form("Confirmpassword")))
Gender=CheckStr(request.form("Gender"))
email=trim(CheckStr(request.form("email")))
homepage=trim(checkURL(CheckStr(request.form("homepage"))))
validate=CheckStr(request.form("validate"))
if request.form("hiddenEmail")=1 then
HideEmail=true
else
HideEmail=false
end if
if len(username)=0 then
ReInfo(0)="错误信息"
ReInfo(1)="
请输入用户名(昵称)!单击返回"
ReInfo(2)="WarningIcon"
register=ReInfo
exit function
end if
if len(username)<2 or len(username)>24 then
ReInfo(0)="错误信息"
ReInfo(1)="
用户名(昵称)不能小于2或
大于24个字符!单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
if IsValidUserName(username)=false then
ReInfo(0)="错误信息"
ReInfo(1)="
非法用户名!
请尝试使用其他用户名!单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
set checkUser=conn.execute("select top 1 mem_id from blog_Member where mem_Name='"&username&"'")
if not checkUser.eof then
ReInfo(0)="错误信息"
ReInfo(1)="
用户名已经被注册!
请尝试使用其他用户名!单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
if len(password)=0 or (len(password)<6 or len(password)>16) then
ReInfo(0)="错误信息"
ReInfo(1)="
请输入6到16位密码!单击返回"
ReInfo(2)="WarningIcon"
register=ReInfo
exit function
end if
if password<>Confirmpassword then
ReInfo(0)="错误信息"
ReInfo(1)="
密码验证失败!请重新输入。单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
if len(email)>0 and IsValidEmail(email)=false then
ReInfo(0)="错误信息"
ReInfo(1)="
错误的电子邮件地址。单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
IF cstr(lcase(Session("GetCode")))<>cstr(lcase(validate)) then
ReInfo(0)="错误信息"
ReInfo(1)="
验证码有误,请返回重新输入单击返回"
ReInfo(2)="ErrorIcon"
register=ReInfo
exit function
end if
dim strSalt,AddUser,hashkey
hashkey=SHA1(randomStr(6)&now())
strSalt=randomStr(6)
password=SHA1(password&strSalt)
AddUser=array(array("mem_Name",username),array("mem_Password",password),array("mem_Sex",Gender),array("mem_salt",strSalt),array("mem_Email",email),array("mem_HideEmail",int(HideEmail)),array("mem_HomePage",homepage),Array("mem_LastIP",getIP),Array("mem_lastVisit",now()),Array("mem_hashKey",hashkey))
DBQuest "blog_member",AddUser,"insert"
'Conn.Execute("INSERT INTO blog_member(mem_Name,mem_Password,mem_Sex,mem_salt,mem_Email,mem_HideEmail,mem_HomePage,mem_LastIP) Values ('"&username&"','"&password&"',"&Gender&",'"&strSalt&"','"&email&"',"&HideEmail&",'"&homepage&"','"&getIP&"')")
Conn.ExeCute("UPDATE blog_Info SET blog_MemNums=blog_MemNums+1")
getInfo(2)
SQLQueryNums=SQLQueryNums+2
ReInfo(0)="用户注册成功"
ReInfo(1)="
注册并自动登录成功,三秒钟返回首页!如果您的浏览器没有自动跳转,请点击这里"
ReInfo(2)="MessageIcon"
register=ReInfo
Response.Cookies(CookieName)("memName")=username
Response.Cookies(CookieName)("memHashKey")=hashkey
Response.Cookies(CookieName).Expires=Date+365
Session(CookieName&"_LastDo")="RegisterUser"
end function
Else
%>
<%End if%>