PHP+AJAX chat

PHP+AJAX chat

by Genner Cerna -
Number of replies: 20
perhaps this could be a better chat system in moodle...

http://www.phpfreechat.net/demo.en.html
Average of ratings: -
In reply to Genner Cerna

Re: PHP+AJAX chat

by Gustavo Augusto Hennig -
I Liked this chat.
We could create a new chat module, as an alternative.

I will help you.
In reply to Gustavo Augusto Hennig

Re: PHP+AJAX chat

by Genner Cerna -
Better in what way?

  • AJAX technology is used to smoothly refresh (no flicker) and display the chat and nickname zone.
  • Messages and nicknames are stored into a simple filesystem, so that server resources are saved as much as possible.
  • Bandwidth is preserved because the server never transmits the same data twice, only new messages are transmitted.
  • No problems with firewalls
Drawbacks...
  • It doesn't require MySQL or any SQL database, messages and nicknames are simply stored in files.
In reply to Genner Cerna

Re: PHP+AJAX chat

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
  • AJAX technology is used to smoothly refresh (no flicker) and display the chat and nickname zone.

I have yet to come accross truly browser independent AJAX.of complex applications. For example the Google AJAX based tools (Docs and Spreadsheets) work with Firefox and IE but not with other browsers, same with Zoho office. However a minimalist approach to AJAX, i.e. just using it where it brings overwhealming benefit (e.g. the refresh you mention) might make sense.

  • Bandwidth is preserved because the server never transmits the same data twice, only new messages are transmitted.
AJAX can provide a performance benefit in that only new information is displayed in the browser rather than a total refresh of the contents.

  • No problems with firewalls
There seems to be no connection between the use of AJAX and firewalls. One of the benefits of the moodle chat approach is because it uses plain HTTP it will generally work through any firewall. If plain HTTP wont get through then generally the users won't be able to browser the web.


I don't mean to be overly negative, it is just that I have ten years of dissapointment and frustration with Javascript so I am very, very cautious when it is suggested and AJAX is a JavaScript based technology. Having said that I have switched to doing all my primary writing in the Google docs module and absolutely love the Google HTML chat system. Bear in mind that those Google folks are very, very smart. Ok OK so are the moodle folks (grins).

Marcus
In reply to Marcus Green

Re: PHP+AJAX chat

by Genner Cerna -
I totally agree with you about JavaScript is problematic. Ya, GOOGLE chat system is very impressive in developing such technology. What I like about GOOGLE chat system is the pop-up and sending of message (fast and efficient).

I believe GOOGLE uses HTML with AJAX technology on their chat system. (if im not wrong?)

