Logge bruger af chat automatisk
Ikke alle er så venlige at logge af når forlader min chat så hvis nogen kan logge dem af automatisk efter de ikke har været på i 30 minutter så er mine point givet godt ud koden er som følger :<%
Option Explicit
Dim NUMBER_OF_MESSAGES
NUMBER_OF_MESSAGES = 25
If (Session(\"chatname\") = \"\") Then
Response.Redirect \"default.asp\"
End If
%>
<html>
<head>
<META HTTP-EQUIV=\'Refresh\' CONTENT=\'8; URL=window.asp\'>
<title></title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"chat.css\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"navy\" link=\"navy\" vlink=\"navy\" alink=\"navy\">
<%
\' user wants to logoff, so we will have to notify all other users
\' about this by printing some kind of \'user X is now logging off\'
\' message.
If ( Len(Request(\"logoff.x\")) > 0) Then
Dim x, chatname
chatname = Session(\"chatname\")
\' add a leaving message to chatroom
For x = NUMBER_OF_MESSAGES To 2 Step - 1
Application(\"chatline_\" & x) = Application(\"chatline_\" & x-1)
Next
Application(\"chatline_1\") = \"<span class=\"\"Info\"\"><img src=\"\"images/bp.gif\"\" height=\"\"9\"\" width=\"\"9\"\"> \" & chatname & \" decided to leave us at \" & now & \"</span>\"
\' update online users by removing this user and
\' rearranging other users below him/her
For x = 1 To 20
If (chatname = Application(\"onlineUser_\" & x)) Then
Dim y
Application(\"onlineUser_\" & x) = \"\"
For y = x To 9
Application(\"onlineUser_\" & y) = Application(\"onlineUser_\" & y+1)
Next
Application(\"onlineUser_20\") = \"\"
End If
Next
\' invalidate session
Session(\"chatname\") = \"\"
Session.Abandon
%>
<script language=\"javascript\">
parent.parent.krop.location.href = \"default.asp\";
</script>
<% Else
\' a new message has been send to chat. we want this message to
\' be added our list of message, indicating which user send it.
If ( Request(\"mode\") = \"message\" ) Then
Dim textMessage
textMessage = Request(\"message\")
\' do not add message, if it is empty
If (Len(textMessage) > 0) Then
Dim i, text
\' move all messages one item down in queue
For i = NUMBER_OF_MESSAGES To 2 Step -1
Application(\"chatline_\" & i) = Application(\"chatline_\" & i-1)
Next
\' build new message
text = \"<table border=\'0\' cellpadding=\'2\' cellspacing=\'0\' width=\'100%\'>\" & _
\"<tr>\" & _
\" <td nowrap><span class=\"\"Name\"\">\" & Session(\"chatname\") & \"</span></td>\" & _
\" <td align=\'justify\' width=\"\"100%\"\"><span class=\"\"Message\"\">\" & Server.HTMLEncode(textMessage) & \"</span></td>\" & _
\"</tr>\" & _
\"</table>\"
\' add message as first message in queue
Application(\"chatLine_1\") = text
End If
End If
End If \' >> If ( Len(Request(\"logoff.x\")) > 0) Then
\' print all messages in window
For i = 1 To NUMBER_OF_MESSAGES
Response.Write Application(\"chatline_\" & i) & \"<br>\"
Next
If ( Len(Request(\"logoff.x\")) > 0) Then
Response.Redirect \"../index.html\"
End If
%>
</body>
</html>
