News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

AjaxChat Integration (latest version 3.2.1)

Started by .HuNTeR., August 27, 2008, 12:59:06 AM

Previous topic - Next topic

TheListener

Here are some the most common questions and answers to getting your Chat Room and Shoutbox going on your forum for AJAX Chat Integration 3.2.1           
   
Please be sure to check the following settings in the Admin Panel.

For SMF 1.1.X  Admin/Configuration/Features and Options/

For SMF 2 RC1  Admin/Configuration/Modifications/Chat/

Enable the ShoutBox?   
Check for ShoutBox on any page or uncheck for only in index page:   
Integrate shout box and chat room?   
Chat in popup page?   
Enable online chat users numbering on chat button?   
Show online users below total logged in time section?

Also be sure to CHECK PERMISSIONS ;)

If you are using a custom theme you will need to edit the following files in your custom theme using a Package Parser.
Themes/yourtheme/index.template.php
Themes/yourtheme/style.css

And possibly...

Themes/yourtheme/BoardIndex.template.php
If your theme does not have a BoarIndex.template don't worry about it, that means your forum is using the default BoardIndex.template           

If you get a 500 Connection error you might have to set your file permissions as well.

There are 2 folder for the AJAX Chat Intergration Mod "Chat" and "Shoutbox".
For AJAX Chat Intergration Version 3 "Folders" be sure to change the file permissions (CHMOD) /chat/index.php and /shoutbox/index.php to 755

If you get a Connection  Status: 0 error from time to time it's harmless and you can stop it from showing

chat/js/chat.js
Find

Code: [Select]
this.addChatBotMessageToChatList('/error ConnectionStatus '+this.getHttpRequest(identifier).status);

Replace with
Code: [Select]
if (this.getHttpRequest(identifier).status != 0) {
this.addChatBotMessageToChatList('/error ConnectionStatus '+this.getHttpRequest(identifier).status);
}
Add a Welcome Message when you users enter the Chat

Open.....yourforum/chat/js/custom.js
Find

Code: [Select]
// Overriding client side functionality:

Add After (of course change Welcome to Paranormal Haunt  to whatever you like.)


Code: [Select]
ajaxChat.customInitialize = function() {
   ajaxChat.addChatBotMessageToChatList('Welcome to Paranormal Haunt')

   Change the name of your Chatbot

Open.....yourforum/chat/lib/config.php

Find and change Chatbot to whatever you'd like.

Code: [Select]
// The userName used for ChatBot messages
$config['chatBotName'] = 'ChatBot';
AWAY FROM KEYBOARD

So people don't start saying they are being ignored this is very handy. I use this myself.

Open lib/class/CustomAJAXChat.php and add the following before the last closing bracket } at the end of the file:

Code: [Select]
function parseCustomCommands($text, $textParts) {
      switch($textParts[0]) {
         // Away from keyboard message:
         case '/afk':
            // Set the userName:
            $this->setUserName('<AFK>_'.$this->getUserName());
            // Update the online user table:
            $this->updateOnlineList();
            // Add info message to update the client-side stored userName:
            $this->addInfoMessage($this->getUserName(), 'userName');
            // Store AFK status as session variable:
            $this->setSessionVar('AwayFromKeyboard', true);
            return true;
         default:
            return false;
      }
   }

   function onNewMessage($text) {
      // Reset AFK status on first inserted message:
      if($this->getSessionVar('AwayFromKeyboard')) {
         $this->setUserName($this->subString($this->getUserName(), 6));
         $this->updateOnlineList();
         $this->addInfoMessage($this->getUserName(), 'userName');
         $this->setSessionVar('AwayFromKeyboard', false);
      }
      return true;
   }
PROFANITY WORD FILTER

This modification is short and simple.

Open chat/js/custom.js

Add the following to the end of the file:

Code: [Select]
//Replace stuff people say:
ajaxChat.replaceCustomText = function(text) {
text=text.replace(/frug/gi, 'Fruggles');
return text;
}

