% Option Explicit %>
<%
'
' :@default.asp
'
' This page is the main entrace for ConquerChat. It shows a list of currently
' logged in chatusers and makes it possible to log in by entering your user-
' name in the appropriate field.
'
' @author Peter Theill peter@theill.com
'
Response.Buffer = True
' many users does not read the included README.TXT file before trying to
' set up this chat -- in order to help them a bit we check if we have the
' required objects properly initialised
On Error Resume Next
If (NOT IsObject(conquerChatUsers) OR NOT IsObject(conquerChatRooms)) Then
Response.Redirect("errorInSetup.asp")
Response.End
End If
' Enable constant (from constants.inc) to reinitialise the chat in order to
' fix users hanging in the chat or to apply room changes. Make sure you dis-
' able the constant once again after having displayed this (default.asp)
' page or you will clear all users every time the default.asp page is shown.
If (INITIALIZING_CHATSYSTEM) Then
conquerChatUsers.RemoveAll
conquerChatRooms.RemoveAll
conquerChatMessages.RemoveAll
End If
Dim userId
userId = Request("chatId")
' do not show login screen if a valid session exists
If (userId <> "") Then
Response.Redirect "frames.asp?chatId=" & userId
Response.End
End If
Function isUserNameBlocked(userName)
isUserNameBlocked = False
End Function
Dim i
Dim mode, errorMessage
mode = Request("mode")
If (mode = "userLogin") Then
Dim userName
userName = Server.HTMLEncode(Request("userName"))
If (countUsers() >= USERS) Then
errorMessage = "The maximum number of users have been reached. You are not allowed to login at this time."
ElseIf (Len(userName) = 0) Then
errorMessage = "You have to enter a username before starting to chat."
ElseIf (Len(userName) > MAX_USERNAME_LENGTH) Then
errorMessage = "Username must not exceed " & MAX_USERNAME_LENGTH & " characters."
ElseIf (userExists(userName)) Then
errorMessage = "Sorry,
You cannot use this username, since another person is using this already."
ElseIf (InStr(userName, Chr(1)) <> 0) Then
errorMessage = "Your username contains inappropriate characters. Please choose another one."
ElseIf (isUserNameBlocked(userName)) Then
errorMessage = "You cannot log on with this username."
Else
Dim p
Set p = New Person
p.id = -1
p.name = userName
p.roomId = 0
p.ipAddress = Request.ServerVariables("REMOTE_ADDR")
' we have a new chat user thus we need to create a new
' id for him/her
Set p = addUser(p)
' tell all other users about this new user
Call addMessage( _
p.id, _
"-1", _
"
" & p.name & " logged on at " & Now() & "
" _
)
' redirect to new frame window and create a new user login
Response.Redirect("frames.asp?chatId=" & p.id)
Response.End
End If
End If ' > If (mode = "userLogin") Then
' make sure we don't show any inactive users for new chat users
kickInactiveUsers()
' create default rooms if no is available (which will be the case the
' very first time after a server restart)
Application.Lock
If (conquerChatRooms.Count = 0) Then
Dim defaultRooms
defaultRooms = Split(DEFAULT_ROOMS, ";")
If (IsArray(defaultRooms)) Then
For i = 0 To UBound(defaultRooms)
defaultRooms(i) = Trim(defaultRooms(i))
If (defaultRooms(i) <> "") Then
Call addRoom(defaultRooms(i), "-1")
End If
Next
End If
End If
Application.UnLock
%>