Page 1 of 1

I made a sort of 'chat room'

Posted: 17 Jul 2006, 21:11
by Gogeta70
Yeah, i made a small completely web based chat room out of php. You can test it here, but i only know it works perfectly in firefox... (i don't care about making it compatible, it's not gonna be commercial) Anyway, if anyone's interested, i'll put the code up.

http://beta:tester@fatalh.sytes.net/testing/chat

Next up: Web based IRC chat!

Posted: 18 Jul 2006, 16:00
by bad_brain
w00t! well done buddy.... :D
the only "problem" is that the chatbox content scrolls up on the site reload, so it´s "hops" up and down...post the source if you want to... :)

Posted: 18 Jul 2006, 21:11
by Gogeta70
Yeah, i can't figure out a better way to keep the box at the bottom... taking ideas...


Index.php

Code: Select all

<?PHP

$id = NULL;
$id = @$_GET['nick'];

?>
<html><head>
<scr ipt language='javascript'>
var a = 5;

function chframe(chat)
{
chat.src="l2.php#bottom"
}
</sc ript>
</head>	
<body onload="document.forms[0].send.focus()">
<span style="font-family:Verdana; font-size:11px;">
<iframe name='chat' onload="chframe(this)" src="l2.php#bottom" style="width:400px; height:200px; border:1px solid black;">
</iframe><br>
<form action=send.php method=post>
<input type=text name=send size=54 maxlength=512 style="margin-top:3px;">
<input type=submit value="Send" style="border:1px solid black; background:#CCCCCC; font-family:Verdana; font-size:11px;"><br/>
User: <input type=text name=nick value="<?PHP echo $id; ?>" style="margin-top:3px;">
</form><br/><br/>
l2.php

Code: Select all

<?PHP

include("log.php");

echo "<a name='bottom'></a></span></body></html>";

?>
You know what's in log.php... (the chat)

send.php

Code: Select all

<?php

$nick = $_POST['nick'];
$text = $_POST['send'];

$nick = htmlentities($nick);
$text = htmlentities($text);

$text = stripslashes($text);

if(filesize('log.php') >= 16384)
{
$open = fopen('log.php', 'w');
$wri = "<span style=\"font-family:Verdana; font-size:11px;\">
<meta HTTP-EQUIV=refresh content=\"1;URL=log.php\">

";
fwrite($open, $wri);
fclose($open);
}

$open = fopen('log.php', 'a');

$wri = "<$nick> $text<br/>" .chr(10);
fwrite($open, $wri);

fclose($open);

header("Location: index.php?nick=$nick");

?>

hmm

Posted: 19 Jul 2006, 12:06
by maboroshi
Hey is it possible in PHP when you open a file it goes directly to the last line

So instead of using an include statement for log.php maybe use the fopen command to open the file at the last line

I don't know just an idea

Cheers

Maboroshi

Correct me if im wrong about the way your code is working :)

Hey

Posted: 19 Jul 2006, 14:54
by maboroshi
Hey does this work for you

it seems to work for me

http://www.techshinobi.de/test/index.php

---l2.php--

Code: Select all

<?PHP

$fp = fopen("log.php", "r");

if (!$fp) {
	echo "failed opening file";
	exit;
	}
	
while (!feof($fp)) 
	{
		$chat = fgets($fp, 100);
		echo $chat;
	}

echo "<a name='bottom'></a></span></body></html>";

fclose($fp);

?>


well

Posted: 19 Jul 2006, 15:07
by maboroshi
well it works somewhat not to sure what would be required for the names and things will let you figure that out

:)

Posted: 19 Jul 2006, 16:06
by Gogeta70
Well, the problem maboroshi is that it needs to constantly update so it can see what other people are typing in. It also seems that it overwrites the last thing the person said.

hmm

Posted: 24 Jul 2006, 13:33
by maboroshi
hmm I see I didn't fix it

The only way I can see doing it is maybe using Flash

I did a bit of research trying to find a solution to that but to be honest that seems to me like a bug in the browser

I did come across this don't know if it can help but it seems it might

http://www-128.ibm.com/developerworks/w ... index.html

Cheers

Maboroshi

Posted: 25 Jul 2006, 07:58
by Nerdz
Is there any "Thread" in php just like in c++? if so, the problem is solve..

Posted: 25 Jul 2006, 13:41
by Gogeta70
I'm not sure what you mean, nerdzoncrack.

Posted: 26 Jul 2006, 08:10
by Nerdz
nvm i misunderstood the problem :cry:

Posted: 18 Aug 2006, 09:22
by indianjones
bhai log,
can anyone help me in
installing a new hack tool in my forum
[url removed]
i need to install a hide option in that
can any one help...........

Posted: 18 Aug 2006, 12:29
by Gogeta70
Indian Jones, don't post the same thing in multiple topics, especially after just making a topic about it.

Posted: 18 Aug 2006, 12:44
by Gogeta70
Okay guys, i fixed the jumping scrollbar part mainly, but it does jump to the top occasionally. There's also another way to fix this, and that's to read the log file from the bottom up. But that'd be kinda weird, so what do you guys think?