EDIT: I've had a few people try to chat with FF and it's failed. I have not thoroughly tested with FF but have had mixed experiences with it (mostly good). But it's apparent there are some that are bad which are causing it to not work at all. I know this isn't what you want to hear, but for demonstration purposes, might be better to try hitting it with IE

I'll let all of you geniouses work out the FF bugs
////////////////////////
I didn't want to post this just yet because it still has some bugs (especially with firefox) but after sooo many people requesting information about chat applications, I thought this could be a good resource for people looking to create their own with somethign other than java/flash and the like.
I do ask that if you modify it in any way, that you please provide me with the changes so that I can incorporate them into my version (assuming I like them

it uses subqueries so 4.1 is required on the db end.
i have it set up here and if you click that link and join the chat, it will email me so I can give you a short demonstration.
I made this quite some time ago and havent' had the time/desire (more desire than time) to fix the small issues that have come up. It's a good start though and I'll bet if you put a little work and effort into it, you could make it super spicy...but remmeber to keep me posted on the spice.
Code: Select all
-- phpMyAdmin SQL Dump
-- version 2.6.1-rc2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 13, 2005 at 07:42 PM
-- Server version: 4.1.10
-- PHP Version: 5.0.3
--
-- Database: `chat`
--
-- --------------------------------------------------------
--
-- Table structure for table `chatcli`
--
DROP TABLE IF EXISTS `chatcli`;
CREATE TABLE IF NOT EXISTS `chatcli` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`cliid` mediumint(9) default NULL,
`time` datetime default NULL,
`chattext` longtext,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=382 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatread`
--
DROP TABLE IF EXISTS `chatread`;
CREATE TABLE IF NOT EXISTS `chatread` (
`id` mediumint(9) NOT NULL auto_increment,
`chatid` mediumint(9) default NULL,
`cliid` mediumint(9) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `cliid` (`cliid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=800 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatusers`
--
DROP TABLE IF EXISTS `chatusers`;
CREATE TABLE IF NOT EXISTS `chatusers` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`time` datetime default NULL,
`lasttime` datetime default NULL,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `room` (`room`),
KEY `lasttime` (`lasttime`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ;
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
if(isset($_GETї'invite'])){
mysql_query("e;insert into 21_chatreq
(
req,
userid,
reqname,
reqtime
)
values
(
"e;.$_GETї'rm']."e;,
"e;.$_GETї'invite']."e;,
'"e;.mysql_escape_string($_GETї'name'])."e;',
now()
)
"e;)
or die(mysql_error());
}
$rm = (isset($_GETї'rm']) ? $_GETї'rm'] : "e;General Chat"e;);
$cliid = $_SERVERї"e;REMOTE_ADDR"e;];
$cliid = substr(md5($cliid), rand(0, 23), ;
$chatWho = (isset($_GETї'name']) ? $_GETї'name'] : "e;Guest"e;.$cliid);
$inssql = "e;insert into 21_chatusers
(
name,
time,
lasttime,
room
)
values
(
'"e;.mysql_escape_string($chatWho)."e;',
now(),
now(),
'"e;.mysql_escape_string($rm)."e;'
)"e;;
mysql_query($inssql)
or die(mysql_error());
$cliid = mysql_insert_id();
?>
<!DOCTYPE HTML PUBLIC "e;-//W3C//DTD HTML 4.01 Transitional//EN"e;>
<html>
<head>
<title>Chat</title>
<style>
input
{
background-color:#6F747D; border:1px #000000 solid; color:#ffffff; font-family:tahoma; font-size:8.5pt; padding-left:2px;
}
textarea.sid
{
width:400px; height:100px; background-color:#EBEADB; border:1px #000000 solid; color:#000000; font-family:tahoma; font-size:9.0pt; padding-left:2px;
}
.dsty
{
width:400px; height:400px; background-color:#EDEDE2; border:1px #000000 solid; color:#353519; overflow:auto; font-family:tahoma; font-size:9.0pt; padding-left:2px; padding-top:2px;
}
td.le
{
border-left:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid;
}
td.rt
{
border-right:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid; padding-top:2px;
}
td.rb
{
border-left:1px #2E3E3F solid;
}
.parts
{
width:190px; height:270px; background-color:#68768E; border:1px #000000 solid; color:#ffffff; overflow:auto; font-family:tahoma; font-size:8.5pt; padding-left:2px; padding-top:2px; text-align:center;
}
</style>
<script>
function addIt(what,who,color,to){
var clr = color;
var temp = document.createElement("e;div"e;);
temp.style.color = clr;
if(!document.all){
temp.innerHTML = who + "e;: "e; + what;
}else{
temp.innerText = who + "e;: "e; + what;
}
if (temp.innerHTML); else
temp.appendChild(document.createTextNode(what));
if (temp.innerHTML){
var html = temp.innerHTML;
html = html.replace(/(\r?\n)/g, "e;<br>$1"e;);
html = html.replace(/(їa-zA-Z_0-9.-]+\@їa-zA-Z_0-9.-]+\.\w+)/g, "e;<a href=\"e;mailto:$1\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\w+ї\\://]+\\w+\\.\\w+\\.\\w+ї/\\w+]*ї.\\w+]*)"e;, "e;g"e;), "e;<a href=\"e;$1\"e; target=\"e;_blank\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\\\')"e;, "e;g"e;),"e;'"e;);
temp.innerHTML = html;
}
if(to){
sendIt();
setTimeout("e;clearIt()"e;,0);
}
document.getElementById("e;rvie"e;).appendChild(temp);
temp.scrollIntoView();
document.MyForm.rtex.focus();
}
function clearIt(){
document.MyForm.rtex.value = "e;"e;;
}
function checkEnt(evt){
if(evt.keyCode == 13 && !evt.shiftKey){
addIt(document.MyForm.rtex.value,'TD','#222755','from');
evt.returnValue = false;
if (evt.preventDefault)
evt.preventDefault();
}
}
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
}else{
req = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
if (window.XMLHttpRequest){
reqs = new XMLHttpRequest();
}else{
reqs = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
// SMPDawg - Added another object to send messages and (hopefully) prevent the chat
// application from trying to send/receive from one XMLHTTP object.
if (window.XMLHttpRequest){
reqsend = new XMLHttpRequest();
}else{
reqsend = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
whoid = 0;
function retrieveIt(simid) {
samid = (!simid ? 0 : simid);
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
req.open("e;GET"e;, "e;getchat.php?Timestr="e;+escape(formatted)+"e;&nm=1&cliid=<?=$cliid;?>&room=<?=$rm;?>&rid="e;+samid, true);
req.onreadystatechange = function(){
if (req.readyState == 4 && req.status == 200) {
if(req.responseText.indexOf("e;**"e;) != -1){
whot = req.responseText.split("e;**"e;);
whoid = whotї0];
whoto = whotї1];
whota = whotї2];
addIt(whota,whoto,"e;#353519"e;);
}else{
whoid = 0;
}
}
}
req.send(null);
setTimeout("e;retrieveIt(whoid)"e;,1000);
}
// SMPDawg - Changed reqs to reqsend per the previous change.
function sendIt() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqsend.onreadystatechange = function(){
if (reqsend.readyState == 4 && reqsend.status == 200) {
}
};
reqsend.open("e;POST"e;, "e;getchat.php"e;, true);
var stuff = "e;rtex="e; + escape(document.MyForm.rtex.value) + "e;&name="e; + escape(document.MyForm.name.value) + "e;&cliid="e; + document.MyForm.cliid.value + "e;&room="e; + escape(document.MyForm.room.value);
reqsend.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
reqsend.setRequestHeader("e;Content-Length"e;,stuff.length);
reqsend.send(stuff);
}
clist = 0;
function whosIn() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqs.open("e;GET"e;, "e;getparts.php?Timestr="e;+escape(formatted)+"e;&cliid=<?=$cliid;?>&room=<?=$rm;?>&clist="e; + clist, true);
reqs.onreadystatechange = function(){
if (reqs.readyState == 4 && reqs.status == 200) {
if(reqs.responseText.indexOf("e;**"e;) != -1){
whot = reqs.responseText.split("e;**"e;);
document.getElementById('pts').innerHTML = "e;<u>Chat Room</u><br>"e; + whotї1];
clist = whotї0];
}
}
}
reqs.send(null);
setTimeout("e;whosIn()"e;,1000);
}
function addPart(idd,namer){
document.getElementById('pts').innerHTML += namer + "e;<br>"e;;
}
</script>
</head>
<body onLoad="e;retrieveIt(), whosIn(), document.MyForm.rtex.focus()"e; topmargin="e;0"e; marginheight="e;0"e; leftmargin="e;0"e; marginwidth="e;0"e;>
<form name="e;MyForm"e; method="e;post"e;>
<table width="e;600"e; cellspacing="e;0"e; cellpadding="e;0"e;>
<tr>
<td rowspan="e;2"e; width="e;400"e; class="e;le"e;>
<table width="e;100%"e; cellpadding="e;2"e; cellspacing="e;0"e;>
<tr>
<td>
<div id="rvie" class="dsty"></div>
<textarea name="e;rtex"e; class="e;sid"e; onKeyDown="e;checkEnt(event)"e; ></textarea><br>
<input type="e;button"e; value="e;Send Message"e; onClick="e;addIt(document.MyForm.rtex.value,'<?=$chatWho;?>','#222755','from')"e; style="e;width:400px; align:center"e;>
<input type="e;hidden"e; name="e;name"e; value="e;<?=$chatWho;?>"e;>
<input type="e;hidden"e; name="e;cliid" value="<?=$cliid;?>">
<input type="hidden" name="e;room"e; value="e;<?=$rm;?>"e;>
</td>
</tr>
</table>
</td>
<td class="e;rt"e; align="e;center"e; valign="e;top"e; height="e;270"e;>
<div id="e;pts"e; class="e;parts"e;>
</div></td>
</tr>
<tr>
<td class="e;rb"e; height="e;230"e;>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// check to see if this is a request for chat messages...burrito
if(isset($_GETї'nm'])){
// update user table to show they are still logged in...burrito
mysql_query("e;update 21_chatusers set lasttime = now() where id = "e;.$_GETї'cliid'])
or die(mysql_error());
// check to see if need to insert a read message row...burrito
if(isset($_GETї'rid']) && $_GETї'rid'] != 0){
$sql = "e;insert into 21_chatread (chatid,cliid) values ("e;.$_GETї'rid']."e;,"e;.$_GETї'cliid']."e;)"e;;
mysql_query($sql)
or die(mysql_error());
} // end if for need to insert a read message...burrito
$graqu = "e;select * from 21_chatcli WHERE id NOT IN (SELECT chatid FROM 21_chatread where cliid = "e;.$_GETї'cliid']."e;) and cliid <> "e;.$_GETї'cliid']."e; and time > (select time from 21_chatusers where id = ".$_GET['cliid'].") and room = '".mysql_escape_string($_GETї'room'])."e;'"e;;
$getmsgs = mysql_query($graqu)
or die(mysql_error());;
if($gtmsgs = mysql_fetch_assoc($getmsgs)){
// send back the chat messages that have not been read...burrito
echo $gtmsgsї'id']."e;**"e;.$gtmsgsї'name']."e;**"e;.$gtmsgsї'chattext'];
}
}else{ // not a message request, so insert new message...burrito
mysql_query("e;insert into 21_chatcli
(
name,
cliid,
time,
chattext,
room
)
values
(
'"e;.$_POSTї'name']."e;',
"e;.$_POSTї'cliid']."e;,
now(),
'"e;.mysql_escape_string($_POSTї'rtex'])."e;',
'"e;.mysql_escape_string($_POSTї'room'])."e;'
)")
or die("**".mysql_error());;
} // end if for message request or new message...burrito
?>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// grab participants in current room...burrito
$partsqu = "e;select * from 21_chatusers where room = '"e;.mysql_escape_string($_GETї'room'])."e;' and lasttime > '"e;.date("e;Y-m-d H:i:s"e;, strtotime("e;-10 seconds"e;))."e;'"e;;
$getparts = mysql_query($partsqu)
or die(mysql_error());
$thisamt = mysql_num_rows($getparts);
// check to see if this is initial load to return all participants...burrito
if($thisamt !== $_GETї'clist']){
$stky = $thisamt."e;**"e;;
while($gtparts = mysql_fetch_assoc($getparts)){ // return one row at a time for new users joining...burrito
$stky .= $gtpartsї'name']."e;<br>"e;;
}// end while for result set...burrito
echo $stky;
} // end if for need to send down new participant info...burrito
?>
have fun with it!ople try to chat with FF and it's failed. I have not thoroughly tested with FF but have had mixed experiences with it (mostly good). But it's apparent there are some that are bad which are causing it to not work at all. I know this isn't what you want to hear, but for demonstration purposes, might be better to try hitting it with IE

I'll let all of you geniouses work out the FF bugs
////////////////////////
I didn't want to post this just yet because it still has some bugs (especially with firefox) but after sooo many people requesting information about chat applications, I thought this could be a good resource for people looking to create their own with somethign other than java/flash and the like.
I do ask that if you modify it in any way, that you please provide me with the changes so that I can incorporate them into my version (assuming I like them

it uses subqueries so 4.1 is required on the db end.
i have it set up here and if you click that link and join the chat, it will email me so I can give you a short demonstration.
I made this quite some time ago and havent' had the time/desire (more desire than time) to fix the small issues that have come up. It's a good start though and I'll bet if you put a little work and effort into it, you could make it super spicy...but remmeber to keep me posted on the spice.
Code: Select all
-- phpMyAdmin SQL Dump
-- version 2.6.1-rc2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 13, 2005 at 07:42 PM
-- Server version: 4.1.10
-- PHP Version: 5.0.3
--
-- Database: `chat`
--
-- --------------------------------------------------------
--
-- Table structure for table `chatcli`
--
DROP TABLE IF EXISTS `chatcli`;
CREATE TABLE IF NOT EXISTS `chatcli` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`cliid` mediumint(9) default NULL,
`time` datetime default NULL,
`chattext` longtext,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=382 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatread`
--
DROP TABLE IF EXISTS `chatread`;
CREATE TABLE IF NOT EXISTS `chatread` (
`id` mediumint(9) NOT NULL auto_increment,
`chatid` mediumint(9) default NULL,
`cliid` mediumint(9) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `cliid` (`cliid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=800 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatusers`
--
DROP TABLE IF EXISTS `chatusers`;
CREATE TABLE IF NOT EXISTS `chatusers` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`time` datetime default NULL,
`lasttime` datetime default NULL,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `room` (`room`),
KEY `lasttime` (`lasttime`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ;
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
if(isset($_GETї'invite'])){
mysql_query("e;insert into 21_chatreq
(
req,
userid,
reqname,
reqtime
)
values
(
"e;.$_GETї'rm']."e;,
"e;.$_GETї'invite']."e;,
'"e;.mysql_escape_string($_GETї'name'])."e;',
now()
)
"e;)
or die(mysql_error());
}
$rm = (isset($_GETї'rm']) ? $_GETї'rm'] : "e;General Chat"e;);
$cliid = $_SERVERї"e;REMOTE_ADDR"e;];
$cliid = substr(md5($cliid), rand(0, 23), ;
$chatWho = (isset($_GETї'name']) ? $_GETї'name'] : "e;Guest"e;.$cliid);
$inssql = "e;insert into 21_chatusers
(
name,
time,
lasttime,
room
)
values
(
'"e;.mysql_escape_string($chatWho)."e;',
now(),
now(),
'"e;.mysql_escape_string($rm)."e;'
)"e;;
mysql_query($inssql)
or die(mysql_error());
$cliid = mysql_insert_id();
?>
<!DOCTYPE HTML PUBLIC "e;-//W3C//DTD HTML 4.01 Transitional//EN"e;>
<html>
<head>
<title>Chat</title>
<style>
input
{
background-color:#6F747D; border:1px #000000 solid; color:#ffffff; font-family:tahoma; font-size:8.5pt; padding-left:2px;
}
textarea.sid
{
width:400px; height:100px; background-color:#EBEADB; border:1px #000000 solid; color:#000000; font-family:tahoma; font-size:9.0pt; padding-left:2px;
}
.dsty
{
width:400px; height:400px; background-color:#EDEDE2; border:1px #000000 solid; color:#353519; overflow:auto; font-family:tahoma; font-size:9.0pt; padding-left:2px; padding-top:2px;
}
td.le
{
border-left:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid;
}
td.rt
{
border-right:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid; padding-top:2px;
}
td.rb
{
border-left:1px #2E3E3F solid;
}
.parts
{
width:190px; height:270px; background-color:#68768E; border:1px #000000 solid; color:#ffffff; overflow:auto; font-family:tahoma; font-size:8.5pt; padding-left:2px; padding-top:2px; text-align:center;
}
</style>
<script>
function addIt(what,who,color,to){
var clr = color;
var temp = document.createElement("e;div"e;);
temp.style.color = clr;
if(!document.all){
temp.innerHTML = who + "e;: "e; + what;
}else{
temp.innerText = who + "e;: "e; + what;
}
if (temp.innerHTML); else
temp.appendChild(document.createTextNode(what));
if (temp.innerHTML){
var html = temp.innerHTML;
html = html.replace(/(\r?\n)/g, "e;<br>$1"e;);
html = html.replace(/(їa-zA-Z_0-9.-]+\@їa-zA-Z_0-9.-]+\.\w+)/g, "e;<a href=\"e;mailto:$1\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\w+ї\\://]+\\w+\\.\\w+\\.\\w+ї/\\w+]*ї.\\w+]*)"e;, "e;g"e;), "e;<a href=\"e;$1\"e; target=\"e;_blank\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\\\')"e;, "e;g"e;),"e;'"e;);
temp.innerHTML = html;
}
if(to){
sendIt();
setTimeout("e;clearIt()"e;,0);
}
document.getElementById("e;rvie"e;).appendChild(temp);
temp.scrollIntoView();
document.MyForm.rtex.focus();
}
function clearIt(){
document.MyForm.rtex.value = "e;"e;;
}
function checkEnt(evt){
if(evt.keyCode == 13 && !evt.shiftKey){
addIt(document.MyForm.rtex.value,'TD','#222755','from');
evt.returnValue = false;
if (evt.preventDefault)
evt.preventDefault();
}
}
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
}else{
req = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
if (window.XMLHttpRequest){
reqs = new XMLHttpRequest();
}else{
reqs = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
// SMPDawg - Added another object to send messages and (hopefully) prevent the chat
// application from trying to send/receive from one XMLHTTP object.
if (window.XMLHttpRequest){
reqsend = new XMLHttpRequest();
}else{
reqsend = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
whoid = 0;
function retrieveIt(simid) {
samid = (!simid ? 0 : simid);
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
req.open("e;GET"e;, "e;getchat.php?Timestr="e;+escape(formatted)+"e;&nm=1&cliid=<?=$cliid;?>&room=<?=$rm;?>&rid="e;+samid, true);
req.onreadystatechange = function(){
if (req.readyState == 4 && req.status == 200) {
if(req.responseText.indexOf("e;**"e;) != -1){
whot = req.responseText.split("e;**"e;);
whoid = whotї0];
whoto = whotї1];
whota = whotї2];
addIt(whota,whoto,"e;#353519"e;);
}else{
whoid = 0;
}
}
}
req.send(null);
setTimeout("e;retrieveIt(whoid)"e;,1000);
}
// SMPDawg - Changed reqs to reqsend per the previous change.
function sendIt() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqsend.onreadystatechange = function(){
if (reqsend.readyState == 4 && reqsend.status == 200) {
}
};
reqsend.open("e;POST"e;, "e;getchat.php"e;, true);
var stuff = "e;rtex="e; + escape(document.MyForm.rtex.value) + "e;&name="e; + escape(document.MyForm.name.value) + "e;&cliid="e; + document.MyForm.cliid.value + "e;&room="e; + escape(document.MyForm.room.value);
reqsend.setRequestHeader("e;Content-Type"e;,"e;application/x-www-form-urlencoded"e;);
reqsend.setRequestHeader("e;Content-Length"e;,stuff.length);
reqsend.send(stuff);
}
clist = 0;
function whosIn() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqs.open("e;GET"e;, "e;getparts.php?Timestr="e;+escape(formatted)+"e;&cliid=<?=$cliid;?>&room=<?=$rm;?>&clist="e; + clist, true);
reqs.onreadystatechange = function(){
if (reqs.readyState == 4 && reqs.status == 200) {
if(reqs.responseText.indexOf("e;**"e;) != -1){
whot = reqs.responseText.split("e;**"e;);
document.getElementById('pts').innerHTML = "e;<u>Chat Room</u><br>"e; + whotї1];
clist = whotї0];
}
}
}
reqs.send(null);
setTimeout("e;whosIn()"e;,1000);
}
function addPart(idd,namer){
document.getElementById('pts').innerHTML += namer + "e;<br>"e;;
}
</script>
</head>
<body onLoad="e;retrieveIt(), whosIn(), document.MyForm.rtex.focus()"e; topmargin="e;0"e; marginheight="e;0"e; leftmargin="e;0"e; marginwidth="e;0"e;>
<form name="e;MyForm"e; method="e;post"e;>
<table width="e;600"e; cellspacing="e;0"e; cellpadding="e;0"e;>
<tr>
<td rowspan="e;2"e; width="e;400"e; class="e;le"e;>
<table width="e;100%"e; cellpadding="e;2"e; cellspacing="e;0"e;>
<tr>
<td>
<div id="e;rvie"e; class="e;dsty"e;></div>
<textarea name="e;rtex"e; class="e;sid"e; onKeyDown="e;checkEnt(event)"e; ></textarea><br>
<input type="e;button"e; value="e;Send Message"e; onClick="e;addIt(document.MyForm.rtex.value,'<?=$chatWho;?>','#222755','from')"e; style="e;width:400px; align:center"e;>
<input type="e;hidden"e; name="e;name"e; value="e;<?=$chatWho;?>"e;>
<input type="e;hidden"e; name="e;cliid"e; value="e;<?=$cliid;?>"e;>
<input type="e;hidden"e; name="e;room"e; value="e;<?=$rm;?>"e;>
</td>
</tr>
</table>
</td>
<td class="e;rt"e; align="e;center"e; valign="e;top"e; height="e;270"e;>
<div id="e;pts"e; class="e;parts"e;>
</div></td>
</tr>
<tr>
<td class="e;rb"e; height="e;230"e;>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// check to see if this is a request for chat messages...burrito
if(isset($_GETї'nm'])){
// update user table to show they are still logged in...burrito
mysql_query("e;update 21_chatusers set lasttime = now() where id = "e;.$_GETї'cliid'])
or die(mysql_error());
// check to see if need to insert a read message row...burrito
if(isset($_GETї'rid']) && $_GETї'rid'] != 0){
$sql = "e;insert into 21_chatread (chatid,cliid) values ("e;.$_GETї'rid']."e;,"e;.$_GETї'cliid']."e;)"e;;
mysql_query($sql)
or die(mysql_error());
} // end if for need to insert a read message...burrito
$graqu = "e;select * from 21_chatcli WHERE id NOT IN (SELECT chatid FROM 21_chatread where cliid = "e;.$_GETї'cliid']."e;) and cliid <> "e;.$_GETї'cliid']."e; and time > (select time from 21_chatusers where id = "e;.$_GETї'cliid']."e;) and room = '"e;.mysql_escape_string($_GETї'room'])."e;'"e;;
$getmsgs = mysql_query($graqu)
or die(mysql_error());;
if($gtmsgs = mysql_fetch_assoc($getmsgs)){
// send back the chat messages that have not been read...burrito
echo $gtmsgsї'id']."e;**"e;.$gtmsgsї'name']."e;**"e;.$gtmsgsї'chattext'];
}
}else{ // not a message request, so insert new message...burrito
mysql_query("e;insert into 21_chatcli
(
name,
cliid,
time,
chattext,
room
)
values
(
'"e;.$_POSTї'name']."e;',
"e;.$_POSTї'cliid']."e;,
now(),
'"e;.mysql_escape_string($_POSTї'rtex'])."e;',
'"e;.mysql_escape_string($_POSTї'room'])."e;'
)"e;)
or die("e;**"e;.mysql_error());;
} // end if for message request or new message...burrito
?>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// grab participants in current room...burrito
$partsqu = "e;select * from 21_chatusers where room = '"e;.mysql_escape_string($_GETї'room'])."e;' and lasttime > '"e;.date("e;Y-m-d H:i:s"e;, strtotime("e;-10 seconds"e;))."e;'"e;;
$getparts = mysql_query($partsqu)
or die(mysql_error());
$thisamt = mysql_num_rows($getparts);
// check to see if this is initial load to return all participants...burrito
if($thisamt !== $_GETї'clist']){
$stky = $thisamt."e;**"e;;
while($gtparts = mysql_fetch_assoc($getparts)){ // return one row at a time for new users joining...burrito
$stky .= $gtpartsї'name']."e;<br>"e;;
}// end while for result set...burrito
echo $stky;
} // end if for need to send down new participant info...burrito
?>

