The chat is usable using the default configuration but a lot of options can be tweaked to customize the chat. For example, to change the refresh speed to 2 seconds, copy/paste this piece of code and run ”/rehash” command:
<?php require_once "src/phpfreechat.class.php"; // adjust to your own path $params["serverid"] = md5(__FILE__); $params["refresh_delay"] = 2000; // 2000ms = 2s $chat = new phpFreeChat($params); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>phpFreeChat demo</title> </head> <body> <?php $chat->printChat(); ?> </body> </html>
Another example: to set the initial nickname to “guest” (it can be useful when the chat is integrated into a portal or a forum which provides the login/password), copy/paste this piece of code:
<?php require_once "src/phpfreechat.class.php"; // adjust to your own path $params["serverid"] = md5(__FILE__); $params["nick"] = "guest"; // it can be useful to take nicks from a database $chat = new phpFreeChat($params); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>phpFreeChat demo</title> </head> <body> <?php $chat->printChat(); ?> </body> </html>
Thanks to these two examples, you should understand how to setup the chat using the parameters:
$params["param-name"] = "param-value";
As parameters are stored in a cache, be sure to run /rehash
command each time you change a parameter value.
Now have a look to the global parameters list and to the proxies parameters list.
Here is some recommendations about how to deploy and integrate the chat in an existing project. Following these recommendations will facilitate future chat upgrades.
Firstly, I suppose your Web server root directory is www/ (where all your existing project files are located). Then download and extract latest phpfreechat version in this directory, the directories hierarchy should have the look of this figure:
<?php require_once dirname(__FILE__).'/phpfreechat-1.0-beta8/src/phpfreechat.class.php'; // adjust to the correct path $params["serverid"] = md5(__FILE__); // used to identify the chat $chat = new phpFreeChat($params); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Chat</title> </head> <body> <?php $chat->printChat(); ?> </body> </html>