I hope others can share better idea to better improve Moodle chat system. big grin (I'm being optimistic...)


In reply to Genner Cerna

Re: PHP+AJAX chat

by Genner Cerna -
http://www.x7chat.com

General Features
  • Skin support
  • Multilangauge support
  • Private Message Logging
  • Custom and predefined status messages
  • Offline Message support
  • Private Chats between two members
  • Full message styling, font, font size, font color, and font style
User Features
  • Full profile
  • Full settings panel
  • Ability to ignore users
  • User-level word filter -- Each user defines the words they want filtered
Room Features
  • Unlimited Number of Rooms
  • Password Protected Rooms
  • Public and Private Rooms
  • Moderated Rooms (Only voiced members can speak)
  • Message Logging
  • Room-level word filter -- Each user defines the words they want filtered
  • Ability to ban users from a specific room
  • Ability to define room specific auto-link words (keywords)
  • Operator, Voice and Mute list allows you to control who has what permissions in your room.
  • Chat room logging
  • Kicking and muting ability
Administrator Features
  • Invisibility
  • Ability to ban users by IP, E-Mail and Username.
  • Ability to ban for a certain time period or for forever
  • Live news from us informs you when new updates or fixes are released
  • Ability to mass-add smilies allows you to add tons of smilies at one time, quickly and easily.
  • Mass mail ability allows you to E-Mail all of your members
  • The Calender allows you to inform your members of group chats and other events
  • The log managers allows you to manage all aspects of the chat script's logging functions
  • The bandwidth panel allows you to limit that amount of bandwidth that each person can use each month.
  • The bandwidth panel also allows you to view the current bandwidth usage of each member
  • The room manager allows you to manage all the rooms on your server
  • The user manager allows you to manage all of your user accounts
  • The user group system makes editing permissions for groups of users incredibally easy
  • Full control of permissions for all aspects of the chat server
  • The word filter allows you to censor bad words
  • The theme manager allows you to edit and delete existing themes as well as install new ones or create your own
  • The settings panel allows you to modify all aspects of your chat server. Everything from the max number of characters in a username to the GD library is customizable
Integrates with ...
  • Invision Board 1.X
  • Invision Board 2.X
  • Mambo 4.5.X
  • MercuryBoard 1.1.X
  • PhpBB 2.0.X
  • PhpNuke 7.X
  • PostNuke 0.075
  • XMB 1.9
  • SMF 1.X
  • Xoops
  • YabbSE 1.5.X
NOTE: I don't want to replace the existing chat system but showing possibilities/ideas to better improve Moodle chat system.

In reply to Genner Cerna

Re: PHP+AJAX chat

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"I believe GOOGLE uses HTML with AJAX technology on their chat system. (if im not wrong?)"

I think you are right, but one of the interesting thing about the google system is not that they have used AJAX, but that they have been very careful about how much AJAX they use. Thus they seem to have leveraged the ability to do refresh without an entire HTTP round trip, but they have managed to keep the "client" very small and responsive.

One way of getting an idea of how good the Google chat is by firing up the msn web client

(http://webmessenger.msn.com)

I do use that web client, but it is overblown and clumsy by contrast with the minimalist efficiency of the Google tool.



In reply to Marcus Green

Re: PHP+AJAX chat

by Genner Cerna -
msn not but at all--- but.... for the chat to run see bellow...

  • A web browser: Microsoft Internet Explorer 5.0 or later, Netscape 7.1 or later, or Mozilla 1.6 or later, running in Microsoft Windows.
  • An Internet connection (56 Kbps or faster recommended)

In reply to Gustavo Augusto Hennig

Re: PHP+AJAX chat

by Lori Bakken -
Unless Moodle comes up with something better, I would be really interested in creating a new chat module with phpfreechat!


In reply to Lori Bakken

Re: PHP+AJAX chat

by Brian Lowe -

We really had trouble with moodle chat so I hacked together phpfreechat.  Here is what I did. Take it for what it is worth (which isn't much).  I did this about 6 months ago so I may be missing something.

moodle/mod/chat/phpchatfree/index.php

add to the top of the file (don't leave any spaces before or after <? ?>

<?php
require_once('../../../config.php');
$chatid = $_GET['id'];
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
if (!$chat = get_record('chat', 'id', $id)) {
error('Could not find that chat room!');
exit;
}

if (!$course = get_record('course', 'id', $chat->course)) {
error('Could not find the course this belongs to!');
exit;
}

/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) {
if (!$group = get_record('groups', 'id', $groupid)) {
error("That group (id $groupid) doesn't exist!");
}

$groupname = ': '.$group->name;
} else {
$groupname = ': '.get_string('allparticipants');
}

} else {
$groupid = 0;
$groupname = '';
}

$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
$userid=$USER->id; // Set the user id for Moodle
global $chatid, $userid, $groupid;
// END MOODLE - Don't leave any space between the php indicators below or you will receive xhmtl error
?>

Then in the params for phpfreechat in the same index.php file, add
$params["serverid"] = $_GET['id']; // use moodle id for chat
You can also make the $USER->firstname and $USER->lastname variable from moodle the user name in phpchatfree if you like.  Something like
$params["nick"] = $USER->firstname.' '.$USER->lastname;

It would be nice to add something that checks if the user entering the chat is an admin or teacher and adding "$params["isadmin"] = true;" if they are.  I am currently just hacking this by using an array $admin_users:

$admin_users[0]='Jane Doe';
$admin_users[1]='John Smith';
foreach ($admin_users as $value) {
  IF($value=="$USER->firstname $USER->lastname")
   $params["isadmin"] = true; // just for debug ;)
  }
}

----------------------------------------------------------------

in file moodle/mod/chat/phpchatfree/src/containers/file.class.php in the setMeta function below
// store the value in the memory cache
//@todo
// $this->_meta[$enc_type][$enc_subtype][$enc_key] = $value;

add the following so that it stores the messages in the moodle chat_messages table.

// MOODLE
 IF($group=='channelid-to-msg'){

 $pos1 = stripos($leafvalue,'send')+5;
 $moodleleafvalue = substr("$leafvalue", $pos1);
                $msg = &New stdClass;
                $msg->chatid    = $GLOBALS[chatid];
                $msg->userid    = $GLOBALS[userid];
                $msg->groupid   = $GLOBALS[groupid];
                $msg->system    = 0;
                //$msg->message   = addslashes($leafvalue); // have to undo the browser's encoding
                $msg->message   = addslashes($moodleleafvalue); // have to undo the browser's encoding

                $msg->timestamp = time();

                // Commit to DB
                insert_record('chat_messages', $msg, false);  // Moodle function
 }elseif($group=='nickid-to-metadata' && $leaf=='nick'){
          $msg = &New stdClass;
                $msg->chatid    = $GLOBALS[chatid];
                $msg->userid    = $GLOBALS[userid];
                $msg->groupid   = $GLOBALS[groupid];
                $msg->system    = 0;
                $msg->message   = 'enter';
                $msg->timestamp = time();

                // Commit to DB
                insert_record('chat_messages', $msg, false);

 }
//END MOODLE


--------------------------------------------------------------------

Lastly, in moodle/mod/chat/view.php look for
link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam","chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, get_string('modulename', 'chat'));

