Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
Active Users in Chat (Works with any web chat client including JPilot) Details »
Active Users in Chat (Works with any web chat client including JPilot)
Mod Version: 1.00, by Dom (Member) Dom is offline
Developer Last Online: Oct 2002 I like it Show Printable Version Email this Page

This modification is in the archives.
vB Version: 2.2.x Rating: (0 vote - 0 average) Installs: 7
Released: 13 Jan 2002 Last Update: Never Downloads: 0
Not Supported Is in Beta Stage  

I am using JPilot for a chat client on my websites. I haven't found a great solution for showing what users are in the chat so I decided to code my own.

Live demo at : http://www.cgchat.com
The users are listed at the top.

The script seems to work well, but I haven't had time to take a look at much of the vbulletin code, so it does maybe need some work.

Instructions:

!Backup your vbulletin and site!

Modify user table with the fallowing lines

ALTER TABLE user ADD lastchatactivity int(10) unsigned DEFAULT '0' not null
ALTER TABLE user ADD inchat smallint(4) DEFAULT '0' not null

Whatever chat software you are using, you have to have it open in a new browser window. Create a page that has two frames.
=============================

<html>
<head>
<title>Site Title.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<frameset rows="1,*" frameborder="NO" border="0" framespacing="0">
<frame name="topFrame" scrolling="NO" noresize src="mainchat_top.php" >
<frame name="mainFrame" src="main_chat.php">
</frameset>
<noframes><body bgcolor="#FFFFFF" text="#000000">

</body></noframes>
</html>

=============================


main_chat.php: This page has your chat client, in my case jpilot.

mainchat_top.php: The top page has a page with this code:

=============================
<?php
require("global.php");
if( $bbuserid ) {

$DB_site->query("UPDATE user SET inchat='1' WHERE userid='$bbuserinfo[userid]'");
$DB_site->query("UPDATE user SET lastchatactivity=$ourtimenow WHERE userid='$bbuserinfo[userid]'");
} else {

} // end if
?><html>
<head>
<meta http-equiv="refresh" content="100; url=http://www.cgchat.com/board/mainchat_top.php">
</head>
<body bgcolor="#0F1D2D">
<center><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Please leave this window open when you are in the CG Live Chat
</font></center></body>
</html>

=============================

What this does is the top hidden frame refreshes every 100 seconds updating the database with the user in the chat. So if the users are using a chat client like mirc this won't show them that they are on the chat, unless you make a new page and point them to the code that updates the db like the code above.

Now the printing isn't very well optimized for vbulletin. This is because I get confused when working with templates in vb , didn't have much time to play around with them yet. Anyway this is what I do:

Create a new page call it : displaychatusers.php and place this code

------------------------------------------------
<?
if ($showforumusers) {
$datecut = $ourtimenow - $cookietimeout;
$chatters = '';
$comma = '';
$forumusers = $DB_site->query("SELECT username, invisible, userid
FROM user
WHERE inchat = 1 AND
lastchatactivity > $datecut");
while ($forumuser = $DB_site->fetch_array($forumusers)) {
if (!$forumuser['invisible'] or $bbuserinfo['usergroupid'] == 6) {
$userid = $forumuser['userid'];
$username = $forumuser['username'];
if ($forumuser['invisible'] == 1) { // Invisible User but show to Admin
$invisibleuser = '*';
} else {
$invisibleuser = '';
}
eval("\$chatters .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
$comma = ', ';
}
}

}
?>
------------------------------------------------

Now I include this page in the header of vbulletin, and echo $chatters in one of the templates. That's it.

If you want to display the users in the forums I used GeorgeofCS previous code from his hack on digichat. Here is a paste:

in forumdisplay.php

at the very bottom the right above:

eval("dooutput(\"".gettemplate('forumdisplay')."\");");

add:

// Get users chatting
if ($showforumusers) {
$datecut = $ourtimenow - $cookietimeout;
$chatters = '';
$comma = '';
$forumusers = $DB_site->query("SELECT username, invisible, userid
FROM user
WHERE inchat = 1 AND
lastchatactivity > $datecut");
while ($forumuser = $DB_site->fetch_array($forumusers)) {
if (!$forumuser['invisible'] or $bbuserinfo['usergroupid'] == 6) {
$userid = $forumuser['userid'];
$username = $forumuser['username'];
if ($forumuser['invisible'] == 1) { // Invisible User but show to Admin
$invisibleuser = '*';
} else {
$invisibleuser = '';
}
eval("\$chatters .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
$comma = ', ';
}
}
if ($chatters) {
if (!$moderatedby) {
$onlineusers = "<br>";
}
eval("\$onlineusers .= \"".gettemplate('forumdisplay_loggedinusers')."\";");
}
}

Next in forumdisplay_loggedinusers template
change:

<br>(Users Browsing this Forum: $browsers)

to:

<br>(Users Browsing this Forum: $browsers)
<br>(Users In Chat: $chatters)

Thats it, if you have any suggestions or extra info let me know. It seem to be a little delayed, and sometimes when a user leaves a chat it still prints there name in chatters , it has to do something with the lastactivity and cookietimeout. I stole that from GeorgeofCS code and it seems to work quite well.

Let me know what you think.

Cheers

Dom
[email protected]
www.insidecg.com
www.cgchat.com

Download Now

Only licensed members can download files, Click Here for more information.

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Similar Mod
Mod Developer Type Replies Last Post
Jpilot Jirc Chat Integration (basic, but it works)... mini2 vBulletin 3.0 Beta Releases 5 26 Jul 2004 02:39
jPilot (IRC chat) Integration Jakeman vBulletin 2.x Full Releases 139 06 Jan 2004 13:35
Modification to the jpilot chat hack JJR512 vBulletin 2.x Full Releases 11 11 Oct 2003 10:59

Comments
  #2  
Old 13 Jan 2002, 11:09
rawnet's Avatar
rawnet rawnet is offline
 
Join Date: Nov 2001
Looks Encouraging

Hi Dom,

This hack looks hugely encouraging. I'm not keen to be the first person to try it. I'm also using vbPortal and would like to include this information in a side block, if possible.

My main concern before installing it would be speed - how does this affect loading time of your forums? Have you noticed much difference? What has been the response of your users?

Cheers for now,

Ross
Reply With Quote
  #3  
Old 13 Jan 2002, 12:15
GeorgeofCS's Avatar
GeorgeofCS GeorgeofCS is offline
 
Join Date: Oct 2001
I know solution to the delay, but seeing that everyone just "steals" my code and re-releases it without asking first I'll keep the information for myself. Cause frankly if you had asked I would have told you the code doesn't work quite well for refreshing.
Reply With Quote
  #4  
Old 13 Jan 2002, 12:37
rawnet's Avatar
rawnet rawnet is offline
 
Join Date: Nov 2001
If part of this hack hack does user GeorgeofCS's code, and he hasn't been asked or credited then this hack should be removed.
Reply With Quote
  #5  
Old 13 Jan 2002, 13:48
Dom Dom is offline
 
Join Date: Jan 2002
The reason I posted this is no body has made a good solution for showing who is in the chat when using vbulletin.

The code works fine with reloading and I don't see any performance changes. It works well.

As for the code I stole, it was only the
----
if ($showforumusers) {
$datecut = $ourtimenow - $cookietimeout;
$chatters = '';
$comma = '';
$forumusers = $DB_site->query("SELECT username, invisible, userid
FROM user
WHERE inchat = 1 AND
lastchatactivity > $datecut");
while ($forumuser = $DB_site->fetch_array($forumusers)) {
if (!$forumuser['invisible'] or $bbuserinfo['usergroupid'] == 6) {
$userid = $forumuser['userid'];
$username = $forumuser['username'];
if ($forumuser['invisible'] == 1) { // Invisible User but show to Admin
$invisibleuser = '*';
} else {
$invisibleuser = '';
}
eval("\$chatters .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
$comma = ', ';
}
}

}
------

I would have rewrote, but why do it if one is already main availble. I have noted it's your code. I really don't care if you or I made it. I am not here for competition! I am here to offer some sort of solution to your problems. I mentioned your name.

ITS GEORGEOFCS CODE!!! Yes those 10 lines are his code. It works well. If he won't allow you to use it, I will write my own.

I am sorry for the missunderstanding, I thought this is a community for sharing ideas. Seems to me it's a popularity spike.
I am not selling the code, so don't worry no million is going to arrive at my door.

Cheers

-Dom
Reply With Quote
  #6  
Old 13 Jan 2002, 17:08
sk187 sk187 is offline
 
Join Date: Dec 2001
Dom- great script im deffinetly going to use it but can you please post a link to the jpilot hack you used? I have a copy of jpilot and have been using it in a different way on my board and want to intergreat it like you did.


Hi stan
Reply With Quote
  #7  
Old 13 Jan 2002, 17:30
Dom Dom is offline
 
Join Date: Jan 2002
You are going to have to tell me exacthly what you mean. All you have to do is make a button in one of the templates to open a new window that frame window.
Reply With Quote
  #8  
Old 13 Jan 2002, 18:37
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Real name: Maurice
Thumbs up

Great! Thanks for sharing. Gonna install this one later.
Reply With Quote
  #9  
Old 13 Jan 2002, 19:15
GeorgeofCS's Avatar
GeorgeofCS GeorgeofCS is offline
 
Join Date: Oct 2001
The point of my post is at least you could have asked me first. Not so much because I don't want you taking my hack, but rather there's bugs in my code and the better version was to be release within the next day or so, and it's bug free and not beta.
Reply With Quote
  #10  
Old 13 Jan 2002, 21:17
Dom Dom is offline
 
Join Date: Jan 2002
I am sorry Goerge , I should have asked you are right. If you do have a new version do share it with us if you like. I didn't proclaim the code as being mine, so I really didn't think it would matter to you even if I mentioned your name.

Again sorry.


There seems to be a slight delay in a post however. It displays the users in the chat, but they are no longer there. It does have something to do with your code and cookietimeout time stamp.


-Dom
Reply With Quote
  #11  
Old 17 Jan 2002, 05:46
jisung jisung is offline
 
Join Date: Dec 2001
Dom,
I'm trying to install this hack but having difficulty now.

Now I include this page in the header of vbulletin, and echo $chatters in one of the templates. That's it.
How can I include this "displaychatusers.php" in every header?
I've tried to put them in phpinclude by adding a line of "include (./displaychatusers.php)" and it works only in forumdisply.php but showtread.php can't be viewed since then.

Thanks in adv.
Jisung
Reply With Quote
  #12  
Old 04 Feb 2002, 13:19
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Just wondering. I saw the word refresh. I would like to have someway to see who's in chat but the refresh thing bothers me. Can you here the refresh clicks while you are in chat? If not I will install this and try it on 2.2.2 .. I just dont like that clicking sound from the refresh. Thanks
Reply With Quote
  #13  
Old 06 Feb 2002, 21:36
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
No clicking sound.. Great!!.. You have to wait on the cookie to clear to be shown as logged out of the chat. I found an alternative and that was to add a popup on exit to the frameset. Then I created another php file I named chat_logout.php ..

The frameset looks like this:

<html>
<head>
<title>Site Title.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function leave() {
window.open('http://www.Your-Site.com/chat_logout.php','','toolbar=no,menubar=no,location=no,height=204,width=700');
}
// End -->
</SCRIPT>
</head>

<frameset onUnload="leave()" rows="1,*" frameborder="NO" border="0" framespacing="0">
<frame name="topFrame" scrolling="NO" noresize src="mainchat_top.php" >
<frame name="mainFrame" src="main_chat.php">
</frameset>
<noframes><body bgcolor="#FFFFFF" text="#000000">

</body></noframes>
</html>

The new php file looks like this:

<?php
require("global.php");
if( $bbuserid ) {

$DB_site->query("UPDATE user SET inchat='0' WHERE userid='$bbuserinfo[userid]'");
$DB_site->query("UPDATE user SET lastchatactivity=$ourtimenow WHERE userid='$bbuserinfo[userid]'");
} else {

} // end if
?>
<head>
<title>Chat Log-Out</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY onLoad="setTimeout(window.close, 5000)"
</body>
</html>


The chat_logout.php is the pop up. The settings above are for 5 seconds. You can customize the body of the pop up to look like you want.. I made mine match my vb and it basically says that you have succesfully logged out of chat. The pop up above is blank. This logs you straight out of the chat with no waiting on cookies and will do me till I see a better solution.

Last edited by PhotoGenie; 06 Feb 2002 at 21:39.
Reply With Quote
  #14  
Old 11 Feb 2002, 04:05
sk187 sk187 is offline
 
Join Date: Dec 2001
im having the same problem as jisung

How do i include displaychatusers.php in the header

and isnt $chatters already echo'd later on in the hack.


Any way any help is appreciated.
Reply With Quote
  #15  
Old 11 Feb 2002, 10:27
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Originally posted by sk187
im having the same problem as jisung

How do i include displaychatusers.php in the header

and isnt $chatters already echo'd later on in the hack.


Any way any help is appreciated.

It depends on where you want it to be.. Mine is at the bottom of my boards under private messages. I included mine in my forumhome_pmloggedin template but I wanted mine where it wasnt visible unless you are looged in. Guest dont see it. I just added this to the bottom of the template.

<tr id="cat">
<td bgcolor="#606096" colspan="6"><smallfont color="#FFF788"><b>Current Chatters </b></smallfont><smallfont color="#FFF788"></smallfont></td>
<tr>
<td bgcolor="#F1F1F1" colspan="6"><smallfont>$chatters</smallfont></td>
</tr></tr>


in root/index.php I put:

require('./displaychatusers.php');


right under:

require('./global.php');

and thats all the changes I made to index.php.



the second problem I was having problems with was when I added the part to show chatters in threads. If chatters were in chat. It would add everything twice to the top of the threads Instead of looking like this:

(Moderated by: milo)
(Users Browsing this Forum: Dave)
(Users In Chat: Dave)

it looked like this:

(Moderated by: milo)
(Users Browsing this Forum: Dave)
(Users In Chat
(Users Browsing this Forum: Dave)
(Users In Chat: Dave)


.. I got mine fixed. If you have this problem just pm me and I'll tell you what I did.
Anyway, hope this helped you.

My chat is open to guest if you would like to check it out It will not show guest as logged in though

Last edited by PhotoGenie; 11 Feb 2002 at 10:46.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:35.

Layout Options | Width: Wide Color: