now usernames and admin privs carry over to the chat and unregisterd users of the phpBB site cant use the chat
place the following code in the index.php file for the chat
- Code: Select all
define('IN_PHPBB', true);
$phpbb_root_path = '../forumroot' //Root to phpBB
$chat_root_phpbbrealtive_path = '../chatroott/'; //Root to chat relative to phpBB root ;)
include( $phpbb_root_path . 'extension.inc' );
include( $phpbb_root_path . 'common.' . $phpEx );
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
if ( !$userdata['session_logged_in'] ) //redirect to phpBB logon page if the user is not logged in
{
redirect(append_sid($phpbb_root_path . "login.$phpEx?redirect=" . $chat_root_phpbbrealtive_path . "index.$phpEx", true));
}
//
//classique phpfreechat parameter list
//
$params["serverid"] = md5(__FILE__);
$params["nick"] = iconv("windows-1251", "UTF-8", $userdata[username]);
$dead=iconv("windows-1251", "UTF-8", $userdata[username]);
//require_once dirname(__FILE__)."/src/phpfreechat.class.php";
//$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$user = "databaseusername";//username
$pass = "dbpassword";//password
$host = "db.ip.or.hostname";//ussaly localhost
$db = "databasename";//database
mysql_connect($host,$user,$pass)or die ("error"); // the connection
mysql_select_db($db); // select your db
$select = mysql_query("SELECT field_with_username user_level_field FROM users_table_name where username='$dead'");
while ($name = mysql_fetch_assoc($select)) {
$nick = $name['username']; // now the username is located in $nick
IF ($name['user_level_field'] == 'value_for_admin')
$params["isadmin"] = true;
else
$params["isadmin"] = false;
}
some values given are generic and must be replaced with specific values
in addition to that, change the frozen_nick to true and delete the admins array and disable the /identify command and your set
to complete the integration, put the following somewhere in the main menu section of your overall_header.tpl for phpBB
- Code: Select all
<!-- BEGIN switch_user_logged_in -->
<a href="../chatroot/index.php" class="mainmenu"><img src="templates/whatevertemplate/images/icon_mini_message.gif" width="12" height="13" border="0" alt="Chat Room" hspace="3" />Chat Room</a>
<!-- END switch_user_logged_in -->