<!--#include file="UC_Client.asp"-->
<%

Function i_Syn_Notify_Reg(UName,UPass,UEmail)
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Exit Function
	'UC整合开始
	dim UID
	UID = uc_user_register(UName,UPass,UEmail)'UCenter同步注册
	UID = Clng(UID)
	if UID>0 then 
		Session(Session_UCUID)=UID
		uc_user_synlogin(UID)'UCenter通知其他应用
	else
		select case UID
			case -1
				Rws "alert('用户名不合法');history.back();"
			case -2
				Rws "alert('包含不允许注册的词语');history.back();"
			case -3
				Rws "alert('用户名已经存在');history.back();"
			case -4
				Rws "alert('Email格式有误');history.back();"
			case -5
				Rws "alert('Email不允许注册');history.back();"
			case -6
				Rws "alert('该Email已经被注册');history.back();"
		end select
		Rend
	end if
	'UC整合结束
End Function

Function i_Syn_Notify_Login(UName,UPass)
	dim UID,iXml,iArr
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Exit Function
	'UC整合开始
	iXml = uc_user_login(UName,UPass)'UCenter同步登录
	iArr = xml2array(iXml)
	UID = iArr(0)
	UID = Clng(UID)
	if UID>0 then 
		Session(Session_UCUID)=UID
		RW uc_user_synlogin(UID)'UCenter通知其他应用
	end if
	'UC整合结束
End Function

Function i_Syn_Notify_UcRegiShow(UName,UPass)
	dim UID,tXml,tArr,t_UserName,t_UserPass,t_UserMail,t_UserNickName,t_UserSex,t_UserID
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Rws "alert('登录失败,请检查输入！');history.back();":Exit Function
	'UC整合开始
	tXml = uc_user_login(UName,UPass)'UCenter同步登录
	'RW "<script>"&tXml&"</script>"
	tArr = xml2array(tXml)
	'RW tArr(1):REND
	UID = tArr(0)
	UID = Clng(UID)
	t_UserName=UName
	t_UserPass=tArr(2)
	t_UserMail=tArr(3)
	t_UserNickName=UName
	t_UserSex=1
	if UID>0 then 
		Session(Session_UCUID)=UID
		'----------注册--------------
		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(Session_UCUID)
		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
		'------------------------
		RW uc_user_synlogin(UID)'UCenter通知其他应用
		Rws "location.href='/i/"&SysConfig("i_Sys_Config_TemplatePath")&"/LoginAccess.html?"&t_GoUrl&"'":Rend
	else
		Rws "alert('登录失败,请检查！');history.back();":Rend
	end if
	'UC整合结束
End Function

Function i_Syn_Notify_LogOut()
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Exit Function
	Rw uc_user_synlogout
End Function

Function i_Syn_Notify_Modify_PassOrMail(username,newpw,email)
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Exit Function
	dim UID
	UID = uc_user_edit(username , "" , newpw , email ,"1", "","")
	
	UID = Clng(UID)
	if UID<0 then
		select case UID
			case -4
				Rws "alert('Email格式有误');history.back();"
			case -5
				Rws "alert('Email不允许注册');history.back();"
			case -6
				Rws "alert('该Email已经被注册');history.back();"
		end select
	end if
End Function

Function i_Syn_Notify_DeleteUser(username)
	if cBool(SysConfig("i_Sys_Config_OpenUCenter"))=false then Exit Function
	uc_user_delete username 
End Function
%>


