PHP Chat
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
PHP Chat
http://www.404-design.net/chat/chat.php
IFrame refreshes every 2 seconds.
Can you guys give me some ideas on how to improve it? My friend was right, constant refreshing is annoying, but it's the only way I've thought of to do it if theres a lot of ppl in the room..
IFrame refreshes every 2 seconds.
Can you guys give me some ideas on how to improve it? My friend was right, constant refreshing is annoying, but it's the only way I've thought of to do it if theres a lot of ppl in the room..
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Incase anyone wanted to know how I did it, to give me some ideas on how to improve the design or whatever.. go ahead! 
chat.php
body.php
bottom.php
chat.php
Code: Select all
<?php
session_start();
if($_POST['mode']=="signin"){
$_SESSION['username'] = $_POST['username'];
}
echo <<<EOM
<html>
<body>
<div align="center">
EOM;
if(isset($_SESSION['username'])){
echo <<<EOT
<iframe src="body.php" scrolling="auto" width="500" height="400" marginheight="0" marginwidth="0" vspace="0" hspace="0" name="bodyframe" frameborder="1"></iframe><br />
<iframe src="bottom.php" scrolling="no" width="500" height="30" marginheight="0" marginwidth="0" vspace="0" hspace="0" name="bottomframe" frameborder="1"></iframe><br />
EOT;
}
else {
echo <<<EOT
Enter a username to use for chatting:<br />
<form action="chat.php" method="post">
<input type="text" name="username"><br />
<input type="hidden" name="mode" value="signin">
<input type="submit" value="Start Chatting!">
</form>
EOT;
}
echo "<br /><br />";
include("counter.php");
$myvar1 = getcount("uniq");
echo "Unique Visitors: " . $myvar1 . "<br />";
echo <<<EOZ
</div>
</body>
</html>
EOZ;
?>Code: Select all
<?php
echo <<<EOT
<html>
<body>
<script language="javascript">
setTimeout("window.location.reload()", 2000);
</script>
EOT;
include ("chatcontent.txt");
echo "</body>\n</html>";
?>Code: Select all
<?php
session_start();
if($_POST['submitted']==1){
$username = $_SESSION['username'];
$intext = $_POST['intext'];
$intext = format($intext);
$chatfile = fopen("chatcontent.txt", "a");
fwrite($chatfile, "<b>" . $username . "</b>: $intext<br>\n");
fclose($chatfile);
}
echo <<<EOT
<form action="bottom.php" method="post"><input type="hidden" name="submitted" value="1"><input type="text" size="60" name="intext"> <input type="submit" name="submit" value="Send!"></form>
EOT;
function format($input){
$input = stripcslashes($input);
$input = str_replace("<script", " ", "$input");
$input = str_replace("<iframe", " ", "$input");
$input = str_replace("<div", " ", "$input");
$input = str_replace("<span", " ", "$input");
$input = str_replace("<hr", " ", "$input");
}
?>
Last edited by d3ad1ysp0rk on Fri Apr 21, 2006 1:04 pm, edited 1 time in total.
Hello everyone, I have (what I think) is a pretty valid way to refresh a chat, but I need help with the code to get it working, i think it is possible using WHILE and FOR loops, I dont know, i need some help. I will give 50mb free hosting to whoever helps me out... I just REALLY need this done See my post for more info
viewtopic.php?t=18560&highlight=
viewtopic.php?t=18560&highlight=
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
have a look at this example. Dunno how it works
http://voc.onio.de/voc.php
Source here
http://vochat.com/
Mark
http://voc.onio.de/voc.php
Source here
http://vochat.com/
Mark