Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Beta Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: 1.00, by Dom Dom is offline
Developer Last Online: Oct 2002 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 01-12-2002 Last Update: Never Installs: 7
Is in Beta Stage  
No support by the author.

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
dominik@insidecg.com
www.insidecg.com
www.cgchat.com

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 03-22-2002, 06:17 AM
lifesourcerec's Avatar
lifesourcerec lifesourcerec is offline
 
Join Date: Jan 2002
Posts: 429
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by PhotoGenie
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 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>
Is the above the new main_top.php file?
Reply With Quote
  #23  
Old 03-23-2002, 06:39 AM
nighteyes's Avatar
nighteyes nighteyes is offline
 
Join Date: Oct 2001
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Swamper
...I had a need for this sort of thing last year and the majority of the regular users in my chat now don't use the java client anymore so there was no accurate way to do it with mysql - So I just set up an eggdrop bot in the channel and have it running a simple TCL script I wrote that writes out the # of people in the channel to disk every time someone joins (didn't bother to have it do it when someone leaves - but that's easy to add too)

..then set up a crontab to copy the file over to my web directory (since the bot runs as user nobody) and within global.php have:

$fd = fopen ("path/to/file_with_number_in_chat", "r");
$num_in_chat = fgets($fd, 3);
fclose ($fd);

...then just insert $num_in_chat in a template or wherever and I have easy access to it..
Would you possibly mind sharing this TCL script? And how you have cron setup? This would be a far more efficient way of doing things than using MySQL. vbulletin has enough mysql queries already going on.
Reply With Quote
  #24  
Old 03-23-2002, 09:31 PM
Swamper Swamper is offline
 
Join Date: Oct 2001
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is my crontab:

* * * * * root /path/to/file_to_run

contents of file_to_run:

/bin/cp /path/to/eggdrop/numchat.txt /path/to/yoursite.com/wherever

Make sure to chmod 755 the file_to_run afterwards...

I modified the peak eggdrop script (announces in channel whenever a new record is set for # of ppl in the channel) - I just added to line 31:

Code:
set fid [open "numchat.txt" "WRONLY CREAT"]
puts $fid $curnum
close $fid
Change the filename to whatever you want (not necessary)

Then in your bot config file add:

source scripts/peak1.5.tcl

That's it Enjoy
Reply With Quote
  #25  
Old 04-14-2002, 09:41 AM
Patrik Patrik is offline
 
Join Date: Nov 2001
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I followed the instructions for jPilot, added the include for displachatusers.php in my index.php the way explained and added the $chatters to my header, but nothing happens... Any idea why I can't see the people ?
Reply With Quote
  #26  
Old 04-20-2002, 07:28 PM
Harryli Harryli is offline
 
Join Date: Dec 2001
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hm , is it possible that since 2.2.5 the $chatters wont work? I changed nothing, use the same templates, but the chatters are shown no more ... ??? I cant see any reason for this... but now noone is shown as chatting
Reply With Quote
  #27  
Old 06-26-2002, 07:32 PM
kypdurron's Avatar
kypdurron kypdurron is offline
 
Join Date: Dec 2001
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok..so I'm working on a better integration with IRC.
Can I do the following:

I want to pass a channel name as a parameter, and I want to know who is in that channel.

This way, all the users are in "#ForumChat" will be displayed

and there is also a "#ForumsAdmin" Channel, which will also be displayed.

I DO NOT want to have one bot per channel, as the number of channels that I want to do this for can be infinite.

So..it will show you who is in chat for all users, plus
moderators can see who is in the #forumchat and if
there is people in another channel, say #forumsadmin.

Any thoughts?
Reply With Quote
  #28  
Old 06-28-2002, 03:05 PM
X-Fan's Avatar
X-Fan X-Fan is offline
 
Join Date: Jan 2002
Location: Adelaide, Australia
Posts: 496
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just installed this hack, and I just can't get it working. I can get a chat section to come up on my forum's main page, but it's not listing any of the users in the chatroom at the time.

Help!!!

Also, how would you get the number of users currently in the chat to display like the number of users online?
Reply With Quote
  #29  
Old 06-28-2002, 03:58 PM
X-Fan's Avatar
X-Fan X-Fan is offline
 
Join Date: Jan 2002
Location: Adelaide, Australia
Posts: 496
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well whaddya know, I got it working!

Forgetting about displaychatusers.php I decided to go straight for index.php, into which I added this code...

PHP Code:
// get chatters
$datecut=time()-$cookietimeout;
$chatters '';
$comma '';
$forumusers $DB_site->query("SELECT username,invisible,userid,usergroupid FROM user WHERE inchat=1 AND lastchatactivity>$datecut ORDER BY invisible ASC, username ASC");
while (
$forumuser $DB_site->fetch_array($forumusers)) {
    if (
$forumuser['invisible']==or $bbuserinfo['usergroupid']==or $bbuserinfo['usergroupid']==or $bbuserinfo['usergroupid']==7) {
        
$userid $forumuser['userid'];
        if (
$forumuser['invisible'] == 1) { // Invisible User but show to Admin
        
$invisibleuser '*';
        } else {
        
$invisibleuser '';
        }
        if (
$forumuser['usergroupid'] == and $highlightadmin) {
            
$username "<b><i>$forumuser[username]</i></b>";
        } else if ((
$mod["$userid"] or $forumuser['usergroupid'] == 5) and $highlightadmin) {
                  
$username "<b>$forumuser[username]</b>";
        } else {
        
$username $forumuser['username'];
        }
    eval(
"\$chatters .= \"".$comma.gettemplate('forumhome_loggedinuser')."\";");
    
$comma ', ';
    }

after this code...

PHP Code:
} else {
  
$pminfo='';

and it works great! (FYI, my usergroupid of 6 is my administrators group. You'll need to change it to whatever yours is if you want to use this code.)

I managed to get the number of users currently in chat displayed as well. I just added this code to index.php:

PHP Code:
// get total chatters
$datecut=time()-$cookietimeout;
$chatnum mysql_num_rows(mysql_query("select * from user WHERE inchat=1 AND lastchatactivity>$datecut")); 
after the above code and it works fine.

Then added this to the bottom of the forumhome_loggedinusers template:

Code:
<tr id="cat">
	<td bgcolor="#336D95" background="https://vborg.vbsupport.ru/images/catagory_backing.gif" colspan="6"><a href="chat/"><normalfont color="#000000"><b>Users Chatting</b></normalfont></a><normalfont color="#000000"><b>: $chatnum</b></normalfont></td>
</tr>
<tr>
<td bgcolor="#1C5780" align="center" valign="top">
<a href="chat/"><img src="https://vborg.vbsupport.ru/images/activechatters.gif" alt="Users Chatting" align=middle border=0></a>
</td>
	<td bgcolor="#13486D" colspan="5"><smallfont>
	$chatters</smallfont></td>
</tr>
to show it all on the front page after the logged in users section.
Reply With Quote
  #30  
Old 06-29-2002, 01:28 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

working quite well on 2.2.6 Thank you

Amy
Reply With Quote
  #31  
Old 07-19-2002, 02:02 AM
Matt's Avatar
Matt Matt is offline
 
Join Date: Oct 2001
Location: UK
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do I make it so I can show the number of people in the chat? Fantastic hack btw!!
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 08:01 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07192 seconds
  • Memory Usage 2,344KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete