I made a sort of 'chat room'
I made a sort of 'chat room'
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!
http://beta:tester@fatalh.sytes.net/testing/chat
Next up: Web based IRC chat!
¯\_(ツ)_/¯ It works on my machine...
- bad_brain
- Site Owner
- Posts: 11638
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
w00t! well done buddy....
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...
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...
Last edited by bad_brain on 19 Jul 2006, 04:53, edited 1 time in total.
Yeah, i can't figure out a better way to keep the box at the bottom... taking ideas...
Index.php
l2.php
You know what's in log.php... (the chat)
send.php
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/>
Code: Select all
<?PHP
include("log.php");
echo "<a name='bottom'></a></span></body></html>";
?>
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");
?>
¯\_(ツ)_/¯ It works on my machine...
hmm
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
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
Hey does this work for you
it seems to work for me
http://www.techshinobi.de/test/index.php
---l2.php--
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);
?>
hmm
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
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
- indianjones
- Newbie
- Posts: 2
- Joined: 17 Aug 2006, 16:00
- 18