and comment it out and add it with

link_to_popup_window ("/mod/chat/phpchatfree/?id=$chat->id$groupparam","chat$course->id$chat->id$groupparam", "$strenterchat", 700, 700, get_string('modulename', 'chat'));

I think I included everything here.  This is a pretty bad hack but it will probably work ok if you need something quick. 

 

In reply to Brian Lowe

Re: PHP+AJAX chat

by Genner Cerna -
i already tried it with moodle and it works, authentication is in mysql. success download the final release it so easy to integrate
In reply to Genner Cerna

Re: PHP+AJAX chat

by Peter Richardson -
I have tried the hack that Brian described and got it to work in a test environment on my OS X machine using the MAMP install, but have not succeeded on my SUSE 9.2 Linux Server running MOODLE 1.8.2. I get a blank popup. If anyone has some suggestions, I would be most appreciative.

Thanks
In reply to Peter Richardson

Re: PHP+AJAX chat

by Chris Potter -
This is somewhat of an older thread, but I thought I would let it be known that I have put together a package that would allow for a separate install from the current chat (it's simply called 'newchat' in the backend) so as to not cause any conflict with the current chat module. We found this to be a great alternative so far (with the testing we've done), and plan to add this to our ITV and online arsenal for course use. The current chat is just too slow for our usage (and a resource hog). I'd like to put this up in the modules and plug-ins, but wanted to ask the author first (and perhaps ask for a review by someone who knows more about this stuff than me, I'm not an expert). Anyone interested?
In reply to Chris Potter

Re: PHP+AJAX chat

by Ever Boleh -
A new module will be great.

I am a novice when it comes to installation of Moodle but I just did it to prove a point! I can't program and I do not dare to tinkle with any codes etc. for fear that I might screw up the system.

My users face problems with the current chat (I have Moodle 1.84).

I tried Wiziq and found it good but for some reasons, I have not been able to log in after 7 pm my time (about 23:00 GMT).

I am looking at X7 Chat Lite at present to see if this will solve my problem.
In reply to Chris Potter

Re: PHP+AJAX chat

by Brian Lowe -

Hey Chris,

It would be great to have phpfreechat turned into a module.  I don't know what they plan to do with the chat in moodle but it is unusable for a large number of people so any alternative would be great.

Brian

In reply to Brian Lowe

Re: PHP+AJAX chat

by Owain Baglow -
This phpfreechat solution worked for me, but Brian there are is a error in the code you have shared here.

The line
if (!$chat = get_record('chat', 'id', $id)) {
should read
if (!$chat = get_record('chat', 'id', $chatid)) {
In reply to Genner Cerna

Ang: PHP+AJAX chat

by Anders Both -

Hello Moodle ajax chat thread.

I just came across this thread in a seach. I am devoloping an ajax chat system, that I believe is really good. Actually better than google html chat..

I would like very much to hear your comments and feedback about it .

There is a demo chat room here: www.basechat.com/demo1.aspx

I agree in what you write about using AJAX, its very effective but its really takes a lot of work to make it work perfect for all browsers. My system is not perfect, as it is not working for Opera.

Besides than you should be aware of server performarce even if you say AJAX does only send nessesary information, e.g. do not make a system that saves messages in files between sessions, use ram instead (and save message log to DB).

Best Regards.

Anders Both, Denmark - Germany.

www.basechat.com

In reply to Genner Cerna

Re: PHP+AJAX chat

by Carlos Alexandre Fonseca -
Picture of Plugin developers
A flash base chat could be very rich experience (with webcam, ppt presentation whiteboard ..)

I search a little and found 2 products that i think it´s not difficult to integrate with moodle
123flashchat
dimdim

The first i think that´s very easy to integrate, because has a phpnuke integration