I made a sort of 'chat room'

Questions about programming languages and debugging
Post Reply
User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

I made a sort of 'chat room'

Post 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!
¯\_(ツ)_/¯ It works on my machine...

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11549
Joined: 06 Apr 2005, 16:00
15
Location: The zone.
Contact:

Post 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... :)
Last edited by bad_brain on 19 Jul 2006, 04:53, edited 1 time in total.

User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

Post 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");

?>
¯\_(ツ)_/¯ It works on my machine...

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1607
Joined: 28 Aug 2005, 16:00
15

hmm

Post 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 :)

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1607
Joined: 28 Aug 2005, 16:00
15

Hey

Post 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);

?>


User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1607
Joined: 28 Aug 2005, 16:00
15

well

Post by maboroshi »

well it works somewhat not to sure what would be required for the names and things will let you figure that out

:)

User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

Post 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.
¯\_(ツ)_/¯ It works on my machine...

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1607
Joined: 28 Aug 2005, 16:00
15

hmm

Post 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

User avatar
Nerdz
The Architect
The Architect
Posts: 1127
Joined: 15 Jun 2005, 16:00
15
Location: #db_error in: select usr.location from sucko_member where usr.id=63;
Contact:

Post by Nerdz »

Is there any "Thread" in php just like in c++? if so, the problem is solve..
Give a man a fish, you feed him for one day.
Learn a man to fish, you feed him for life.

User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

Post by Gogeta70 »

I'm not sure what you mean, nerdzoncrack.
¯\_(ツ)_/¯ It works on my machine...

User avatar
Nerdz
The Architect
The Architect
Posts: 1127
Joined: 15 Jun 2005, 16:00
15
Location: #db_error in: select usr.location from sucko_member where usr.id=63;
Contact:

Post by Nerdz »

nvm i misunderstood the problem :cry:
Give a man a fish, you feed him for one day.
Learn a man to fish, you feed him for life.

User avatar
indianjones
Newbie
Newbie
Posts: 2
Joined: 17 Aug 2006, 16:00
14

Post 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...........

User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

Post by Gogeta70 »

Indian Jones, don't post the same thing in multiple topics, especially after just making a topic about it.
¯\_(ツ)_/¯ It works on my machine...

User avatar
Gogeta70
^_^
^_^
Posts: 3251
Joined: 25 Jun 2005, 16:00
15

Post 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?
¯\_(ツ)_/¯ It works on my machine...

Post Reply