|
Cookbook /
PHPFreeChatSummary: Integrate phpFreeChat (PFC) ajax chat into PmWiki
Version: 2007-07-09
Prerequisites:
Status: Young and ugly
Maintainer: lordmundi
Categories: Chat Integration
Questions answered by this recipe
DescriptionThis recipe will integrate a phpFreeChat instance into a wiki page for ajax based chat. NotesI am actually embarrassed at the state of this recipe. The only reason I decided to throw it up here is because I thought someone else with more pmwiki/php/ajax experience might be able to solve the problems I encountered that I ultimately had to hack through. More info in the comments at the bottom. But, I should add... it works! (my computer science teacher would hate to hear me say that). Right now it supports all of the chat room features and settings and also automatically sets the nickname based off of the Author/AuthId variable. If you aren't requiring or using the Author variable, you can just it let it grab "guest" nicknames for people and let them change them themselves. For a demo of phpfreechat, see http://www.phpfreechat.net/ Installation
ConfigurationNOTE: After changing anything in the config, you will need to "rehash" the config. This can be done by becoming an admin user, running the "/identify" command, and then issuing the "/rehash" command. Or, my personal favorite, just deleting everything in the "phpfreechat/data/private/" dir (make sure that "private" is still writable after you clean it out). More details about this on the phpfreechat website.
SDVA($pmwiki_PFC_params, array( 'nick' => "guest".rand(1,10000), 'title' => "$WikiTitle chat", 'serverid' => md5($pmwiki_PFC_Group) ));
A sample configuration of some parameters: $pmwiki_PFC_params = array( 'admins' => array( 'admin' => '', 'bob' => ''), 'max_msg' => 0, 'height' => "300px", ); Recommended UseSince you probably don't want users creating their chat rooms, you should probably lock down the markup to a specific page as I explained above. Also, phpfreechat is known to be pretty heavy on servers, so if you have a site with lots of traffic, you may want to investigate something else. Release Notes
CommentsQuite frankly... I hate this integration that I've done, but hopefully someone else will fix it up. It all started looking at the simple demos/examples on the phpfreechat site. They look extremely easy. Integrating it into pmwiki turned into a 2 week headache though. The main thing I wanted to do is create a markup to instantiate the chat box (this was easy enough) and have it use $Author or One problem is with sessions. After much searching, it looks like the sessions that PFC uses conflicts with the sessions for authuser. This is why I have to include it before authuser. And if I include it before authuser, I can't know the Another problem seems to be how late in the processing the script can go. Putting all of the recipe in the "Main.Chat.php" seemed to screw things up as well. So what am I so embarrassed about? Well, when you instantiate the phpfreechat class, the "nick" parameter is already set. You can see we are setting it to "guest" + a random number up above since we don't know the author name at that point. The nasty part is once we process the markup and are going to generate the javascript to place in the html to connect, I actually parse through the output before I return it to pmwiki and change the nickname to the author name. This is not only ugly, and wrong, but it also has disadvantages. Doing it this way doesn't let me use the "frozen_nick" option to keep people from changing their nick. So, this lets people set their nick to whatever they want. This also means you should set an admin password so people can't change to the admin chat user and do what they want. I would love to hear people's experiences with this. -- lordmundi July 10, 2007, at 12:43 AM FYI, here are some of the posts on the PFC forum that I posted, but didn't help me much:
See AlsoContributors |