I'll let all of you geniouses work out the FF bugs
////////////////////////
I didn't want to post this just yet because it still has some bugs (especially with firefox) but after sooo many people requesting information about chat applications, I thought this could be a good resource for people looking to create their own with somethign other than java/flash and the like.
I do ask that if you modify it in any way, that you please provide me with the changes so that I can incorporate them into my version (assuming I like them

it uses subqueries so 4.1 is required on the db end.
i have it set up here and if you click that link and join the chat, it will email me so I can give you a short demonstration.
I made this quite some time ago and havent' had the time/desire (more desire than time) to fix the small issues that have come up. It's a good start though and I'll bet if you put a little work and effort into it, you could make it super spicy...but remmeber to keep me posted on the spice.
Code: Select all
-- phpMyAdmin SQL Dump
-- version 2.6.1-rc2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 13, 2005 at 07:42 PM
-- Server version: 4.1.10
-- PHP Version: 5.0.3
--
-- Database: `chat`
--
-- --------------------------------------------------------
--
-- Table structure for table `chatcli`
--
DROP TABLE IF EXISTS `chatcli`;
CREATE TABLE IF NOT EXISTS `chatcli` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`cliid` mediumint(9) default NULL,
`time` datetime default NULL,
`chattext` longtext,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=382 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatread`
--
DROP TABLE IF EXISTS `chatread`;
CREATE TABLE IF NOT EXISTS `chatread` (
`id` mediumint(9) NOT NULL auto_increment,
`chatid` mediumint(9) default NULL,
`cliid` mediumint(9) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `cliid` (`cliid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=800 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatusers`
--
DROP TABLE IF EXISTS `chatusers`;
CREATE TABLE IF NOT EXISTS `chatusers` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`time` datetime default NULL,
`lasttime` datetime default NULL,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `room` (`room`),
KEY `lasttime` (`lasttime`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ;
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
if(isset($_GETї'invite'])){
mysql_query("e;insert into 21_chatreq
(
req,
userid,
reqname,
reqtime
)
values
(
"e;.$_GETї'rm']."e;,
"e;.$_GETї'invite']."e;,
'"e;.mysql_escape_string($_GETї'name'])."e;',
now()
)
"e;)
or die(mysql_error());
}
$rm = (isset($_GETї'rm']) ? $_GETї'rm'] : "e;General Chat"e;);
$cliid = $_SERVERї"e;REMOTE_ADDR"e;];
$cliid = substr(md5($cliid), rand(0, 23), ;
$chatWho = (isset($_GETї'name']) ? $_GETї'name'] : "e;Guest"e;.$cliid);
$inssql = "e;insert into 21_chatusers
(
name,
time,
lasttime,
room
)
values
(
'"e;.mysql_escape_string($chatWho)."e;',
now(),
now(),
'"e;.mysql_escape_string($rm)."e;'
)"e;;
mysql_query($inssql)
or die(mysql_error());
$cliid = mysql_insert_id();
?>
<!DOCTYPE HTML PUBLIC "e;-//W3C//DTD HTML 4.01 Transitional//EN"e;>
<html>
<head>
<title>Chat</title>
<style>
input
{
background-color:#6F747D; border:1px #000000 solid; color:#ffffff; font-family:tahoma; font-size:8.5pt; padding-left:2px;
}
textarea.sid
{
width:400px; height:100px; background-color:#EBEADB; border:1px #000000 solid; color:#000000; font-family:tahoma; font-size:9.0pt; padding-left:2px;
}
.dsty
{
width:400px; height:400px; background-color:#EDEDE2; border:1px #000000 solid; color:#353519; overflow:auto; font-family:tahoma; font-size:9.0pt; padding-left:2px; padding-top:2px;
}
td.le
{
border-left:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid;
}
td.rt
{
border-right:1px #2E3E3F solid; border-top:1px #2E3E3F solid; border-bottom:1px #2E3E3F solid; padding-top:2px;
}
td.rb
{
border-left:1px #2E3E3F solid;
}
.parts
{
width:190px; height:270px; background-color:#68768E; border:1px #000000 solid; color:#ffffff; overflow:auto; font-family:tahoma; font-size:8.5pt; padding-left:2px; padding-top:2px; text-align:center;
}
</style>
<script>
function addIt(what,who,color,to){
var clr = color;
var temp = document.createElement("e;div"e;);
temp.style.color = clr;
if(!document.all){
temp.innerHTML = who + "e;: "e; + what;
}else{
temp.innerText = who + "e;: "e; + what;
}
if (temp.innerHTML); else
temp.appendChild(document.createTextNode(what));
if (temp.innerHTML){
var html = temp.innerHTML;
html = html.replace(/(\r?\n)/g, "e;<br>$1"e;);
html = html.replace(/(їa-zA-Z_0-9.-]+\@їa-zA-Z_0-9.-]+\.\w+)/g, "e;<a href=\"e;mailto:$1\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\w+ї\\://]+\\w+\\.\\w+\\.\\w+ї/\\w+]*ї.\\w+]*)"e;, "e;g"e;), "e;<a href=\"e;$1\"e; target=\"e;_blank\"e;>$1</a>"e;);
html = html.replace(new RegExp("e;(\\\\')"e;, "e;g"e;),"e;'"e;);
temp.innerHTML = html;
}
if(to){
sendIt();
setTimeout("e;clearIt()"e;,0);
}
document.getElementById("e;rvie"e;).appendChild(temp);
temp.scrollIntoView();
document.MyForm.rtex.focus();
}
function clearIt(){
document.MyForm.rtex.value = "e;"e;;
}
function checkEnt(evt){
if(evt.keyCode == 13 && !evt.shiftKey){
addIt(document.MyForm.rtex.value,'TD','#222755','from');
evt.returnValue = false;
if (evt.preventDefault)
evt.preventDefault();
}
}
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
}else{
req = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
if (window.XMLHttpRequest){
reqs = new XMLHttpRequest();
}else{
reqs = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
// SMPDawg - Added another object to send messages and (hopefully) prevent the chat
// application from trying to send/receive from one XMLHTTP object.
if (window.XMLHttpRequest){
reqsend = new XMLHttpRequest();
}else{
reqsend = new ActiveXObject("e;Microsoft.XMLHTTP"e;);
}
whoid = 0;
function retrieveIt(simid) {
samid = (!simid ? 0 : simid);
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
req.open("e;GET"e;, "e;getchat.php?Timestr="e;+escape(formatted)+"e;&nm=1&cliid=<?=$cliid;?>&room=<?=$rm;?>&rid="e;+samid, true);
req.onreadystatechange = function(){
if (req.readyState == 4 && req.status == 200) {
if(req.responseText.indexOf("e;**"e;) != -1){
whot = req.responseText.split("e;**"e;);
whoid = whotї0];
whoto = whotї1];
whota = whotї2];
addIt(whota,whoto,"e;#353519"e;);
}else{
whoid = 0;
}
}
}
req.send(null);
setTimeout("e;retrieveIt(whoid)"e;,1000);
}
// SMPDawg - Changed reqs to reqsend per the previous change.
function sendIt() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqsend.onreadystatechange = function(){
if (reqsend.readyState == 4 && reqsend.status == 200) {
}
};
reqsend.open("e;POST"e;, "e;getchat.php"e;, true);
var stuff = "e;rtex="e; + escape(document.MyForm.rtex.value) + "e;&name="e; + escape(document.MyForm.name.value) + "e;&cliid="e; + document.MyForm.cliid.value + "e;&room="e; + escape(document.MyForm.room.value);
reqsend.setRequestHeader("e;Content-Type"e;,"e;application/x-www-form-urlencoded"e;);
reqsend.setRequestHeader("e;Content-Length"e;,stuff.length);
reqsend.send(stuff);
}
clist = 0;
function whosIn() {
datevar = new Date();
y = datevar.getFullYear();
m = datevar.getMonth() + 1;
d = datevar.getDate();
h = datevar.getHours();
i = datevar.getMinutes();
s = datevar.getSeconds();
formatted = y+"e;-"e;+m+"e;-"e;+d+"e; "e;+h+"e;:"e;+i+"e;:"e;+s;
reqs.open("e;GET"e;, "e;getparts.php?Timestr="e;+escape(formatted)+"e;&cliid=<?=$cliid;?>&room=<?=$rm;?>&clist="e; + clist, true);
reqs.onreadystatechange = function(){
if (reqs.readyState == 4 && reqs.status == 200) {
if(reqs.responseText.indexOf("e;**"e;) != -1){
whot = reqs.responseText.split("e;**"e;);
document.getElementById('pts').innerHTML = "e;<u>Chat Room</u><br>"e; + whotї1];
clist = whotї0];
}
}
}
reqs.send(null);
setTimeout("e;whosIn()"e;,1000);
}
function addPart(idd,namer){
document.getElementById('pts').innerHTML += namer + "e;<br>"e;;
}
</script>
</head>
<body onLoad="e;retrieveIt(), whosIn(), document.MyForm.rtex.focus()"e; topmargin="e;0"e; marginheight="e;0"e; leftmargin="e;0"e; marginwidth="e;0"e;>
<form name="e;MyForm"e; method="e;post"e;>
<table width="e;600"e; cellspacing="e;0"e; cellpadding="e;0"e;>
<tr>
<td rowspan="e;2"e; width="e;400"e; class="e;le"e;>
<table width="e;100%"e; cellpadding="e;2"e; cellspacing="e;0"e;>
<tr>
<td>
<div id="e;rvie"e; class="e;dsty"e;></div>
<textarea name="e;rtex"e; class="e;sid"e; onKeyDown="e;checkEnt(event)"e; ></textarea><br>
<input type="e;button"e; value="e;Send Message"e; onClick="e;addIt(document.MyForm.rtex.value,'<?=$chatWho;?>','#222755','from')"e; style="e;width:400px; align:center"e;>
<input type="e;hidden"e; name="e;name"e; value="e;<?=$chatWho;?>"e;>
<input type="e;hidden"e; name="e;cliid"e; value="e;<?=$cliid;?>"e;>
<input type="e;hidden"e; name="e;room"e; value="e;<?=$rm;?>"e;>
</td>
</tr>
</table>
</td>
<td class="e;rt"e; align="e;center"e; valign="e;top"e; height="e;270"e;>
<div id="e;pts"e; class="e;parts"e;>
</div></td>
</tr>
<tr>
<td class="e;rb"e; height="e;230"e;>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// check to see if this is a request for chat messages...burrito
if(isset($_GETї'nm'])){
// update user table to show they are still logged in...burrito
mysql_query("e;update 21_chatusers set lasttime = now() where id = "e;.$_GETї'cliid'])
or die(mysql_error());
// check to see if need to insert a read message row...burrito
if(isset($_GETї'rid']) && $_GETї'rid'] != 0){
$sql = "e;insert into 21_chatread (chatid,cliid) values ("e;.$_GETї'rid']."e;,"e;.$_GETї'cliid']."e;)"e;;
mysql_query($sql)
or die(mysql_error());
} // end if for need to insert a read message...burrito
$graqu = "e;select * from 21_chatcli WHERE id NOT IN (SELECT chatid FROM 21_chatread where cliid = "e;.$_GETї'cliid']."e;) and cliid <> "e;.$_GETї'cliid']."e; and time > (select time from 21_chatusers where id = "e;.$_GETї'cliid']."e;) and room = '"e;.mysql_escape_string($_GETї'room'])."e;'"e;;
$getmsgs = mysql_query($graqu)
or die(mysql_error());;
if($gtmsgs = mysql_fetch_assoc($getmsgs)){
// send back the chat messages that have not been read...burrito
echo $gtmsgsї'id']."e;**"e;.$gtmsgsї'name']."e;**"e;.$gtmsgsї'chattext'];
}
}else{ // not a message request, so insert new message...burrito
mysql_query("e;insert into 21_chatcli
(
name,
cliid,
time,
chattext,
room
)
values
(
'"e;.$_POSTї'name']."e;',
"e;.$_POSTї'cliid']."e;,
now(),
'"e;.mysql_escape_string($_POSTї'rtex'])."e;',
'"e;.mysql_escape_string($_POSTї'room'])."e;'
)"e;)
or die("e;**"e;.mysql_error());;
} // end if for message request or new message...burrito
?>
Code: Select all
<?
////////////////////////////////////////////////////////////
// BreakFast Chat v1.0
// Authors:
// Burrito(burrito@burritostand.com)
// SMPDawg
// Last Modified: 04/28/2005
// Created: 3/12/2005
// Please feel free to use/distribute/modify this code
// I only ask that if you make any improvements that you
// email me the updated code so I can incorporate it into
// my version burrito@burritostand.com. I also ask
// that you retain this copy © info at the top of every
// page of the application.
// enjoy!!
//copyright © 2005 Burrito (burrito AT burritostand DOT Com)
////////////////////////////////////////////////////////////
// refresh this page every time it's hit...burrito
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
header("e;Pragma: no-cache"e;);
// grab db connect info....burrito
require_once("e;../includes/dbInteract.php"e;);
tt_db_connect();
// grab participants in current room...burrito
$partsqu = "e;select * from 21_chatusers where room = '"e;.mysql_escape_string($_GETї'room'])."e;' and lasttime > '"e;.date("e;Y-m-d H:i:s"e;, strtotime("e;-10 seconds"e;))."e;'"e;;
$getparts = mysql_query($partsqu)
or die(mysql_error());
$thisamt = mysql_num_rows($getparts);
// check to see if this is initial load to return all participants...burrito
if($thisamt !== $_GETї'clist']){
$stky = $thisamt."e;**"e;;
while($gtparts = mysql_fetch_assoc($getparts)){ // return one row at a time for new users joining...burrito
$stky .= $gtpartsї'name']."e;<br>"e;;
}// end while for result set...burrito
echo $stmixed experiences with it (mostly good). But it's apparent there are some that are bad which are causing it to not work at all. I know this isn't what you want to hear, but for demonstration purposes, might be better to try hitting it with IE
I'll let all of you geniouses work out the FF bugs
////////////////////////
I didn't want to post this just yet because it still has some bugs (especially with firefox) but after sooo many people requesting information about chat applications, I thought this could be a good resource for people looking to create their own with somethign other than java/flash and the like.
I do ask that if you modify it in any way, that you please provide me with the changes so that I can incorporate them into my version (assuming I like them ).
it uses subqueries so 4.1 is required on the db end.
i have it set up [url=http://www.21-learn.com/chat/enterchat.php]here[/url] and if you click that link and join the chat, it will email me so I can give you a short demonstration.
I made this quite some time ago and havent' had the time/desire (more desire than time) to fix the small issues that have come up. It's a good start though and I'll bet if you put a little work and effort into it, you could make it super spicy...but remmeber to keep me posted on the spice.
Code: Select all
-- phpMyAdmin SQL Dump
-- version 2.6.1-rc2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 13, 2005 at 07:42 PM
-- Server version: 4.1.10
-- PHP Version: 5.0.3
--
-- Database: `chat`
--
-- --------------------------------------------------------
--
-- Table structure for table `chatcli`
--
DROP TABLE IF EXISTS `chatcli`;
CREATE TABLE IF NOT EXISTS `chatcli` (
`id` mediumint(9) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`cliid` mediumint(9) default NULL,
`time` datetime default NULL,
`chattext` longtext,
`room` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `time` (`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=382 ;
-- --------------------------------------------------------
--
-- Table structure for table `chatread`
--
DROP TABLE IF EXISTS `chatread`;
CREATE TABLE IF NOT EXISTS `chatread` (
`id` mediumint(9) NOT NULL auto_increment,
`chatid` mediumint(9) default NULL,
`cliid` mediumint(9) default NULL,
`name` varchar(255) defau