<% Option Explicit %> <% Const MESSAGES = 25 ' a maximum of 25 messages are shown on screen Const USERS = 10 ' a maximum of 10 users may join CONST TIMEOUT = 10 ' a session times out after 10 minutes Function FindUser(userName) FindUser = false Dim i For i = 1 To USERS If (userName = Application("onlineUser_" & i)) Then FindUser = true Exit For End If Next End Function %> <% ' do not show login screen if a valid session exists If (Session("chatname") <> "") Then Response.Redirect "chat.html" Response.End End If Dim mode, x, errorMessage mode = Request("mode") If ( (mode = "userLogin") ) Then If ( Len(Request("username")) > 20 ) Then errorMessage = "Username must not exceed 20 characters" Else If ( Len(Request("username")) < 1 ) Then errorMessage = "You have to enter a username before starting to chat" Else Dim requestedUsername ' Check if this user exist already requestedUsername = Server.HTMLEncode( Request("username") ) If (Not FindUser(requestedUsername)) Then ' Session will timeout after X minutes, i.e. user will be logged out ' if there's not entered any text within X minutes. Session.TimeOut = TIMEOUT Session("chatname") = requestedUsername ' 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") = " " & requestedUsername & " logged on at " & now & "
" ' push new username onto our users stack For x = USERS To 2 Step -1 Application("onlineUser_" & x) = Application("onlineUser_" & x-1) Next Application("onlineUser_1") = Session("chatname") Response.Redirect "chat.html" Response.End Else errorMessage = "Sorry, but you can't use this username. Another user is logged in with this already." End If End If End If End If %> ConquerChat On·Line
Make your own free website on Tripod.com
Part of the Theill Web Site
<% Dim chatname, userFound userFound = False ' loop through all users and print active using a bold font For x = 0 To USERS chatname = Application("onlineUser_" & x) If (NOT IsNull(chatname) AND (chatname <> "")) Then userFound = True If ( x MOD 2 ) Then Response.Write "" Else Response.Write "" End If Response.Write " " Response.Write " " Response.Write "" End If Next If (NOT userFound) Then Response.Write "" & vbCrLf Response.Write "" & vbCrLf Response.Write "" & vbCrLf End If %>
<%= errorMessage %>
 Join ConquerChat
username 
 

Current chatusers (max. <%= USERS %>):
" & chatname & " 
   No users