<!--#include file="../inc/Bll.asp"-->
<!--#include file="../inc/Constant.asp"-->
<!--#include file="../inc/Md5.asp"-->
<!--#include file="../inc/App.asp"-->
<%
'验证网站是否开启注册
if Cint(SysConfig("i_Sys_Config_OpenReg"))=0 then Rws  "alert('网站已关闭对外注册功能!');history.back();":Rend

'注册验证
LocalValid
'整合应用注册
i_Syn_Notify_Reg t_UserName,t_UserPass,t_UserMail 
'本地数据注册
LocalReg

dim t_UserID,t_UserName,t_UserPass,t_ReUserPass,t_UserNickName,t_UserMail,t_UserSex
'本地注册验证
Sub LocalValid()
	'验证数据
	if request.form("Method")<>"Reg" then Rws "alert('非法请求!');history.back();":Rend
	CheckVCode '验证码
	t_UserName = CheckSub(vAccount,request.form("UserName"),"账号格式有误") '验证账号
	t_UserPass = CheckSub(vPwd,request.form("UserPass"),"密码格式有误") '验证密码
	t_ReUserPass = CheckSub(vPwd,request.form("ReUserPass"),"二次密码格式有误") '验证二次密码
	if t_UserPass<>t_ReUserPass then Rws "alert('两次输入密码不相同!');history.back();" '验证密码是否相同
	t_UserNickName = CheckSub(vNickName,request.form("UserNickName"),"昵称格式有误") '验证昵称
	t_UserMail = CheckSub(vEmail,request.form("UserMail"),"邮箱格式有误") '验证邮箱
	if not IsNumeric(Request.Form("User_Sex")) then rws "alert('非法参数!');history.back();":Rend
	t_UserSex = Request.Form("User_Sex")
	if not CheckRepeatUserName(t_UserName) then rws "alert('账号已被注册!');history.back();":Rend
	if not CheckRepeatMail(t_UserMail) then rws "alert('邮箱地址已被使用!');history.back();":Rend
	if not CheckRepeatNick(t_UserNickName) then rws "alert('昵称已被使用!');history.back();":Rend
End Sub

'本站数据注册
Sub LocalReg()
	RS_End
	'注册用户
	RS.OPEN "select top 1 * from [i_User_Info]" , DB_CONN , 1 , 3
	RS.addnew()
	RS("i_User_Name")=t_UserName
	if Session("i_UC_UID")<>"" then RS("i_User_UCID")=Session("i_UC_UID")
	RS("i_User_Pass")=MD5(t_UserPass)
	RS("i_User_Mail")=t_UserMail
	RS("i_User_Sex")=t_UserSex
	RS("i_User_NickName")=t_UserNickName
	RS("i_User_Class")=SysConfig("i_Sys_Config_RegDefaultClass")
	RS("i_User_Score")=SysConfig("i_Sys_Config_RegDefaultScoreNum")
	RS("i_User_Money")=SysConfig("i_Sys_Config_RegDefaultMoneyNum")	
	RS.update()
	RS_End
	'读取注册用户ID
	Set RS=DB_CONN.EXECUTE("select top 1 * from [i_User_Info] where [i_User_Name]='"&t_UserName&"'")
	if RS.RecordCount<1 then Rws "alert('网站注册异常,请联系网站管理员');history.back();":Rend
	t_UserID = RS("i_User_ID")
	Session(Session_UserID_Arg)=RS("i_User_ID")
	Session(Session_UserName_Arg)=RS("i_User_Name")
	Session(Session_UserNickName_Arg)=RS("i_User_NickName")
	Session(Session_UserSex_Arg)=RS("i_User_Sex")
	Session(Session_UserClass_Arg)=RS("i_User_Class")
	Session(Session_UserFace_Arg)=RS("i_User_Face")
	Session(Session_LogIP_Arg)=get_IP()
	Session(Session_LogTime_Arg)=now()
	RS_End
	'注册房间
	RS.OPEN "select top 1 * from [i_Sys_Room]" , DB_CONN , 1 , 3
	RS.addnew()
	RS("i_Sys_Room_Name")=t_UserNickName
	RS("i_Sys_Room_AdminUserID")=t_UserID
	RS("i_Sys_Room_ManagerUsers")="|"&t_UserID&"|"
	RS.update()
	RS_End
	'读取注册房间ID
	Set RS=DB_CONN.EXECUTE("select top 1 * from [i_Sys_Room] where [i_Sys_Room_AdminUserID]='"&t_UserID&"'")
	Session(Session_RoomID_Arg)=RS("i_Sys_Room_ID")
	RS_End
	Rws "location.href='/i/"&SysConfig("i_Sys_Config_TemplatePath")&"/RegAccess.html'":Rend
End Sub

%>