<%@ Language=VBScript %>
<%Option Explicit
Response.Buffer = True
%>
<!-- #INCLUDE FILE = "inc.asp" -->
<!-- #INCLUDE FILE = "config.asp" -->
<%
Dim iGUID, sNickName, bSex, bShowSex
Dim dtBirthday, bShowAge, sEmail, sPortrait, bChangePortrait, sAboutMe
Dim sOldPassword, sPassword1, sPassword2, bChangePassword


iGUID = Request.Form("GUID")
sNickName = Trim(Request.Form("NickName"))
bSex = Request.Form("Sex")
bShowSex = Request.Form("ShowSex")
dtBirthday = Request.Form("Birthday")
bShowAge = Request.Form("ShowAge")
sEmail = Trim(Request.Form("Email"))
sPortrait = Request.Form("Portrait")
bChangePortrait = Request.Form("ChangePortrait")
sAboutMe = Request.Form("AboutMe")

sOldPassword = Request.Form("OldPassword")
sPassword1 = Request.Form("Password1")
sPassword2 = Request.Form("Password2")
bChangePassword = Request.Form("ChangePassword")

If bChangePassword = 1 Then
	If sPassword1 <> sPassword2 Then
		err("两次密码不一样，请您核对您输入的新密码。")
	End If
End If

If sNickName = "大家" Then err("非法昵称，请另选好名！")

Dim oChat
Set oChat = Server.CreateObject("LSChat.Users")
oChat.Configure g_SiteName, g_SiteDomain, g_DBString, g_ErrFile, g_ScriptName

Dim rst
Set rst = oChat.GetChatUserByNickName(sNickName)

If Not rst.EOF Then
	If rst("GUID") <> CLng(iGUID) Then
		rst.Close
		Set rst = Nothing
		Set oChat = Nothing
		err("已经有人使用了这个昵称，请重新选择。")
	End If
End If

rst.Close
Set rst = Nothing

If bChangePassword = 1 Then
	Dim rstUser
	Set rstUser = oChat.GetUserByGUID(iGUID)
	If rstUser("PASSWORD") <> sOldPassword Then
		rstUser.Close
		Set rstUser = Nothing
		Set oChat = Nothing
		err("您输入的原始密码不正确！")
	End If
	rstUser("PASSWORD") = sPassword1
	rstUser.Update
	rstUser.Close
	Set rstUser = Nothing
End If

Dim rstChatUser
Set rstChatUser = oChat.GetChatUser(iGUID)
	
rstChatUser("NickName") = sNickName
rstChatUser("Sex") = bSex
rstChatUser("ShowSex") = bShowSex
rstChatUser("Birthday") = dtBirthday
rstChatUser("ShowAge") = bShowAge
rstChatUser("Email") = sEmail
If bChangePortrait = 1 Then
	rstChatUser("Portrait") = sPortrait
End If
rstChatUser("AboutMe") = sAboutMe

rstChatUser.Update
rstChatUser.Close
Set rstChatUser = Nothing
Set oChat = Nothing

Response.Redirect "vmychatinfo.asp"
%>