ASP Chat Box
by Scud Thursday, September 14, 2006
Rating:
Vote this news:
Asp Chat Box s a free and easy to use chat application can be used in a simple website. This version of AspChatBox can read and write only a single file. If you can work on thi script, you may write a custom script for you.
Do not forget to read/write permission on chatlog.txt file
<html>
<head>
<title>ASP Chat Box</title>
<META http-equiv="refresh" content="5">
</head>
<body>
<%
if request.Form("func") = "Send" then
nickName = trim(request.Form("nickName"))
nickName = replace(nickName, "'", "''")
chatBox = trim(request.Form("chatBox"))
chatBox = replace(chatBox, "'", "''")
session("nickName") = nickName
Set objFlSys = Server.CreateObject("Scripting.FileSystemObject")
chatFile = Server.MapPath ("chatlog.txt")
Set objStreamOutput= objFlSys.OpenTextFile (chatFile, 8, TRUE)
ipaddr=Request.ServerVariables("REMOTE_ADDR") & " : "
objStreamOutput.Write "<b>" & nickName & "</b>:"
objStreamOutput.WriteLine chatBox & "<BR>" & vbnewline
Set objStreamOutput = Nothing
end if
Set objFlSys = Server.CreateObject("Scripting.FileSystemObject")
chatFile = Server.MapPath ("chatlog.txt")
Set objStreamInput = objFlSys.OpenTextFile (chatFile, 1, False, False)
Response.Write objStreamInput.ReadALL & "<br/>"
Set objStreamInput=Nothing
%>
<form action="aspchatbox.asp" method="post" >
<strong>Nickname :</strong> <input name="nickName" value="<%=session("nickName")%>"/><br/>
<strong>Message : </strong>
<br/><textarea cols="60" rows="4" name="chatBox"></textarea>
<input type="submit" name="func" value="Send"/>
</form>
</body>
</html>
Do not forget to read/write permission on chatlog.txt file
<html>
<head>
<title>ASP Chat Box</title>
<META http-equiv="refresh" content="5">
</head>
<body>
<%
if request.Form("func") = "Send" then
nickName = trim(request.Form("nickName"))
nickName = replace(nickName, "'", "''")
chatBox = trim(request.Form("chatBox"))
chatBox = replace(chatBox, "'", "''")
session("nickName") = nickName
Set objFlSys = Server.CreateObject("Scripting.FileSystemObject")
chatFile = Server.MapPath ("chatlog.txt")
Set objStreamOutput= objFlSys.OpenTextFile (chatFile, 8, TRUE)
ipaddr=Request.ServerVariables("REMOTE_ADDR") & " : "
objStreamOutput.Write "<b>" & nickName & "</b>:"
objStreamOutput.WriteLine chatBox & "<BR>" & vbnewline
Set objStreamOutput = Nothing
end if
Set objFlSys = Server.CreateObject("Scripting.FileSystemObject")
chatFile = Server.MapPath ("chatlog.txt")
Set objStreamInput = objFlSys.OpenTextFile (chatFile, 1, False, False)
Response.Write objStreamInput.ReadALL & "<br/>"
Set objStreamInput=Nothing
%>
<form action="aspchatbox.asp" method="post" >
<strong>Nickname :</strong> <input name="nickName" value="<%=session("nickName")%>"/><br/>
<strong>Message : </strong>
<br/><textarea cols="60" rows="4" name="chatBox"></textarea>
<input type="submit" name="func" value="Send"/>
</form>
</body>
</html>



