MediaWiki in /www/wiki2/ directory
Apache config file: "Alias /wiki /var/www/wiki2/index.php"
phpFreeChat in /www/chat/ directory
New file: wiki2/extensions/SpecialChat.php
New file: wiki2/includes/SpecialChat.php
Add to file: wiki2/LocalSettings.php
require_once("extensions/SpecialChat.php");
That should be all. You can access now the new chat with [[Special:Chat]]
Also shows up in "Special pages"
Csaba Csoma
wiki2/extensions/SpecialChat.php
- Code: Select all
<?php
$wgExtensionFunctions[] = "wfExtensionSpecialChat";
function wfExtensionSpecialChat()
{
global $wgMessageCache;
$wgMessageCache->addMessages(array('chat' => 'My Chat'));
require_once('includes/SpecialPage.php');
SpecialPage::addPage(new SpecialPage('Chat'));
}
?>
wiki2/includes/SpecialChat.php
- Code: Select all
<?php
function wfSpecialChat()
{global $wgOut,$wgUser;
$wgCachePages=false;
$wgOut->setHTMLTitle('My Chat');
$wgOut->setPageTitle('My Chat');
if ($wgUser->mId<1) {
$wgOut->addHTML('You must <a href="/wiki2/index.php?title=Special:Userlogin&returnto=Special:Chat">log in</a> first<br>');
} else {
require_once "/www/chat/src/phpfreechat.class.php"; // adjust to your own path
$params = array("title" => "",
"max_msg" => 21,
"nick" => $wgUser->mRealName,
"openlinknewwindow" => true,
"showsmileys" => false,
"channels" => array("Public room"),
"nickmarker" => true,
"serverid" => md5(__FILE__),
"btn_sh_smileys" => true,
'server_script_path' => '/www/chat/ajax.php',
'server_script_url' => '/www/chat/ajax.php',
);
$chat = new phpFreeChat($params);
$wgOut->addScript( $chat->printJavascript(true) );
$wgOut->addScript( $chat->printStyle(true) );
$wgOut->addHTML( $chat->printChat(true) );
}
}
?>
chat/ajax.ph
- Code: Select all
<?php
if (!$_GET['q'])
$params = $_GET; // Only need to fetch query string after initial request
// Explode channels into an array of strings
$params['channels'] = explode(',', $params['channels']);
$params['serverid'] = md5(__FILE__);
require_once("src/phpfreechat.class.php");
$chat = new phpFreeChat($params);
?>