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
  #12  
Old 01-17-2002, 04:46 AM
jisung jisung is offline
 
Join Date: Dec 2001
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dom,
I'm trying to install this hack but having difficulty now.

Quote:
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
  #13  
Old 02-04-2002, 12:19 PM
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
  #14  
Old 02-06-2002, 08:36 PM
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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,locatio n=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.
Reply With Quote
  #15  
Old 02-11-2002, 03:05 AM
sk187 sk187 is offline
 
Join Date: Nov 2001
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
  #16  
Old 02-11-2002, 09:27 AM
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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
Reply With Quote
  #17  
Old 02-12-2002, 02:10 AM
sk187 sk187 is offline
 
Join Date: Nov 2001
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there anyway to make jpilot automatically log the chat users in under there name on the board.

Somthing like what is done in other scripts like

<param name="NickName" value="{$bbuserinfo[username]}">

in the jpilot script.

The way this current hack is set up the user gets to manually enter his name in. I want to know if its possiable to log them in automatically.

Thanks in advance

And thanks to PhotoGenie for the help it worked great
Reply With Quote
  #18  
Old 02-12-2002, 02:21 AM
PhotoGenie PhotoGenie is offline
 
Join Date: Jan 2002
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your param for that should look like this:

<param name="NickName" value="$bbuserinfo[username]">

Here is whate my applet code looks like:

<applet archive="jirc_nss.zip" code=Chat.class width=700 height=365 >
<param name="CABBASE" value="jirc_mss.cab">
<param name="LicenseKey" value="Your License key">
<param name="ServerPort" value="6667">
<param name="ServerName1" value="Your server">
<param name="Channel1" value="Your Channel name">
<param name="AllowURL" value="true">
<param name="AllowIdentd" value="true">
<param name="WelcomeMessage" value="Your Welcome message">
<param name="RealName" value="Use anything here">
<param name="NickName" value="$bbuserinfo[username]">
<param name="UserName" value="">
<param name="isLimitedServers" value="true">
<param name="isLimitedChannels" value="true">
<param name="ChannelPasword" value="">
<param name="IgnoreLevel" value="3">

<param name="FilterKeys" value=" (cry) :B :O ) :zz :{ (b) (coffee) (m) (cake) (h) (l) (moon) (note) (rose) (*) (d) (p) (gift)" />
<param name="FilterVals" value="smile.gif sad.gif biggrin.gif tounge.gif wink_smile.gif cry_smile.gif embaressed_smile.gif omg_smile.gif shades_smile.gif sleepy.gif angry_smile.gif beer_yum.gif coffee.gif martini_shaken.gif cake.gif heart.gif lightbulb.gif moon.gif musical_note.gif rose.gif star.gif thumbs_up.gif thumbs_down.gif present.gif" />
<param name="MessageCol" value="80">
<param name="BackgroundColor" value="99,132,181">
<param name="TextColor" value="black">
<param name="TextScreenColor" value="white">
<param name="ListTextColor" value="blue">
<param name="ListScreenColor" value="lightgray">
<param name="TextFontName" value="MS Sans Serif">
<param name="TextFontSize" value="11">
<param name="ConfigNickOnly" value="false">
<param name="NickNChannelOnly" value="true">
<param name="LogoBgColor" value="white">
<param name="BorderVsp" value="3">
<param name="DirectStart" value="true">
<param name="FGColor" value="black">
<param name="TitleBackgroundColor" value="black">
<param name="TitleForegroundColor" value="white">
<param name="InputTextColor" value="black">
<param name="InputScreenColor" value="white">
<param name="IgnoreLevel" value="3">
<param name="DisplayConfigRealName" value="false">
<param name="DisplayConfigServer" value="false">
<param name="DisplayConfigPort" value="false">
<param name="DisplayConfigMisc" value="false">
<param name="InitCommands" value="/clear;/me enters">
<param name="UserListWidth" value="160">
<param name="RefreshColorCode" value="false">
<param name="DisplaySoundControl" value="true">
<param name="NoConfig" value="true">
<param name="DisplayAbout" value="false">
<param name="IgnoreServerMsg" value="true">
<param name="IgnoreModeMsg" value="true">
<param name="IgnoreMOTD" value="true">
<param name="IgnoreChannelChangeMsg" value="true">
<param name="AllowSound" value="true">
</applet></td>
</tr>

</table>
</td></tr></table>

</body>

</html>
Reply With Quote
  #19  
Old 02-22-2002, 02:58 AM
sk187 sk187 is offline
 
Join Date: Nov 2001
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for the help PhotoGenie

I just have one more problem

i still keep getting erroneus name when loggin into the chat rooms

It has somthing to do with
<param name="NickName" value="$bbuserinfo[username]">

and it not calling the vb database correctly

is there anyone that can help with this PLEASE

thanks alot sk187
Reply With Quote
  #20  
Old 03-13-2002, 04:28 PM
lifesourcerec's Avatar
lifesourcerec lifesourcerec is offline
 
Join Date: Jan 2002
Posts: 429
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got jpilot integrated and trying to figure out how to integrate this into it. my files are named different and I already have a pop up. Will this every be released?

The only things I may have to integrate is:

Quote:
<?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
?>
and the displaychatusers.php file.

Can someone help me on this? I use this integration chat:

https://vborg.vbsupport.ru/showthrea...threadid=33050
Reply With Quote
  #21  
Old 03-21-2002, 05:34 AM
Swamper Swamper is offline
 
Join Date: Oct 2001
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

...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..
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 12:29 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.04859 seconds
  • Memory Usage 2,338KB
  • 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
  • (3)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