Closed Thread Icon

Topic awaiting preservation: Online chat Pages that link to <a href="https://ozoneasylum.com/backlink?for=12942" title="Pages that link to Topic awaiting preservation: Online chat" rel="nofollow" >Topic awaiting preservation: Online chat\

 
Author Thread
amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 10-20-2003 13:31


Hi, I dont know if this chat-script this is any good.
It's the update from the one previously sported here.
If anyone would take a crack at critizizing it, it would be great.
I know it should be possible to make it work for Opera and Mozilla as well, and I once wrote a version for Netscape.
It should be quite easy to do in PHP as well, for those who knows anything about that, which I dont, unfortunatly.

This is the server-part.

<pre>

<% @ LANGUAGE=JScript %>

<% Response.ContentType = "application/x-javascript .js" %>

<%

ForAppending=8;
ForWriting=2;
ForReading=1;

tribuned=new String(Request.Querystring);
tribuned=tribuned.split("<cut>");

if(!tribuned[1])
{

%>

reply="";
num="";
adress="liquid21";
winx=0;
window.str=0;

document.write("<script id='call'><"+"/script>");
window.onload=signOn;

function thePackage()
{
str=document.all.register.template;
if(str=="0"){str="<br/><font style='color:black;border:solid black 2px;width:200;padding:3px;font-face:verdana;font-size:10pt;'><b>[TITLE]</b><br/><b style='cursor:hand;color:black;background-color:silver;border:solid red 1px;padding:2px;height:15;overflow:hidden;width:70;font-size:9px' onclick='callUp()' visitor='[THE_ID]'>Send to..</b><br/><br/>Post: <span id='account'>[POST]</span></font>";}
if(document.all.title){str=str.replace("[TITLE]",document.all.title.value);}
if(document.all.post){str=str.replace("[POST]",document.all.post.value);}
if(document.all.link_to){str=str.replace("[LINK_TO]",document.all.link_to.value);}
if(document.all.mail){str=str.replace("[MAIL_TO]",document.all.mail.value);}
str=str.replace("[THE_ID]",document.body.timestamp);
package=escape(str);
return package
}
function Call()
{
validate(document.all.post.value);
conn="http://www.naltabyte.se/rent_a_chat/files/mail.asp?the_mail_out<cut>";
num++;
thePackage();
act=adress+"<cut>"+package+"<cut> 'the_"+num+"'";
document.all.call.src=conn+act;
document.all.post.value="";
if(reply==""){return false;}
else
{
num++;
reply="";
setTimeout('CallOne(0,1)',2000);
}
}

function CallOne(addon,arg)
{
conn="http://www.naltabyte.se/rent_a_chat/files/mail.asp?the_mail_in<cut>";
num++;
act=addon+"<cut>"+document.body.setTime+"<cut>"+document.all.post.value+"---"+document.all.title.value+"<cut>-<cut> 'the_"+num+"'";
if(!arg){document.all.post.value="";}
call.src=conn+act;
if(reply==""){return false;}
else
{
num++;
reply="";
}
}

function signOn()
{
day=new Date();
day=day.toGMTString();
day=day.replace(/:/g,".");
if(top!=self)
{
if(!document.body.timestamp)
{
document.body.timestamp=parent.setIdentity;
}
}
else if(!document.body.timestamp)
{
document.body.timestamp=day;
}
document.body.setTime="0";
setInterval('CallOne(0,1)',6000);
}


function validate(data)
{
ndata=document.all.post.value;
for(i=0;i < ndata.length;i++)
{
ndata=ndata.replace("<","<");
ndata=ndata.replace(">",">");
ndata=ndata.replace("(","acccc");
ndata=ndata.replace(")","cccca");
ndata=ndata.replace('"','&quot;');
}
document.all.post.value=ndata;
}
function callUp()
{
document.body.setTime=event.srcElement.visitor;
CallOne('send');
}

<%
}


if(tribuned[0]=="the_mail_out"){finish();}
if(tribuned[0]=="the_mail_in"){startup();}
if(tribuned[1]=="send"){sender();}


function finish()
{
strFil="";
indata=" ";
Fsave=" ";
Fstore="";

fso=new ActiveXObject("Scripting.FileSystemObject");

if(fso.FileExists(Server.MapPath("liquid21")))
{
ofil=fso.OpenTextFile(Server.MapPath("liquid21"), ForReading, true);
while(!ofil.AtEndOfStream){strFil+=ofil.ReadLine();}

var x=unescape(strFil);
x=x.split("#");
for(i=0;i < 5;i++){if(!x[i]){break;}indata+=x[i]+"#";}
ofil.Close();

File=fso.OpenTextFile(Server.MapPath("liquid21"), ForWriting, true);
Fsave+=tribuned[2];
Fsave+="<span style='visibility:hidden'>#</span><br>";
File.WriteLine(unescape(Fsave));
File.Write(unescape(indata));
File.Close();
}
if(!fso.FileExists(Server.MapPath("liquid21")))
{
objFile=fso.CreateTextFile(Server.MapPath("liquid21"), true);
objFile.Write(" ")
objFile.Close();
}


%>

<%
}

