% Option Explicit %> <% Dim ChatID Dim requestedUsername ChatID = Request("ChatID") requestedUsername = Server.HTMLEncode( Request("username") ) ' do not show login screen if a valid session exists If (ChatID <> "") Then Response.Redirect "chat.asp?ChatID=" & ChatID Response.End End If Dim mode, x, errorMessage mode = Request("mode") If ( (mode = "userLogin") ) Then If ( Len(Request("username")) < 1 ) Then errorMessage = "You have to enter a username before starting to chat" Else ' Check if this user exist already requestedUsername = Left(requestedUsername, 20) If (Not FindUser(requestedUsername) AND (InStr(requestedUsername, "|") = 0)) Then ' we have a new chat user thus we need to create a new ' id for him/her ChatID = CStr(Timer) ' safe enough for now Application.Lock Application.StaticObjects.Item("ASPChat").Add ChatID, requestedUsername Application.StaticObjects.Item("ASPChatTime").Add ChatID, CStr(Now()) ' tell all other users about this new user For x = MESSAGES To 2 Step -1 Application("chatline_" & x) = Application("chatline_" & x-1) Next Application("chatline_1") = "