Step 1: Copy the existing "phpbb2" theme to a "myphpbb2" directory.
This just copies the phpfreechat's phpbb smilies to the new theme.
Step 2: Add this new file, "customize.js.php" to the theme:
- Code: Select all
pfcClient.prototype.buildNickItem = function(nickid)
{
var nick = this.getUserMeta(nickid, 'nick');
var isadmin = this.getUserMeta(nickid, 'isadmin');
if (isadmin == '') isadmin = false;
var gender = this.getUserMeta(nickid, 'gender');
if (! gender > 0) gender = 0;
var li = document.createElement('li');
var a = document.createElement('a');
a.setAttribute('href','#');
a.pfc_nick = nick;
a.pfc_nickid = nickid;
a.onclick = function(evt){
var d = pfc.getNickWhoisBox(this.pfc_nickid);
document.body.appendChild(d);
d.style.display = 'block';
d.style.zIndex = '400';
d.style.position = 'absolute';
d.style.left = (mousePosX(evt)-7)+'px';
d.style.top = (mousePosY(evt)-7)+'px';
return false;
}
li.appendChild(a);
var img = document.createElement('img');
if (isadmin)
img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
else
if (gender != 2) // check for gender - undefined = 0, male = 1, female = 2
img.setAttribute('src', this.res.getFileUrl('images/user.gif'));
else
img.setAttribute('src', this.res.getFileUrl('images/user_female.gif'));
img.style.marginRight = '5px';
if (is_ie)
img.setAttribute('className', 'pfc_nickbutton'); // for IE
else
img.setAttribute('class', 'pfc_nickbutton');
a.appendChild(img);
// nobr is not xhtml valid but it's a workeround
// for IE which doesn't support 'white-space: pre' css rule
var nobr = document.createElement('nobr');
var span = document.createElement('span');
if (is_ie)
span.setAttribute('className', 'pfc_nickmarker pfc_nick_'+nickid); // for IE
else
span.setAttribute('class', 'pfc_nickmarker pfc_nick_'+nickid);
span.appendChild(document.createTextNode(nick));
nobr.appendChild(span);
a.appendChild(nobr);
return li;
}
pfcClient.prototype.updateNickWhoisBox = function(nickid)
{
var usermeta = this.getAllUserMeta(nickid);
var div = document.createElement('div');
if (is_ie)
div.setAttribute('className', 'pfc_nickwhois'); // for IE
else
div.setAttribute('class', 'pfc_nickwhois');
var p = document.createElement('p');
if (is_ie)
p.setAttribute('className', 'pfc_nickwhois_header'); // for IE
else
p.setAttribute('class', 'pfc_nickwhois_header');
div.appendChild(p);
// add the close button
var img = document.createElement('img');
if (is_ie)
img.setAttribute('className', 'pfc_nickwhois_close'); // for IE
else
img.setAttribute('class', 'pfc_nickwhois_close');
img.pfc_parent = div;
img.onclick = function(evt){
this.pfc_parent.style.display = 'none';
return false;
}
img.setAttribute('src', this.res.getFileUrl('images/close-whoisbox.gif'));
img.alt = this.res.getLabel('Close');
p.appendChild(img);
p.appendChild(document.createTextNode(usermeta['nick'])); // append the nickname text in the title
// add the whois information table
var table = document.createElement('table');
var tbody = document.createElement('tbody');
table.appendChild(tbody);
var um_keys = usermeta.keys();
var msg = '';
for (var i=0; i<um_keys.length; i++)
{
var k = um_keys[i];
var v = usermeta[k];
if (v && k != 'nickid'
&& k != 'nick' // useless because it is displayed in the box title
&& k != 'isadmin' // useless because of the gold shield icon
&& k != 'floodtime'
&& k != 'flood_nbmsg'
&& k != 'flood_nbchar'
&& k != 'gender'
&& k != 'avatar'
&& k != 'custom_title'
&& k != 'user_flag'
&& k != 'age'
)
{
var tr = document.createElement('tr');
var td1 = document.createElement('td');
if (is_ie)
td1.setAttribute('className', 'pfc_nickwhois_c1'); // for IE
else
td1.setAttribute('class', 'pfc_nickwhois_c1');
var td2 = document.createElement('td');
if (is_ie)
td2.setAttribute('className', 'pfc_nickwhois_c2'); // for IE
else
td2.setAttribute('class', 'pfc_nickwhois_c2');
td1.appendChild(document.createTextNode(k+':'));
td2.appendChild(document.createTextNode(v));
tr.appendChild(td1);
tr.appendChild(td2);
tbody.appendChild(tr);
}
}
div.appendChild(table);
// append the avatar image
if (this.getUserMeta(nickid,'avatar'))
{
var img = document.createElement('img');
img.setAttribute('src',this.getUserMeta(nickid,'avatar'));
if (is_ie)
img.setAttribute('className', 'pfc_nickwhois_avatar'); // for IE
else
img.setAttribute('class', 'pfc_nickwhois_avatar');
div.appendChild(img);
}
// append the custom title
if (this.getUserMeta(nickid,'custom_title'))
{
var p = document.createElement('p');
if (is_ie)
p.setAttribute('className', 'pfc_nickwhois_custom_title'); // for IE
else
p.setAttribute('class', 'pfc_nickwhois_custom_title');
p.appendChild(document.createTextNode(this.getUserMeta(nickid,'custom_title'))); // append the custom title text
div.appendChild(p);
}
var div_flag_and_age = document.createElement('div');
if (is_ie)
div_flag_and_age.setAttribute('className', 'pfc_nickwhois_flag_and_age'); // for IE
else
div_flag_and_age.setAttribute('class', 'pfc_nickwhois_flag_and_age');
// append the flag image
if (this.getUserMeta(nickid,'user_flag'))
{
var img = document.createElement('img');
img.setAttribute('src',this.getUserMeta(nickid,'user_flag'));
if (is_ie)
img.setAttribute('className', 'pfc_nickwhois_user_flag'); // for IE
else
img.setAttribute('class', 'pfc_nickwhois_user_flag');
div_flag_and_age.appendChild(img);
}
// append the age
if (this.getUserMeta(nickid,'age'))
{
var p = document.createElement('p');
if (is_ie)
p.setAttribute('className', 'pfc_nickwhois_age'); // for IE
else
p.setAttribute('class', 'pfc_nickwhois_age');
p.appendChild(document.createTextNode('Age: ' + this.getUserMeta(nickid,'age').toString())); // append the age
div_flag_and_age.appendChild(p);
}
if (this.getUserMeta(nickid,'user_flag') || this.getUserMeta(nickid,'age'))
div.appendChild(div_flag_and_age);
// add the privmsg link (do not add it if this button is yourself)
if (pfc.getUserMeta(nickid,'nick') != this.nickname)
{
var p = document.createElement('p');
if (is_ie)
p.setAttribute('className', 'pfc_nickwhois_pv'); // for IE
else
p.setAttribute('class', 'pfc_nickwhois_pv');
var a = document.createElement('a');
a.setAttribute('href', '');
a.pfc_nickid = nickid;
a.pfc_parent = div;
a.onclick = function(evt){
var nick = pfc.getUserMeta(this.pfc_nickid,'nick');
pfc.sendRequest('/privmsg "'+nick+'"');
this.pfc_parent.style.display = 'none';
return false;
}
var img = document.createElement('img');
img.setAttribute('src', this.res.getFileUrl('images/openpv.gif'));
img.alt = document.createTextNode(this.res.getLabel('Private message'));
a.appendChild(img);
a.appendChild(document.createTextNode(this.res.getLabel('Private message')));
p.appendChild(a);
div.appendChild(p);
}
this.nickwhoisbox[nickid] = div;
}
Step 3: Add this new file, "style.css.php" to the theme:
- Code: Select all
div.pfc_nickwhois {
width: 150px;
}
img.pfc_nickwhois_avatar {
margin: 0 auto 0 auto;
padding: 0 10px 0 10px;
display: block;
}
p.pfc_nickwhois_custom_title {
margin: 0 auto 0 auto;
padding: 0 10px 0 10px;
width: auto;
font-size: 8pt;
display: table;
}
div.pfc_nickwhois_flag_and_age {
margin: 10px auto;
display: block;
vertical-align: middle;
text-align: center;
}
img.pfc_nickwhois_user_flag {
padding: 0 10px;
display: inline;
vertical-align: middle;
}
p.pfc_nickwhois_age {
margin: 10px auto;
padding: 0 10px;
width: auto;
font-size: 8pt;
vertical-align: middle;
display: inline;
}
p.pfc_nickwhois_pv {
margin: 0 auto 10px auto;
padding: 0 10px 0 10px;
}
Step 4: Movie the cookie location in the phpBB administrator.
In phpBB, log in as administrator, go to "General Admin," "Configuration," scroll down to "Cookie Settings." Change the cookie path to "/". You may need to delete all of your cookies to ensure the change registers in your browser.
Step 5: Replace the index.php file for PHPFREECHAT.
I came up with this replacement to the standard index.php file that comes with phpfreechat. You need to modify the $phpbb_folder_name and $phpfreechat_folder_name variables to reflect your actual directory names for phpbb and phpfreechat. Also, edit the title, channel name(s), and any censored words you wish to block.
I designed it to use the subSilver CSS file. Feel free to experiment with your forum's own CSS file. Sorry, I don't know how to get the page to use whatever template stylesheet the user has in their control panel settings.
- Code: Select all
<?php
Header("Cache-control: private, no-cache");
Header("Expires: Mon, 26 Jun 1997 05:00:00 GMT");
Header("Pragma: no-cache");
define('IN_PHPBB', true);
$phpbb_folder_name = 'phpbb';
$phpfreechat_folder_name = 'phpfreechat';
$phpbb_root_path = '../'.$phpbb_folder_name.'/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
function pfc_user_age($birthday)
{
$this_year = create_date( 'Y', time(), -5 );
$this_date = create_date( 'md', time(), -5 );
if ( $birthday != 999999 )
{
$poster_birthdate = realdate('md', $birthday);
$poster_age = $this_year - realdate ('Y', $birthday);
if ($this_date < $poster_birthdate) $poster_age--;
}
else
$poster_age = NULL;
return $poster_age;
}
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params = array();
$params["title"] = "phpBB Forum Chat";
$params["serverid"] = md5("phpfreechat"); // calculate a unique id for this chat
$params["channels"] = array("General");
$params["language"] = "en_US";
//$params["nick"] = iconv("iso-8859-1", "UTF-8", $userdata[username]);
$params["nick"] = iconv("windows-1251", "UTF-8", $userdata[username]);
$params["theme"] = "myphpbb2";
$params["admins"] = array();
$params["frozen_nick"] = true;
$params["isadmin"] = false;
$params["max_msg"] = 150;
$params["max_nick_len"] = 30;
$params["timeout"] = 60000;
$params["nickmeta"] = array("avatar" => $userdata['user_avatar'] != NULL ? $phpbb_root_path . "images/avatars/" . $userdata['user_avatar'] : NULL,
"custom_title" => $userdata['user_custom_title'],
"user_flag" => $userdata['user_from_flag'] != "blank.gif" ? $phpbb_root_path . "images/flags/" . $userdata['user_from_flag'] : NULL,
"age" => pfc_user_age($userdata['user_birthday']),
"gender" => $userdata['user_gender']);
if ($userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD) $params['isadmin'] = true;
//$params["isadmin"] = true; // just for debug ;)
//$params["debug"] = true;
$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 xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<title>
<?php echo($board_config['sitename']); ?> :: Chat
</title>
<?php $chat->printJavascript(); ?>
<?php $chat->printStyle(); ?>
<link rel="stylesheet" href="<?php echo($phpbb_root_path . 'templates/subSilver/subSilver.css'); ?>"
type="text/css" />
<style type="text/css">
#pfc_minmax { display: none; }
a:link, a:visited, a:hover {
font-weight: bold;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.nospace { word-spacing: -0.35em; }
div.content {
margin-top: 5px;
margin-bottom: 4px;
padding: 1em;
margin-left: 6px;
margin-right: 6px;
background-color: #FFF;
border: 2px #006699 solid;
min-height: 40em;
font-family: Verdana, Sans-Serif;
font-size: 100%;
}
div.content * { margin-top: 0.5em; margin-bottom: 0.5em; }
div.content a img { border: none; }
div.content h2 { border-bottom: 1px #444 solid; }
div.content h3 { text-decoration: underline; font-size: 100%; margin: 1em 0 1em 0; }
div.content a:link, div.content a:visited, div.content a:hover { color: #0081ac; }
div.content a:visited { color: #ac0011; }
div.content code { background-color: #EFE; border: 1px #444 dotted; }
div.content pre { padding: 1em; background-color: #f3fce5; border: 1px #444 dotted; }
div.content ul { margin-left: 3em; }
div.content ol { margin-left: 3em; }
div.content dd { margin-left: 3em; }
div.content dt { font-weight: bold; margin: 2em 0 2em 0; }
div.content .abstract { border: 2px #999 solid; background-color: #EEE; padding: 1em; color: #000; text-align: justify; }
</style>
</head>
<body>
<?php
if($userdata['session_logged_in'])
{
echo('<span class="gen">');
echo('Hi '.$userdata['username'].'! <a href="'.$phpbb_root_path.'login.php?logout=true&sid='.$userdata['session_id'].'&redirect=..%2F'.$phpfreechat_folder_name.'%2F'.'">Logout</a>');
echo('</span><br />');
?>
<div class="content">
<?php $chat->printChat(); ?>
<p>
Tips:
</p>
<ul>
<li>
To open a <strong>private chat</strong>, click on
the nickname in the right column (user list).
</li>
<li>
To <strong>join a channel</strong>, type this
text in the input box : <code>/join yourchannelname</code>
(replace yourchannelname by what your want)
</li>
<li>
To listen <strong>sound notification</strong>,
put your chat window in the background and wait
for someone post a message.
</li>
</ul>
</div>
<?php
}
else
{
?>
<span class="gen">Hi Guest!</span><br />
<form action="<?php echo($phpbb_root_path); ?>login.php" method="post" enctype="multipart/form-data">
<table width="400" cellpadding="4" cellspacing="1" border=
"0" class="forumline" align="center" summary="Login Box">
<tr>
<th height="25" class="thHead" nowrap="nowrap">
Please enter your username and password to log in.
</th>
</tr>
<tr>
<td class="row1">
<table border="0" cellpadding="3" cellspacing="1"
width="100%" summary="">
<tr>
<td colspan="2" align="center">
</td>
</tr>
<tr>
<td width="35%" align="right">
<span class="gen">Username:</span>
</td>
<td>
<input type="text" name="username" size="25"
maxlength="40" value="" />
</td>
</tr>
<tr>
<td align="right">
<span class="gen">Password:</span>
</td>
<td>
<input type="password" name="password" size=
"25" maxlength="32" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<span class="gen">Log me on automatically each
visit: <input type="checkbox" name="autologin"
value="ON" /></span>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="hidden" name="redirect" value=
"../<?php echo($phpfreechat_folder_name); ?>/index.php" /><input type="submit"
name="login" class="mainoption" value=
"Log in" />
</td>
</tr>
<tr align="center">
<td colspan="2">
<span class="gensmall"><a href=
"<?php echo($phpbb_root_path.'profile.'.$phpEx.'?mode=sendpassword'); ?>"
class="gensmall">I forgot my password</a>
::
<a href=
"<?php echo($phpbb_root_path.'profile.'.$phpEx.'?mode=register'); ?>"
class="gensmall"><?php echo $lang['Register']; ?></a>
</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>
Step 6: (Optional) Show users online in phpBB
Edit your template overall_header.tpl:
- Code: Select all
<td height="25" align="center" valign="top" nowrap="nowrap"><span class="mainmenu"><a href="{U_PROFILE}" class="mainmenu">{L_PROFILE}</a> :: <a href="{U_PRIVATEMSGS}" class="mainmenu">{PRIVATE_MESSAGE_INFO}</a> :: <a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a></span></td>
</tr>
</table>
<!-- Start add - phpfreechat MOD -->
<table cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="row1" align="center"><span class="gensmall"><a href="/phpfreechat" class="mainmenu">{TOTAL_USERS_ONCHAT}{USERS_ONCHAT}</span></td>
</tr>
</table>
<!-- End add - phpfreechat MOD -->
and edit your includes/page_header.php:
- Code: Select all
// Start - phpfreechat mod init
require_once $phpbb_root_path."../phpfreechat/src/pfcinfo.class.php";
$phpfreechat_info = new pfcInfo( md5("phpfreechat") );
// NULL is used to get all the connected users, but you can specify
// a channel name to get only the connected user on a specific channel
$phpfreechat_users = $phpfreechat_info->getOnlineNick(NULL);
$phpfreechat_nb_users = count($phpfreechat_users);
$phpfreechat_users_csv = "";
foreach($phpfreechat_users as $u)
{
$u = ereg_replace("[[:space:]]", " ", $u);
$phpfreechat_users_csv .= $u.", ";
}
if ($phpfreechat_nb_users > 1)
{
$phpfreechat_users_csv = substr($phpfreechat_users_csv, 0, -2);
$phpfreechat_info = "There are <strong>".$phpfreechat_nb_users."</strong> users in chat right now: ";
}
else if ($phpfreechat_nb_users == 1)
{
$phpfreechat_users_csv = substr($phpfreechat_users_csv, 0, -2);
$phpfreechat_info = "There is <strong>1</strong> user in chat right now: ";
}
else
{
$phpfreechat_info = "There are no users in chat right now.";
}
// End - phpfreechat mod init