Difference between revisions of "PhpBB integration"
(→Customizing) |
m (Fixing the weird mess that happened by editing part of the page.) |
||
Line 8: | Line 8: | ||
INLINE, FIND | INLINE, FIND | ||
− | == | + | ============ |
− | + | &nbsp;<a href="{U_PROFILE}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="{L_PROFILE}" hspace="3" />{L_PROFILE}</a>&nbsp; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | < | + | INLINE, BEFORE ADD |
+ | ================== | ||
+ | &nbsp;<a href="mibbit.php" class="mainmenu" onclick="window.open('mibbit.php','mibbit','width=500,innerwidth=500,height=400,innerheight=400,location=0,menubar=0,scrollbars=0,status=0,toolbar=0');return false">IRC</a>&nbsp; | ||
+ | </pre></code> | ||
==mibbit.php== | ==mibbit.php== | ||
Line 91: | Line 86: | ||
If you add a new profile field or already have a MOD in your forum that allows you to use a valid IRC nickname, you may easily modify the nickname line: | If you add a new profile field or already have a MOD in your forum that allows you to use a valid IRC nickname, you may easily modify the nickname line: | ||
− | <code>$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : '';</code> | + | <code><nowiki>$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : '';</nowiki></code> |
To: | To: | ||
− | <code>$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : $userdata['irc_nickname'];</code> | + | <code><nowiki>$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : $userdata['irc_nickname'];</nowiki></code> |
Where <var>'irc_nickname'</var> is the name of the profile field. You may also switch things around if you prefer IRC nickname over the forum username: | Where <var>'irc_nickname'</var> is the name of the profile field. You may also switch things around if you prefer IRC nickname over the forum username: | ||
− | <code>$nickname = is_valid_nickname($userdata['irc_nickname']) ? $userdata['irc_nickname'] : $userdata['username'];</code> | + | <code><nowiki>$nickname = is_valid_nickname($userdata['irc_nickname']) ? $userdata['irc_nickname'] : $userdata['username'];</nowiki></code> |
Revision as of 21:27, 27 March 2008
This MOD for phpBB2 uses username as the nickname for the user. However a Guest nickname is used if the nickname contains characters that are not valid within IRC.
Editing templates/subSilver/overall_header.php
FIND
====
<td height="25" align="center" valign="top" nowrap="nowrap"><span class="mainmenu"> <a href="{U_PROFILE}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="{L_PROFILE}" hspace="3" />{L_PROFILE}</a> <a href="{U_PRIVATEMSGS}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_message.gif" width="12" height="13" border="0" alt="{PRIVATE_MESSAGE_INFO}" hspace="3" />{PRIVATE_MESSAGE_INFO}</a> <a href="{U_LOGIN_LOGOUT}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_login.gif" width="12" height="13" border="0" alt="{L_LOGIN_LOGOUT}" hspace="3" />{L_LOGIN_LOGOUT}</a> </span></td>
INLINE, FIND
============
<a href="{U_PROFILE}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_profile.gif" width="12" height="13" border="0" alt="{L_PROFILE}" hspace="3" />{L_PROFILE}</a>
INLINE, BEFORE ADD
==================
<a href="mibbit.php" class="mainmenu" onclick="window.open('mibbit.php','mibbit','width=500,innerwidth=500,height=400,innerheight=400,location=0,menubar=0,scrollbars=0,status=0,toolbar=0');return false">IRC</a>
mibbit.php
This file goes to the root of your phpBB installation. Remember to change the channel and server!
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
function is_valid_nickname($nickname)
{
if($nickname != '')
{
for($i = 0, $maxi = strlen($nickname); $i < $maxi; $i++)
{
$code = ord($nickname[$i]);
if( !(($i > 0 && ( $code == 45 || ($code >= 48 && $code <= 57) )) || ($code >= 65 && $code <= 125)) ) break;
}
return ($i == $maxi);
}
}
if($userdata['session_logged_in'])
{
$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : '';
}
else
{
$nickname = '';
}
if( !is_valid_nickname($nickname) )
{
$nickname = 'Guest_'.chr(mt_rand(65, 90)).chr(mt_rand(97, 122)).chr(mt_rand(97, 122));
}
$uri = 'http://embed.mibbit.com/?nick='.$nickname
.'&chatOutputShowTimes=true'
.'&server=irc.freenode.net:6667' // replace server and port with matching information
.'&channel=%23channel'; // replace channel with the name of your channel
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>IRC</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
html,body,object,iframe { border: 0; height: 100%; margin: 0; overflow: hidden; padding: 0; }
object,iframe { height: 100%; width: 100%; }
object html,object body,iframe html,iframe body { height : auto; }
</style>
</head>
<body>
<!--[if !IE]><!--><object data="<?php echo $uri; ?>"><!--<![endif]--><iframe src="<?php echo $uri; ?>" scrolling="no" frameborder="0"><h1><a href="<?php echo $uri; ?>">Open IRC channel</a></h1></iframe><!--[if !IE]>--></object><!--<![endif]-->
</body>
</html>
Customizing
If you add a new profile field or already have a MOD in your forum that allows you to use a valid IRC nickname, you may easily modify the nickname line:
$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : '';
To:
$nickname = is_valid_nickname($userdata['username']) ? $userdata['username'] : $userdata['irc_nickname'];
Where 'irc_nickname' is the name of the profile field. You may also switch things around if you prefer IRC nickname over the forum username:
$nickname = is_valid_nickname($userdata['irc_nickname']) ? $userdata['irc_nickname'] : $userdata['username'];