How to integrate phpfreechat in a dokuwiki page ?

This method is used on the demo page.

  1. You have to install the phpinclude dokuwiki plugin.
  2. You have to create a phpinclude/ directory in the root directory of your dokuwiki installation and a phpincludes/pfc-pub-data/ directory (public pfc data will be stored here).
  3. You have to create these two scripts :
    • phpinclude/pfc-front.php : this script will load the chat interface when the dokuwiki page is loaded.
    • phpinclude/pfc-backend.php : this script will be contacted by pfc-front.php using ajax call to communicate with the pfc server.
  4. Finally, in the desired dokuwiki page you have to insert this code:
    <phpinc=pfc-front.php>
  5. That's all.

pfc-front.php

Here is an example you should of course adapt to your needs:

<?php
 
global $USERINFO;
 
require_once dirname(__FILE__).'/../src/trunk/src/phpfreechat.class.php';
$params = array();
$params['serverid'] = 'pfc-dokuwiki';
$params['nick'] = isset($USERINFO['name']) && !empty($USERINFO['name']) ?
                    $USERINFO['name'] :
                    (isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : '');
$params['isadmin']  = isset($USERINFO['grps']) ?
                        in_array('Administrators',$USERINFO['grps']) || in_array('Moderators',$USERINFO['grps']) :
                        false;
$params['data_public_path']   = dirname(__FILE__).'/pfc-pub-data';
$params['data_public_url']    = 'phpincludes/pfc-pub-data';
$params['server_script_path'] = dirname(__FILE__).'/pfc-backend.php';
$params['server_script_url']  = 'phpincludes/pfc-backend.php';
 
// store in session the parameters list for the backend script
@session_start();
$_SESSION['demo_params_list'] = $params;
 
$pfc = new phpFreeChat($params);
$pfc->printChat();
 
?>

pfc-backend.php

<?php
 
// necessary to open the dokuwiki session
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/../');
require_once(DOKU_INC.'inc/init.php');
 
require_once dirname(__FILE__).'/../src/trunk/src/phpfreechat.class.php';
$plist = $_SESSION['demo_params_list'];
$chat = new phpFreeChat( $plist );
 
?>
Fork me on GitHub