<%@Language = "VBScript"%> <% Option Explicit Response.Buffer = True Response.Expires = -1000 %> <% Dim vINIFile Dim vUserName, vUserPassword Dim vUserRoomNumber, vUserRoomPassword Dim vCheckPassword Dim vUserOK, vRoomOK Dim vRoomCount, vRoomName, vRoomPassword Dim vLoginError, vRoomError Dim vUserArray, vMoodArray, vUserCount Dim vCheckOp 'Is user already logged into the chat? 'If they are, send them straight there If Session("ChatName") <> "" Then Response.Redirect "chatroom.asp" Response.Flush Response.End End If 'Load INI-file if necessary vINIFile = Application("INIFile") If vINIFile = "" Then Application.Lock vINIFile = LoadINIFile(Server.MapPath("chat_ini.asp")) Application("INIFile") = vINIFile Application.Unlock End If 'Process Form? If Request.Form("login") = "1" Then vUserName = Request.Form("txtUserName") vUserPassword = Request.Form("txtUserPassword") vUserRoomNumber = CInt(Request.Form("room")) vUserRoomPassword = Request.Form("txtRoomPassword" & vUserRoomNumber) vUserOK = False vRoomOK = False 'Check Room Login vCheckPassword = INIFileValue(vINIFile, "Rooms", "Password" & vUserRoomNumber) If UCase(Trim(vCheckPassword)) = UCase(Trim(vUserRoomPassword)) Then vRoomOK = True Else vRoomError = "Incorrect Password for Room '" & INIFileValue(vINIFile, "Rooms", "Name" & vUserRoomNumber) & "'" vRoomOK = False End If If vRoomOK Then 'Check User Login Application.Lock vUserArray = Application("ChatUsers" & vUserRoomNumber) vMoodArray = Application("ChatMoods" & vUserRoomNumber) vUserCount = Application("UserCount" & vUserRoomNumber) If vUserName <> "" Then vCheckOp = CheckOp(vUserName, vUserPassword) If vCheckOp = "BadPassword" Then 'Incorrect Password vLoginError = "The user password you entered was incorrect." vUserOK = False Else 'Password is Correct If LogUserIn(vUserName, vUserArray, vMoodArray, vUserCount) = True Then Session("Kicked") = "False" If vCheckOp = "OK" Then Session("Op") = "True" Session("Password") = vUserPassword Else Session("Op") ="False" Session("Password") = "" End If Session("ChatName") = vUserName Session("RoomNo") = vUserRoomNumber Application("ChatUsers" & vUserRoomNumber) = vUserArray Application("ChatMoods" & vUserRoomNumber) = vMoodArray Application("UserCount" & vUserRoomNumber) = vUserCount AddLineToChat vUserRoomNumber, "**" & vUserName & " has arrived**" Session("StartLine") = Application("ChatLineCount" & vUserRoomNumber) Session("LastLine") = Application("ChatLineCount" & vUserRoomNumber) vUserOK = True Else 'Bad Login - user already exists vLoginError = "That username is already in use." vUserOK = False End If End If Else 'Cannot use empty user name vLoginError = "You must enter a valid user name." vUserOK = False End If Application.Unlock End If If vUserOK And vRoomOK Then Response.Redirect "chatroom.asp" Response.Flush Response.End End If Else vUserRoomNumber = 1 End If %> Untitled Document
Site hosted by Angelfire.com: Build your free website today!
Chat Room Login Page
<%If vLoginError<>"" Then%>
<%=vLoginError%>
<%End If%> <%If vRoomError<>"" Then%>
<%=vRoomError%>
<%End If%> <% vRoomCount = 1 Do vRoomName = INIFileValue(vINIFile, "Rooms", "Name" & vRoomCount) If vRoomName = "" Then Exit do vRoomPassword = INIFileValue(vINIFile, "Rooms", "Password" & vRoomCount) %> <% vRoomCount = vRoomCount + 1 Loop %>
1. Enter Login Information
Name
Password
(operators only)
     
2. Select a Room
Select
Name
Users
Password
 
>
<%=Server.HTMLEncode(vRoomName)%>
<%=(0 + Application("UserCount" & vRoomCount))%>
<%If vRoomPassword<>"" Then%> <%Else%> (not required) <%End If%>
 
3. Click to Log In
<% Response.Flush Response.End %>