• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ phpBB, Simple Machines Forum (SMF), and Forum Software (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

more phpBB integration

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
6 posts • Page 1 of 1

Postby Hopper » Thu Apr 19, 2007 8:38 pm

thanks to tribalx and alexy i was able to cook up (using their code) a way of fully integrating the chat into my phpBB site
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 -->
Last edited by Hopper on Thu Apr 19, 2007 8:46 pm, edited 1 time in total.
Hopper
New member
 
Posts: 4
Joined: Mon Apr 16, 2007 2:40 pm
Top

Postby phpfreechat » Thu Apr 19, 2007 9:16 pm

Be carfull with your code, each ajax call will call again and again this query :
mysql_query("SELECT field_with_username user_level_field FROM users_table_name where username='$dead'");

A better solution would be to save the query result in sessions.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby Hopper » Thu Apr 19, 2007 9:33 pm

well when it comes to php/ajax coding i am below rookie so i had to start with something and modify it.. it is a quick and dirty solution and at least works for now.. perhaps if someone is willing to say how to do that or modify that so it works better.. im open to suggestions (i am just learning still afterall)
Hopper
New member
 
Posts: 4
Joined: Mon Apr 16, 2007 2:40 pm
Top

Postby KDB9000 » Tue May 15, 2007 4:49 pm

I am trying to do the same thing but with a CMS called e107. I used your code and added my stuff in but it doesn't seem to work. I get a blank page. Did you have that problem?
KDB9000
Member
 
Posts: 13
Joined: Tue May 15, 2007 4:46 pm
Top

Postby cls » Sat Aug 18, 2007 11:28 pm

Here is a more simple solution:

To carry over admin privilegs from phpBB2, add the following to the code described in the faq:

Code: Select all
if ($userdata['user_level'] == ADMIN) { $params['isadmin'] = true; }

Be sure to add also:

Code: Select all
$params['frozen_nick'] = true;
cls
Member
 
Posts: 57
Joined: Sat Aug 18, 2007 10:29 pm
Location: Germany
  • Website
Top

Postby King Moonraiser » Fri Aug 24, 2007 1:50 am

cls wrote:Here is a more simple solution:

To carry over admin privilegs from phpBB2, add the following to the code described in the faq:

Code: Select all
if ($userdata['user_level'] == ADMIN) { $params['isadmin'] = true; }

Be sure to add also:

Code: Select all
$params['frozen_nick'] = true;


That's great!

Also, if you want MODs to be included:

Code: Select all
if ($userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD) $params['isadmin'] = true;
King Moonraiser
Member
 
Posts: 98
Joined: Fri Jun 22, 2007 9:42 pm
  • Website
Top


Post a reply
6 posts • Page 1 of 1

Return to phpBB, Simple Machines Forum (SMF), and Forum Software (v1.x)

Who is online

Users browsing this forum: No registered users and 4 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub