Integrating AJAX Chat 0.8.7 with myBB 1.6.9

182 views
Skip to first unread message

fourb...@gmail.com

unread,
Mar 9, 2014, 10:17:57 PM3/9/14
to ajax...@googlegroups.com
Hey guys,

I've been spending quite some time trying to integrate the chatbox as a "shoutbox". I've been using the readme included with the download, and I just can't seem to get it working.

1. I added the @import url part to my global.css for the first line.


2. I feel like this is where my problem is. I'm confused with the difference between the AJAX_CHAT_URL and the AJAX_CHAT_PATH.I'm assuming the URL would be the same thing I put in the @import url statement, right? But what would I put for the PATH? I thought it would be just like the path you would find if you're using a FTP program like FileZilla, but I've tried multiple methods and it just won't work for me, it's getting pretty frustrating. Could someone post some example code?

3. I put:


README:


Shoutbox

AJAX Chat is also usable as shoutbox - this is a short guide on how to set it up:

Shoutbox Stylesheet

Add the following line to the stylesheet (CSS) of all pages displaying the shoutbox:

@import url("http://example.org/path/to/chat/css/shoutbox.css");

Replace http://example.org/path/to/chat/ with the URL to the chat.
Modify css/shoutbox.css to your liking.

Shoutbox Function

Add the following function to your PHP code:

<?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;
}
?>

Make sure AJAX_CHAT_URL and AJAX_CHAT_PATH point to the chat directory.

Shoutbox Output

Display the shoutbox content using the shoutbox function:

<div style="width:200px;"><?php echo getShoutBoxContent(); ?></div>

FireWire

unread,
Mar 10, 2014, 5:14:27 AM3/10/14
to
Hi.

First off, you didn't tell where you inserted the code. You use MyBB, so I guess you inserted it in the file '/forum/index.php', right?

And to answer this:
2. I feel like this is where my problem is. I'm confused with the difference between the AJAX_CHAT_URL and the AJAX_CHAT_PATH.I'm assuming the URL would be the same thing I put in the @import url statement, right? But what would I put for the PATH? I thought it would be just like the path you would find if you're using a FTP program like FileZilla, but I've tried multiple methods and it just won't work for me, it's getting pretty frustrating. Could someone post some example code?

AJAX_CHAT_URL = the full web address to the chat directory e.g. 'http://www.example.org/chat/' <--- From outside world.
AJAX_CHAT_PATH = base address to the chat e.g. '/chat/' <--- From server side, normally the '/chat/' is from the root of the server. But in your case it is '/forum/chat/'.
BUT the above labels AJAX_CHAT_URL and AJAX_CHAT_PATH should NOT be replaced, you only define what they should contain, not replacing them as you have done.
define('AJAX_CHAT_URL', './chat/');
The first part is the constant string name: 'AJAX_CHAT_URL' the second part is the value of the constant string: './chat/'. The reason for even using this, is so you don't have to insert the whole address every time it's needed. In your code, you removed the constant string completely, so it cannot be used anywhere.
Don't know how much you know about php, so I hope you don't think I am rude to explain how it works. Just want to help you.

@import url-statement points to a stylesheet, so nothing to do with the above except it usually have the same base url.

The problem I see so far, is that you removed the important parts in the php-code.
 
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').'/');
}

You can't remove AJAX_CHAT_URL and AJAX_CHAT_PATH from the defines. The point with those lines is to tell the code where your chat resides and then reuses it when chat's address is needed.
If you really need to change anything, then you should only change the last part of the statements e.g. after the ','.
define(AJAX_CHAT_URL, './chat/'); The red part is the only thing you should change in the code, 
BUT I don't really thing it's needed.
BUT I see one more issue. You have replaced several 'AJAX_CHAT_PATH' with 'MYBB_ROOT'.
Is that some special instructions from the integrated readme? If not, I suggest you remove everything, and just insert the
default code from readme into the forums index.php(or the page where you want the shoutbox to be visible).
Try this and get back.

I don't have any integrated version, so I don't really know exactly how they work.
So my suggestions are general, but hopefully I can give you some hint on how to proceed.

//FireWire

EDIT: I want to add, that the Wiki about this, is a bit unclear regarding what to do with
the code. It could be read as that you should replace 'AJAX_CHAT_URL' and 'AJAX_CHAT_PATH'
but that's not the case.

fourb...@gmail.com

unread,
Mar 10, 2014, 4:30:18 PM3/10/14
to ajax...@googlegroups.com
Hi FireWire,

Thanks so much for the detailed response- extremely appreciated. I have a very large background in programming, I've just never done anything in PHP. Looks like that should be my next language to look into. :p

Unfortunately, I still can't get it to work. I've tried just copying and pasting the code in without changing it, and I've tried some of my own edits as well. Nothing working so far. Since my forum isn't at the root of my website, do I need to edit some code? For example:

Instead of: define('AJAX_CHAT_URL', './chat/');

Should I put: define('AJAX_CHAT_URL', './forum/chat/');

I tried using both, and still nothing. Do I need to do anything similar in the

define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/forum/chat').'/');

line? Also, is there anyway I can just hard-code the values of URL and PATH? Thank you again for all the help!

fourb...@gmail.com

unread,
Mar 23, 2014, 7:30:14 PM3/23/14
to ajax...@googlegroups.com
Still looking for an answer- can someone help me out?

Frug

unread,
Mar 23, 2014, 9:30:34 PM3/23/14
to ajax...@googlegroups.com
 If you know how to turn on error reporting, or can find your server's error logs, that can help you find the source of the problem.

It's kind of impossible to solve a problem from here with a description of "my script won't work" when we don't know your file structure or where you're putting the php code into. With errors on it should say pretty clearly "cannot find file home/user/you/www/whatever/chat/classes.php and then you can find out why it's not in the right place.

fourb...@gmail.com

unread,
Mar 23, 2014, 10:34:33 PM3/23/14
to
I tried to put as much information as I could in the OP. Is there anything more specific I can post to help out? I'll certainly try error reporting.
Reply all
Reply to author
Forward
0 new messages