function startup()
{
strFil="";
indata="";

fso=new ActiveXObject("Scripting.FileSystemObject");
if(fso.FileExists(Server.MapPath("liquid21")))
{
ofil=fso.OpenTextFile(Server.MapPath("liquid21"), ForReading, true);
while(!ofil.AtEndOfStream){strFil+=ofil.ReadLine();}
ofil.Close();

x=unescape(strFil);
x=x.split("#");

for(i=0;i < 6;i++){if(!x[i]){break;}indata+=x[i];}

str="";
fso=new ActiveXObject("Scripting.FileSystemObject");
ofile=fso.OpenTextFile(Server.MapPath("mail.txt"));
while(!ofile.AtEndOfStream) {str += ofile.ReadLine();}
ofile.Close();

%>

printoutdata="<% Response.Write(indata) %>";

printoutdata1=printoutdata.replace(/acccc/g, "(");
printoutdata1=printoutdata1.replace(/cccca/g, ")");

document.all.printOut.innerHTML=printoutdata1;
reply="Success";

recalling();

function recalling()
{
x="<% Response.Write(str) %>";
identity=x.split("<cut>");

if(identity[0]==document.body.timestamp && window.str!=identity[1])
{
window.str=identity[1];
winx=window.open("about:blank","javas","height=120,width=140,resizable=no,scrollbars=no");
winx.document.write("<html><title>Message</title><body oncontextmenu='return false' style='background:butt****ce;border:0'><center><div style='border:inset 1px;height:80px;width:120px;overflow:scroll;background:white;font-family:verdana;font-size:10px;padding:5px'>"+identity[1]+"</div></center></body></html> ");
winx.focus();
}
}

<%
}
}

function sender()
{
objFSO=new ActiveXObject("Scripting.FileSystemObject");
objFile=objFSO.CreateTextFile(Server.MapPath("mail.txt"), true);
objFile.Write(unescape(tribuned[2])+"<cut>"+unescape(tribuned[3]))
objFile.Close();
}

%>

</pre>

This is the client-part.
I use the attribute 'template' in the script-tag to define how I want the posts to be formatted.
It's sent to the server along with the posts.
That way, I can have multiple instances of this chat, with different interfaces and posts, adjusted to the design.

<pre>

<html>
<head>
<title>Naltabyte_chat v.1.0</title>
<script
id="register"
mode="chat"
template="<br><font style='overflow:scroll;color:black;border:solid black 2px;width:200;padding:3px;font-face:verdana;font-size:10pt;background:white'><b>[TITLE]</b><br><span style='text-align:center;margin:1px;font-family:verdana;font-size:9px;cursor:hand;color:black;background-color:buttonhighlight;border:solid black 1px;width:70;font-size:9px;display:block' onclick='callUp()' visitor='[THE_ID]'>Send to..</span><span id='account'><span onclick='parent.viewTheCodeNow(this.parentElement.children(1).innerText)' style='text-align:center;margin:1px;border:black 1px solid;background-color:buttonhighlight;font-family:verdana;font-size:9px;cursor:hand;display:block;width:70'>Codeview</span><span>[POST]</span></span>&lt ;/font>";
src="http://www.naltabyte.se/rent_a_chat/files/mail.asp">
</script>
</head>
<body oncontextcode="return false" scroll="no" style="background-color:butt****ce;border:0">

<center>

<table style="width:100%;height:100%;border:0;z-index:8;padding:10">
<tr valign="top" style="width:100%;height:100%">
<td align="right" style="width:30%;height:100%">

<input type="text" id="title" style="background-color:white;border:solid gray 1px;width:100%"><b>Name:</b><br />
<textarea id="post" style="background-color:white;border:solid gray 1px;width:100%;height:70%"></textarea>
<br />
&nbsp;<button onclick="Call()" style="background:white;border:gray 1px solid;height:20;width:50;font-size:10">Post</button>
</td>
<td style="width:50%;height:100%">
<div id="printOut" style="position:relative;top:3;left:0;padding:15;background:white;width:100%;height:100%;overflow:scroll">
</div>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="width:100%;height:100%">
</td>
</tr>
</table>
</center>

</body>
</html>


</pre>



(^-^)b

pwhitrow
Bipolar (III) Inmate

From: UK
Insane since: Feb 2002

posted posted 10-20-2003 17:23

Hi amikael,

I have written a chat application myself, it's called netCOMs and is written in php/mysql.
You can take a look at it by going to my home page and clicking on the netCOMs logo.

Cheers,

Paul

www.pwhitrow.com

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 10-20-2003 19:59

Nice, but is it open source?
Can I peak at the client/server-code to build/add new features??

It's great stuff, but what I'm kinda aiming for here, is to develop a free open source solution that anyone can use, and which have all the bells and whistles that one expects.

I know that my solution don't have that, so I was hoping for some input on how to come closer to that.

(^-^)b

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 10-20-2003 20:38

pwhitrow: I know I'd also be interested in nosing around your code

___________________
Emps

The Emperor dot org

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 10-20-2003 21:44

What do you mean?
It's all here..

(^-^)b

Hub-izer
Bipolar (III) Inmate

From: The little green dot at the center of your monitor
Insane since: Jul 2003

posted posted 10-27-2003 23:27

Hi,

I'm developing a real-time HTML/JavaScript/PHP/MySQL chat. It's coming along fine, I'm near to a beta.
I aim to replace phpMyChat. Ambitious, ne?

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 11-08-2003 19:49

Im sure you are all doing it established ways, and Ill be breaking the trend, being a javascripter, but may I make a suggestion?

Have a simple chat page - textarea, text box and submit button.
Then, inside it, have 2 invisible iframes.
Then, at regular intervals, "get" information via one iframe using a cgi script
With the other simply send the info via a "?" page and send it using a cgi script
There are complications, I know, like u cant send all the chat info each time due to bandwidth, only the info since your last update, so you have to use identifiers and stuff.
It's really not that hard (I think). I don't my server I am writing on at the moment, but I will try to write and submit the code here at some point.

Am i missing something, or can you just do it with javascirpt and cgi?

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer!

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 11-09-2003 17:41

Thats how I'd prehaps do it.
or rather than 'getting' at set times
simply give the user a 'get' button there selves that they click to get the new content

Trigger

[url=http://hackingzone.org/]
Fatal Industries -- The-bronze webhosting

« BackwardsOnwards »

Show Forum Drop Down Menu