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
  #32  
Old 07-22-2002, 05:33 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm wondering who has got this to work without having to clear your cookies everytime you leave the chat, in order to get the "who's chatting" updated. I saw the solution with the popup on the first page, but surely there is an automatic way...
Reply With Quote
  #33  
Old 07-22-2002, 06:39 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Never mind, after awhile tinkering with the code I have finally got it to work

Simply perfect, I have it working with the IRC Bocazas chat hack and everything works fine. This hack causes no performance drop either, for those questioning this. Only thing I wish could be possible is if users using mIRC, or another chat client, could be picked up also..ofcourse that logically isn't possible with this hack.
Reply With Quote
  #34  
Old 12-28-2002, 09:46 PM
SloppyGoat's Avatar
SloppyGoat SloppyGoat is offline
 
Join Date: Feb 2002
Posts: 339
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by X-Fan
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.



to show it all on the front page after the logged in users section.
This looks like a great hack, but I can't quite figure it out. Can someone clue me in a bit? First, I don't know how to find out what usergroup id is the admin! How is this done? Second, will I need to edit the other usergroupid's listed in this code? I'm not very knowledgeable in php. Please elaborate for idiots like me. What is usergroup 5, 6, and 7 in this example? I think I'm close, if i can just figure out this usergroupid thing.

[edit]
Ok, I figured out how to find it in phpmyadmin, and my usergoupid's are the same, so now I don't know what I'm doing wrong....unless the db needs to be modified?

I keep getting this db error when I try this:

Invalid SQL: SELECT username,invisible,userid,usergroupid FROM user WHERE inchat=1 AND lastchatactivity>1041116216 ORDER BY invisible ASC, username ASC
mysql error: Unknown column 'inchat' in 'where clause'

mysql error number: 1054

Do I need to modify the db with this?

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

If so, how do I do that? I do have phpmyadmin installed, but don't know much about it. :ermm:

[edit2]
AAAARRRRGGGHHHH!!! Well, I added those two to my user table, but it still didn't do anything.
Reply With Quote
  #35  
Old 01-07-2003, 04:40 AM
lifesourcerec's Avatar
lifesourcerec lifesourcerec is offline
 
Join Date: Jan 2002
Posts: 429
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, use phpMyAdmin. If you enter it, use this:

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

A ";" was missing.

Works great for me now.. but messes up another script.
Reply With Quote
  #36  
Old 01-07-2003, 12:33 PM
SloppyGoat's Avatar
SloppyGoat SloppyGoat is offline
 
Join Date: Feb 2002
Posts: 339
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I'll try it again then. What other script does it mess up, though? :disappointed:
Reply With Quote
  #37  
Old 01-08-2003, 04:24 AM
lifesourcerec's Avatar
lifesourcerec lifesourcerec is offline
 
Join Date: Jan 2002
Posts: 429
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The Top 5 Statistics hack.

In the "Top 5 Newest Members:", whenever someone joins the chat, it will put their name before the first new user.

Conflict with $username.
Reply With Quote
  #38  
Old 01-08-2003, 12:25 PM
SloppyGoat's Avatar
SloppyGoat SloppyGoat is offline
 
Join Date: Feb 2002
Posts: 339
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok cool. I don't use that hack anyway.
Reply With Quote
  #39  
Old 05-02-2004, 05:40 PM
hubba hubba is offline
 
Join Date: Dec 2003
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hm, in VB 3 this gives a database eroor?

$DB_site->query("UPDATE user SET inchat='0' WHERE userid='$bbuserinfo[userid]'");
$DB_site->query("UPDATE user SET lastchatactivity=$ourtimenow WHERE userid='$bbuserinfo[userid]'");
Reply With Quote
  #40  
Old 05-09-2004, 03:50 PM
hubba hubba is offline
 
Join Date: Dec 2003
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wahhh isnt it possible to rewrite that to VB3???
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 01:13 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.04547 seconds
  • Memory Usage 2,327KB
  • Queries Executed 24 (?)
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
  • (3)bbcode_php
  • (1)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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