This will replace the word frug in chat with Fruggles. You can, of course, replaced the word frug with whatever you like, and you can add more replacements by copying the relevant line. For example:

Code: [Select]
//Replace stuff people say:
ajaxChat.replaceCustomText = function(text) {
text=text.replace(/frug/gi, 'Fruggles');
text=text.replace(/foo/gi, 'Donkey Foo');
return text;
}

ATHOUGH THERE ARE OTHER EDITS WHICH CAN BE MADE THE ONES I HAVE SHOWN ARE THE ONES I USE  ON MY CHAT.

Thanks go to mrtrc266 for the work he has endlessy put in to this mod.

Frosted Flake

I changed the shoutbox & chat permissions and I'm still having trouble.  :'( My members can't log in.

LC

#3722
Quote from: Frosted Flake on September 01, 2009, 06:18:51 PM
I changed the shoutbox & chat permissions and I'm still having trouble.  :'( My members can't log in.
It's either the permissions in your Admin Control Panel->Permissions that aren't set properly or the code in the actual script needs to be modified.

If those two things don't work I would have to say it could be something on the users end blocking the process. (like a firewall) Which is unlikely.


The code in the script you would want to change would be the lib/class/CustomAJAXChat.php file

Here is some information on that file. From the AjaxChat wiki.

getValidLoginUserData()
This method is called on chat login to retrieve valid authentication data.
It must return an associative array with the following values:
'userID' => the userID of the logged in user
'userName' => the (trimmed) userName of the logged in user
'userRole' => the userRole of the logged in user
If the user is logged in to the existing system it should return the userID and the ("trimmed") userName of this user.
The method $this->trimUserName($userName) returns a "trimmed" version of the userName which ensures UTF-8 encoding and avoids invalid characters (e.g. it replaces spaces with the underscore).
The userRole must be one of the following constants:
AJAX_CHAT_ADMIN
AJAX_CHAT_MODERATOR
AJAX_CHAT_USER
If the user is not logged in to the existing system, the method can just return with a call to $this->getGuestUser().
If guest access is allowed, $this->getGuestUser() returns an associative array with a unique guest userID, a guest userName and the userRole constant AJAX_CHAT_GUEST.
If guest access is disabled, $this->getGuestUser() just returns null, which means login is denied.

To read more- http://sourceforge.net/apps/mediawiki/ajax-chat/index.php?title=Custom_integration_howto#getValidLoginUserData.28.29

danielwmoore

Quote from: TheListener on September 01, 2009, 01:31:14 PM
Daniel can you please share how you moved the shoutbox to the bottom of your forum.

many people have asked how to do so.

Certainly, I'd be happy to do so. 

Moving the ShoutBox to the bottom of the page
(index only or all pages, depending on setting in admin panel.  Works either way.)

Open Sources/Load.php:

Find:
array_splice($context['template_layers'], 1, 0, 'shout');


The array_splice might have different numeric constants passed to it, so it might take a bit of searching.  Mine was:
array_splice($context['template_layers'], 2, 0, 'shout');

Replace:
// array_splice($context['template_layers'], 1, 0, 'shout');


As you can see, all you need to do is comment that line out.

Now, there is a problem that when you complete all the changes, and you collapse or expand the ShoutBox, it will jump to the top of the forum page.  You want it to still focus on the ShoutBox, so we do the following:
Open Themes/default/Shout.template.php.
Find:

<a rel="nofollow" href="#" onclick="ajax_shoutBox_collapse(!sb_current_header)"><img id="ajax_shoutbox_collapse" src="', $settings['images_url'], empty($options['sb_collapsed']) ? '/collapse.gif' : '/expand.gif','" alt="*" style="margin-right: 5px;"  /></a>', $txt['shoutBox'], '


Replace with:

<a name="ajax_shoutbox" rel="nofollow" href="#ajax_shoutbox" onclick="ajax_shoutBox_collapse(!sb_current_header)"><img id="ajax_shoutbox_collapse" src="', $settings['images_url'], empty($options['sb_collapsed']) ? '/collapse.gif' : '/expand.gif','" alt="*" style="margin-right: 5px;"  /></a>', $txt['shoutBox'], '


Now, for the fun part.  I next opened index.template.php in each theme that I wanted to place the ShoutBox in. (Which, of course, was all of them.)  This is where you actually place the ShoutBox at the bottom.

Find:

function template_body_below()
{
global $context, $settings, $options, $scripturl, $txt;
echo '
</div>';

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!


Replace with:

function template_body_below()
{
global $context, $settings, $options, $scripturl, $txt;
        template_shout_above();
echo '
</div>';

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
}


If, however, like me, you have created a chat.template.php to integrate it into your forum and a "?action=chat" action to direct people to chat, then you need to replace with the following instead.  (Code for integrating is shown below.) Otherwise, you will see the ShoutBox at the bottom of your actual chat screen, which is not the desired result.  Two chat windows on the same screen can be confusing.

function template_body_below()
{
global $context, $settings, $options, $scripturl, $txt;
if (!($context['current_action'] == 'chat')) {
    template_shout_above();
  }
echo '
</div>';

// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
}


If you want to integrate chat into the forum template system (as hinted to above) then do the following:
Open Sources/Subs.php
Find:

'chat' => array(
'title' => $chatButton,
'href' => $scripturl . $chatLink,
'show' => true,
'sub_buttons' => array(

Replace with:

'chat' => array(
'title' => $chatButton,
'href' => $scripturl . '?action=chat'/*$chatLink*/,
'show' => true,
'sub_buttons' => array(


Open /index.php
Find:

$actionArray = array(

Replace with:

$actionArray = array(
  'chat' => array('chat.php', 'chat'),


Create file Sources/chat.php

<?php
if (!defined('SMF'))
die('Hacking attempt...');
function 
Chat()
{
// Load the 'Chat' template.
loadTemplate('chat');
}
?>



Create file Themes/default/chat.template.php

<?php
function template_main() {
  global 
$boardurl;
  
// This script will assure the maximum height for the chat area is available, 
  // without being oversized for the user's display.
  
echo '
    <script type="text/javascript">
      document.write("<iframe height=")
      if (screen.availHeight > 750) {
        document.write(screen.availHeight - 365)
      }
      else {
        document.write(403);
      }
      document.write(\' width=100% marginheight=0 marginwidth=0 scrolling=auto frameBorder=0 src="'
.$boardurl.'/chat/index.php"></iframe>\');
    </script>'
;
}
?>




I hope those are helpful tips. 

TheListener

Daniel

Thanks for the tip. If I get round to placing all the hints and tips together then I will add yours.

HandsomeDan

Quote from: Frosted Flake on September 01, 2009, 06:18:51 PM
I changed the shoutbox & chat permissions and I'm still having trouble.  :'( My members can't log in.

I've got the same problem as Frosted Flake.  I've made it past the "You can't access the chat" error by moving my chat to a sub-domain.  I've 755'd the chat directory and the index.php file.  I do have Pretty URL's on with the Redirect code inserted into the .htaccess file.

It's almost like it's a local pc issue.  For instance, on my PC I'm running Firefox 3.5 (latest build) and it immediately takes me back to the forum after clicking "login".  IE8 works perfectly.

I switch over to linux where I'm running FireFox 3.0 and it works fine.

To make it even more confusing, I have users who are running Firefox 3.5 inside the chat room.

{shrugs shoulders}

weird.

kurosaki00

I installed the integration. I just want the chat. I check my ftp directory and is forum/chat
the button is pointing there, but it says nothing found for forum/chat
I checked the permissions and all.

any help plz

TheListener

Which forum version do you use?

In 2.0 which I use you go to Modifications> chat then untick the shoutbox.

GhostHunter


Is there a way to allow guests to participate in the chat? Currently they can view the chat but not participate, and TPTB have requested guest participation to be allowed.

TIA

Jim

TheListener

Quote from: GhostHunter on September 02, 2009, 07:03:15 PM

Is there a way to allow guests to participate in the chat? Currently they can view the chat but not participate, and TPTB have requested guest participation to be allowed.

TIA

Jim

Hi Jim

Guests can take part in chat. can I see your forum please.
Also which version of smf are you using?


ScottDB

My chat and shoutbox seem to be working ok. The only problem is that my log is getting cluttered by an error message every time someone uses the chat or shoutbox. Here is the error
Quote
                              Apply Filter: Only show the error messages of this URL                               http://newbiescentral.com/index.php?action=post2;board=8;preview;xml                                                     
                           Apply Filter: Only show the errors with the same message                            8: Undefined index:  chat                         
                           Apply Filter: Only show the errors from this file                                                           File: /home/scott/public_html/newbiescentral.com/Sources/Subs.php
                              Line: 3716                                                     
Any ideas?
Thank you,
Scott

If at first you don't succeed. post and post again.

danielwmoore

Quote from: ScottDB on September 03, 2009, 02:22:36 PM
My chat and shoutbox seem to be working ok. The only problem is that my log is getting cluttered by an error message every time someone uses the chat or shoutbox. Here is the error
QuoteUndefined index:  chat
File: /home/scott/public_html/newbiescentral.com/Sources/Subs.php
Line: 3716
Any ideas?

ScottDB,

When it says, "Undefined index: chat", that means there is an array that is being passed 'chat' as the index, and it doesn't exist.

This is most likely the culprit of another issue I found and fixed with this Mod, that I completely forgot to mention above. 

While this mod will set some language strings for the shoutbox, it does not do so for the chat.  Open up your Modifications.english.php in your Themes/default/language directory, (or Modifications.german.php, or whatever language you're needing this for), and add to the list:

$txt['chat'] = 'Chat';


This will be the text that appears on your menu button.  That's why it seems to fail pretty much every time someone displays a page.

Do that somewhere on a new line before the final '?>' in the file.

That will fix the problem.

AnnieT

In my admin panel when I go to set the permissions, the words don't show up next to the checkboxes so I don't know what the checkboxes do.



And my regular members are able to delete anybody's comments in the shoutbox and I don't know how to fix it :(

If someone can help, thank you very much! If it helps you at all, I'm using version 1.1.10

TheListener

Quote from: AnnieT on September 03, 2009, 11:54:24 PM
In my admin panel when I go to set the permissions, the words don't show up next to the checkboxes so I don't know what the checkboxes do.



And my regular members are able to delete anybody's comments in the shoutbox and I don't know how to fix it :(

If someone can help, thank you very much! If it helps you at all, I'm using version 1.1.10

Can I see a link to your forum please?


Are there any errors in your error log?

AnnieT

^ My forum is hxxp:jaejin.kyu.me/forums/ [nonactive]

In my error log, most of the errors are "Unable to load the 'Shout.english-utf8' language file."


TheListener

Anie can you pm a temp admin account please.

GhostHunter

Quote from: TheListener on September 02, 2009, 07:05:57 PM

Hi Jim

Guests can take part in chat. can I see your forum please.
Also which version of smf are you using?



Must be something broke in mine, then ... :)

Guests can view what is going on, but nothing they type is passed through. FWIW, I think that allowing Guest chatting is not a great idea, but I told them I would look into it. If it's a server side issue, I'm gonna drop it. Our host has his own issues, and I've already been an extreme pain is his posterior.

SMF version 1.1.10. We is here:

http://www.nebraskaghosts.org/smf/

Thanks,

-Jim

TheListener

Jim can you pm a temp admin account to me please and I will have a look for you when I am free.

GhostHunter

Quote from: TheListener on September 04, 2009, 12:49:14 AM
Jim can you pm a temp admin account to me please and I will have a look for you when I am free.

Will deal with that tomorrow night. It's past my bedtime. Thanks for your help.

Cheers,

-Jim

Advertisement: