+++default.asp+++( kan er ook index.asp van maken naar jou keuze )
<%
if Request.Cookies("emchatrefresh")="" then response.Cookies("emchatrefresh")="15"
%>
<body bgcolor="#FFFFFF" topmargin="5"><center>
<font face='verdana,arial' size='2'>Type nickname
<form action='chat.asp?event=login' method='post'>
<input type='text' name='login' size='10'>
<input type='submit' value='Enter'>
<%if request("error")=1 then response.write "<br><br><font color='red'>Nick "& request("username") &" is used!</font>"%>
</form>
<hr size='1'>
+++chat.asp+++
<%
'----------------setup------------------
title="Chatroom" 'title of web page
'----------------/setup------------------
if request("event")="login" then
if (InStr(application("emchatusers"), ","& request("login") &",")<>0) then response.redirect("default.asp?error=1&username=" & request("login"))
Response.Cookies("emchatlogin")=request("login")
application("emchatusers") = application("emchatusers") & request("login") &"," & minute(now) & ","
Application(20)=Application(19)
Application(19)=Application(18)
Application(18)=Application(17)
Application(17)=Application(16)
Application(16)=Application(15)
Application(15)=Application(14)
Application(14)=Application(13)
Application(13)=Application(12)
Application(12)=Application(11)
Application(11)=Application(10)
Application(10)=Application(9)
Application(9)=Application(8)
Application(8)=Application(7)
Application(7)=Application(6)
Application(6)=Application(5)
Application(5)=Application(4)
Application(4)=Application(3)
Application(3)=Application(2)
Application(2)=Application(1)
Application("1")="<font color='green'><b>"& request.Cookies("emchatlogin") & "</b> enters chatroom</font>"
Response.Redirect "chat.asp"
end if
if request.Cookies("emchatlogin")="" then Response.Redirect"default.asp"
if mid(request.Cookies("emchatlogin"),1,1)=" " then Response.Redirect"default.asp"
if request("event")="post" then
Application(20)=Application(19)
Application(19)=Application(18)
Application(18)=Application(17)
Application(17)=Application(16)
Application(16)=Application(15)
Application(15)=Application(14)
Application(14)=Application(13)
Application(13)=Application(12)
Application(12)=Application(11)
Application(11)=Application(10)
Application(10)=Application(9)
Application(9)=Application(8)
Application(8)=Application(7)
Application(7)=Application(6)
Application(6)=Application(5)
Application(5)=Application(4)
Application(4)=Application(3)
Application(3)=Application(2)
Application(2)=Application(1)
Application("1")="<b>" & request.Cookies("emchatlogin") & ":</b>"& request("text")
Response.Redirect "chat.asp?event=form"
end if
if request("event")="logout" then
Application(20)=Application(19)
Application(19)=Application(18)
Application(18)=Application(17)
Application(17)=Application(16)
Application(16)=Application(15)
Application(15)=Application(14)
Application(14)=Application(13)
Application(13)=Application(12)
Application(12)=Application(11)
Application(11)=Application(10)
Application(10)=Application(9)
Application(9)=Application(8)
Application(8)=Application(7)
Application(7)=Application(6)
Application(6)=Application(5)
Application(5)=Application(4)
Application(4)=Application(3)
Application(3)=Application(2)
Application(2)=Application(1)
Application("1")="<font color='green'><b>"& request.Cookies("emchatlogin") & "</b> leaves chatroom</font>"
userarray=split(application("emchatusers"),",")
userscount=int(((UBound(userarray)+1))-0.5)
for f = 0 to userscount-1 step 2
if userarray(f)=request.Cookies("emchatlogin") then
reptmp=userarray(f) & "," & userarray(f+1) &","
application("emchatusers") = replace(application("emchatusers"),reptmp,"")
end if
next
Response.Cookies("emchatlogin")=""
Response.Redirect"default.asp"
end if
if request("event")="form" then
%>
<body bgcolor="#FFCC99" topmargin="5">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<form action='chat.asp?event=post' method='post' name='chatform'>
<input type='text' name='text' size='50'>
<input type="image" src="images/post.gif" width="84" height="18" border="0">
</td>
<td width="120">
<a href="chat.asp?event=setup" target="_top"><p align="right"><img border="0" src="images/setup.gif" width="44" height="18" ><a href="chat.asp?event=logout" target="_top"></a>
<img border="0" src="images/exit.gif" width="44" height="18"></a>
</td>
</tr>
</table>
</form>
<script language="VBScript">
Sub Window_onLoad
chatform.text.focus
End Sub
</script>
<%
end if
if request("event")="show" then
Response.Write "<meta http-equiv='refresh' content='" & request.Cookies("emchatrefresh") &"'>"
Response.Write "<body bgcolor='#ECE4B0'>"
Response.Write "<font face='arial,verdana' size='2'>"
for f=1 to 20
Response.Write Application(f) & "<br>"
userarray
=split(application
("emchatusers"),",")userscount=int(((UBound(userarray)+1))-0.5)
for f = 0 to userscount-1 step 2
if abs(minute
(now
)-int
(userarray
(f
+1))) > 2 then
application("emchatusers")=replace(application("emchatusers"),userarray(f) & "," & userarray(f+1) & ",","")
if userarray(f)=request("userrefresh") then
reptmp=userarray(f) & "," & userarray(f+1) &","
application("emchatusers") = replace(application("emchatusers"),reptmp,userarray(f) & "," & minute(now) &",")
if request("event")="listusers" then
Response.Write "<meta http-equiv='refresh' content='30'>"
Response.Write "<body bgcolor='#FFCC99'>"
Response.Write "<font face='arial,verdana' size='2'>"
userarray
=split(application
("emchatusers"),",")userscount=int(((UBound(userarray)+1))-0.5)
for f = 0 to userscount-1 step 2
response.write userarray(f) & "<br>"
if request("event")="" then
if request.Cookies("barpos")="" then
%>
<title><%=title%></title>
<frameset rows="37,*" frameborder="0">
<frame name="header" scrolling="no" noresize target="main" src="chat.asp?event=form">
<frameset cols="*,130">
<frame name="main" target="main" scrolling="auto" noresize src="chat.asp?event=show&userrefresh=<%=request.Cookies("emchatlogin")%>">
<frame name="main" scrolling="auto" noresize src="chat.asp?event=listusers" target="main">
</frameset>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
<%
end if
if request.Cookies("barpos")="1" then
%>
<frameset rows="*,37" frameborder="0">
<frameset cols="*,130">
<frame name="contents" target="main" scrolling="auto" src="chat.asp?event=show&userrefresh=<%=request.Cookies("emchatlogin")%>">
<frame name="main" scrolling="auto" src="chat.asp?event=listusers">
</frameset>
<frame name="bottom" scrolling="no" noresize target="contents" src="chat.asp?event=form">
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
<%
if request("event")="refresh" then
Response.Cookies("emchatrefresh")=request("refresh")
Response.Redirect"chat.asp"
if request("event")="aptop" then
Response.Cookies("barpos")=""
Response.Redirect"chat.asp"
if request("event")="aptop1" then
Response.Cookies("barpos")="1"
Response.Redirect"chat.asp"
if request("event")="setup" then
%>
<body bgcolor="#FFCC99">
<b><font face="Arial" size="4">Appearance</font></b>
<hr noshade>
<p align="center"><a href='chat.asp?event=aptop'><img border="0" src="images/bartopico.gif" width="50" height="38"></a>
<a href='chat.asp?event=aptop1'><img border="0" src="images/bardownico.gif" width="50" height="38"></a></p>
<b><font face="Arial" size="4">Refresh</font></b>
<hr noshade>
<center>
<form action='chat.asp?event=refresh' method='post'>
<select size="1" name='refresh'>
<option <%if request.Cookies("emchatrefresh")="5" then Response.Write "selected"%>>5</option>
<option <%if request.Cookies("emchatrefresh")="10" then Response.Write "selected"%>>10</option>
<option <%if request.Cookies("emchatrefresh")="15" then Response.Write "selected"%>>15</option>
<option <%if request.Cookies("emchatrefresh")="20" then Response.Write "selected"%>>20</option>
<option <%if request.Cookies("emchatrefresh")="30" then Response.Write "selected"%>>30</option>
<option <%if request.Cookies("emchatrefresh")="60" then Response.Write "selected"%>>60</option>
</select>
<input type='submit' value='Set refresh (sec.)'>
</form>
<%
%>
+++clear.asp+++
<%
'clear users and chat data
application("emchatusers") = ""
for f=1 to 20
Application(f)=""
next
%>