MyBB Community Forums

Full Version: Ajax chat question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm not sure if I'm doing this right.
To use open source Ajax chat as a chat box on MyBB the developer said to put this in a PHP file:
<?php
function getShoutBoxContent() {
// URL to the chat directory:
if(!defined('AJAX_CHAT_URL')) {
define('AJAX_CHAT_URL', './chat/');
}

// Path to the chat directory:
if(!defined('AJAX_CHAT_PATH')) {
define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/chat').'/');
}

// Validate the path to the chat:
if(@is_file(AJAX_CHAT_PATH.'lib/classes.php')) {

// Include Class libraries:
require_once(AJAX_CHAT_PATH.'lib/classes.php');

// Initialize the shoutbox:
$ajaxChat = new CustomAJAXChatShoutBox();

// Parse and return the shoutbox template content:
return $ajaxChat->getShoutBoxContent();
}

return null;
}
?>

and this in a MyBB template:
<div style="width:200px;"><?php echo getShoutBoxContent(); ?></div>

The developer also said to, "Make sure AJAX_CHAT_URL and AJAX_CHAT_PATH point to the chat directory."

So I'm having trouble implementing this..
Do I just put the php in a chat.php file in the forums root and then paste the template code in index template? Will it work like that?

And I'm not sure what to edit in the PHP to make sure "AJAX_CHAT_URL and AJAX_CHAT_PATH point to the chat directory."

Please help!
I put that in my portal php, back when I had a shoutbox.

Try this: http://www.leefish.nl/mybb/showthread.php?tid=766
Oh I don't want to do core edits if I can't help it, looked at the entire thread and so it's a resource hog? I'm not noticing performance issues yet.. at least not when in it's own directory.. but I'm trying to put it in my header template with the directions in my OP from the developers website (to use on MyBB). Please help oh great Leefish!

If I put php in it's own file and put in forum root how do I call for that php file in the header template? will the html code the developer gave suffice? and what part of the php code do I alter to fix the url and dir? is it the './chat/' part?
um, I am not so great, you mean someone else. Use patches plugin. That makes core edits easy. I just started using Patches - I wish I had used it sooner.

And YES, it is a resource hog - you are pinging your server ALL THE TIME.
Do you have a link for this patches plugin? I've never heard of it before.
GASP. It is on the mods site and you need that and plugin library. If you are looking at getting Euantor's alerts then you wil need plugin library anyway.

http://mods.mybb.com/view/patches
http://mods.mybb.com/view/pluginlibrary
k, I've been reading through the 2 support threads... this patches looks like it will do the job I need done, thank you Leefish.

Any recommendation on where I should append the php to?
Where are you thinking to put the shoutbox? Index or portal?
in header template... I don't know which PHP file that is that the header template is dependent on.
You want this shoutbox on every page???

Most people just put it on index or portal. In that case you attach it to the appropriate page (index or portal) What you can try (??) is making that php code a php file - call it chatbox and bung it in the forum root.... If you have not changed the default locaton of the chat then the links should work. No IDEA how secure that is. Be careful - that is direct user input.
Pages: 1 2