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 |
#32
|
||||
|
||||
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...
|
#33
|
||||
|
||||
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. |
#34
|
||||
|
||||
Quote:
[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. |
#35
|
||||
|
||||
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. |
#36
|
||||
|
||||
Thanks, I'll try it again then. What other script does it mess up, though? :disappointed:
|
#37
|
||||
|
||||
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. |
#38
|
||||
|
||||
Ok cool. I don't use that hack anyway.
|
#39
|
|||
|
|||
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]'"); |
#40
|
|||
|
|||
Wahhh isnt it possible to rewrite that to VB3???
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|