The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Details »» | |||||||||||||||||||||||||
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
|
Comments |
#22
|
||||
|
||||
Quote:
|
#23
|
||||
|
||||
Quote:
|
#24
|
|||
|
|||
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 Then in your bot config file add: source scripts/peak1.5.tcl That's it Enjoy |
#25
|
|||
|
|||
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 ?
|
#26
|
|||
|
|||
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
|
#27
|
||||
|
||||
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? |
#28
|
||||
|
||||
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? |
#29
|
||||
|
||||
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:
PHP 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:
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> |
#30
|
||||
|
||||
working quite well on 2.2.6 Thank you
Amy |
#31
|
||||
|
||||
How do I make it so I can show the number of people in the chat? Fantastic hack btw!!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|