MyBB Community Forums

Full Version: PHP question - AJAX Plugin.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
http://mods.mybb.com/view/ajax-chat-user-count

I downloaded this plugin and installed it, the PHP is:

<?php

/*
	Ajax-Chat User-Count Plugin for MyBB
	Copy this file into your plugins directory and activate in the admin control panel
*/

if(!defined("IN_MYBB")) {
    die("This file cannot be accessed directly.");
}

$plugins->add_hook('index_start','ajaxchatusercount',1000);
$plugins->add_hook('global_start','ajaxchatusercount',1000);

function ajaxchatusercount_info() {
	return array(
		'name'			=> 'ajaxchatusercount',
		'description'	=> 'AjaxChat User Count',
		'website'		=> 'mailto:[email protected]',
		'author'		=> 'fwalderd',
		'authorsite'	=> 'mailto:[email protected]',
		'version'		=> '0.1',
		'compatibility' => '16*'
	);
}

function ajaxchatusercount_activate() {
//	global $db, $mybb;
}

function ajaxchatusercount_deactivate() {
//	global $db,$mybb;	
}

function ajaxchatusercount() {
	global $ajaxchatusercount,$db,$mybb;
//Count Users in Ajax Chat and return a string: Chat(x)
	$query=$db->query("SELECT userID FROM ajax_chat_online"); 
	$usercount=0;
	while($record=$db->fetch_array($query)) {
		$usercount=$usercount+1;
	} 
//If you want a different output, edit the line below
	$ajaxchatusercount="Chat <strong>(".$usercount.")</strong>";
}
?>

How do I get the forum to return the number of users currently in chat?

I made a new navbar link by editing the 'header' and adding the link to the chat directory, the header now looks like:

<li><a href="{$mybb->settings['bburl']}/calendar.php">{$lang->toplinks_calendar}</a></li>
<li><a href="{$mybb->settings['bburl']}/misc.php?action=help">{$lang->toplinks_help}</a></li>
<li><a href="{$mybb->settings['bburl']}/chat">Chat</a></li>

Can someone please help?
I believe this should do it.


<li><a href="{$mybb->settings['bburl']}/chat">Chat ({$ajaxchatusercount})</a></li>
(2011-11-10, 02:13 AM)Jason L. Wrote: [ -> ]I believe this should do it.


<li><a href="{$mybb->settings['bburl']}/chat">Chat ({$ajaxchatusercount})</a></li>

Worked fine, many thanks. Smile



Edit: One more thing, is there any way to show who's in chat?
(2011-11-10, 02:18 AM)Knack Wrote: [ -> ]
(2011-11-10, 02:13 AM)Jason L. Wrote: [ -> ]I believe this should do it.


<li><a href="{$mybb->settings['bburl']}/chat">Chat ({$ajaxchatusercount})</a></li>

Worked fine, many thanks. Smile



Edit: One more thing, is there any way to show who's in chat?

Not that I know of, sorry.
Seriously, one last thing now...


 <li><a href="{$mybb->settings['bburl']}/chat">{$ajaxchatusercount}</a></li> 

What can I add to this to make it pop up in a new window? I've been messing around and so far I can only get it to open up in a new tab, I want it to open up as a new window.
This is incredible. Thanks! By the way, Knack, I use this in my header template.
<li><a href="{$mybb->settings['bburl']}/chat" target="_blank">Chat Room ({$ajaxchatusercount})</a></li>

This way, it just shows the number in brackets after "Chat Room". This opens the chat in a new tab. Modify it to your needs. If anyone could help me in my AJAX Chat thread I'd be most grateful. I know I should contact the developers, but they make it very hard to get in touch with them, and they pretty much make it clear that they don't want to be contacted for support. So if anyone knows how to help, thanks.
sorry for bumping an old thread but.

I get this error when installing it

[Image: kQbTI.png]

Any ideas?
Any ideas?
Any ideas?
bumping
Pages: 1 2