[cpg1.4.x]: PHPBB3 bridge [cpg1.4.x]: PHPBB3 bridge
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[cpg1.4.x]: PHPBB3 bridge

Started by Nibbler, July 04, 2008, 07:37:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nibbler

Supported phpbb3 bridge file attached. Download, extract, upload into the bridge folder. Then edit bridgemgr.php and add in the details for it as follows

Find


// define the var array


After that, add:


$default_bridge_data['phpbb3'] = array(
  'full_name' => 'phpBB version 3',
  'short_name' => 'phpbb3',
  'support_url' => 'http://www.phpbb.com/',
  'full_forum_url_default' => 'http://www.yoursite.com/board',
  'full_forum_url_used' => 'mandatory,not_empty,no_trailing_slash',
  'relative_path_to_config_file_default' => '../board/',
  'relative_path_to_config_file_used' => 'lookfor,config.php',
  'use_post_based_groups_default' => '0',
  'use_post_based_groups_used' => 'radio,1,0',
   'cookie_prefix_default' => '',
   'cookie_prefix_used' => 'cookie',
);


If you want to enable logout redirection it seems you need to hack phpbb to support this. This step is optional.

edit the phpbb file ucp.php

find:


meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));

$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
   
      
change to :


meta_refresh(3, request_var('redirect', append_sid("{$phpbb_root_path}index.$phpEx")));

$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . request_var('redirect', append_sid("{$phpbb_root_path}index.$phpEx")) . '">', '</a> ');


That tells phpbb to look for the redirect parameter being passed in the url.

After that, install the bridge using the bridge manager.

Feedback welcome, especially since I don't use phpbb myself. If you have issues please remember to provide all the requested information.

Note: This bridge file only works 'out of the box' for new installs of phpbb3. If your forum has been upgraded from phpbb2 then you need to make this code change below.

Edit phpbb3.inc.php, find


$this->admingroups = array(5);


Change the 5 to the admin group in phpbb3. You can find this out by doing the following

Quote
Go to your forum, log into AdminCP; click on the tab "Users and Groups" and go to "Manage groups". you'll see all your forum groups now and next to them 3 links (Settings/Members/Delete); click on "Settings" next to the group you want to give portal admin permissions. now take a look at the address line, which should similarly to this:

http://yourdomain.com/phpbb3/adm/index.php?i=groups&sid=[randomnumbersandletters]&icat=12&mode=manage&action=edit&g=64

In our example above, the group's ID is 64;

rphMedia

Just FYI Nibbler, I can't get yours to work. I've had a (hack) bridge in place for phpBB3 since Feb 2007 and it's worked flawlessly.

Can't login at all. Takes me to the forum (logged in), but upon returning to the gallery, still have login option.

Disabled the bridge via the database, still can't login. I get the CPG login screen, but it takes me to the gallery home and still have the login option. Totally lost here as I have the bridging disabled ??

Deleted all cookies, same thing. I have no core-code mods.

Am I missing something?



(I've since enabled the previous hack and I'm back to our original).

rphMedia

OK, this has nothing to do with your bridge file. I'm trying to hunt the problem down.

fornit

Hi,

I've just taken a look into phpbb3.inc.php

Well ... to be honest, I'm not really sure whether everything has been considered.

Are you aware that there are three types of cookies in phpBB3 with respect to session management ("_sid", "_u" and "_k") cookies?

Are you also aware that there is a parameter named "session_length" in phpBB3 which limits the validity of session?

And are you aware that "user_level" is an attribute which has existed in the user table of phpbb2 but doesn't exist in phpbb3 any more?


These are only a few points after having a very quick look ...

Kind reagrds
fornit

Nibbler

No, since I don't use PHPBB. That's the point of releasing the file and getting feedback. I will look into these things.

Raven24

The thing I can say about this bridge is that at least the ids from the user galleries are correctly matched with the usernames from the phpBB DB.
But as mentioned before login, etc. doesn't work... but thank you for working on a bridge!

mathias.frei

If i upload this Mod, i have follow Error-Message:

QuoteFatal error: Cannot redeclare cpggetmicrotime() (previously declared in /home/www/web373/html/pa-po/gallery/include/init.inc.php:35) in /home/www/web373/html/pa-po/gallery/include/init.inc.php on line 33

Is there a solution for this problem?

Nibbler

You probably put the wrong path in 'relative path to your BBS' and pointed back to Coppermine instead of phpbb.

mathias.frei

The transmission works well, it was the relative path. Now I can log in the forum, but in the gallery, I am not logged in. The Cookies has the same name and the Path is the same.

Nibbler

#9
There's a typo in the bridge file.

$session_id = addslashes($_COOKIE[$this->cookie_name . '_sid']);

That should be

$this->session_id = addslashes($_COOKIE[$this->cookie_name . '_sid']);

*Now fixed in the version posted*

Dogbot

Many thanks Nibbler for releasing this bridge file for phpbb/coppermine users.

I found some code elsewhere here on the site for autocreating albums, here it is..do you think this will work with your bridge file or do you know a better way of doing it.



function authenticate()
        {
                global $USER_DATA, $CONFIG;

                if (!($auth = $this->session_extraction()) && !($auth = $this->cookie_extraction())) {
                        $this->load_guest_data();
                } else {
                        list ($id, $cookie_pass) = $auth;
                        $f = $this->field;

                        if (isset($this->usergroupstable)){
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password,

ug.{$f['usertbl_group_id']} AS group_id ".
                                           "FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug ".
                                           "WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='$id'";
                        } else {
                                $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password,

u.{$f['usertbl_group_id']}+100 AS group_id ".
                                           "FROM {$this->usertable} AS u INNER JOIN {$this->groupstable} AS g ON

u.{$f['usertbl_group_id']}=g.{$f['grouptbl_group_id']} ".
                                           "WHERE u.{$f['user_id']}='$id'";
                        }

                        $result = cpg_db_query($sql, $this->link_id);

                        if (mysql_num_rows($result)){
                                $row = mysql_fetch_assoc($result);
                                mysql_free_result($result);

                                $db_pass = $this->udb_hash_db($row['password']);
                                if ($db_pass === $cookie_pass) {
                                        $this->load_user_data($row);
                                } else {
                                        $this->load_guest_data();
                                }
                        } else {
                                $this->load_guest_data();
                        }
                }

                $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';

        $USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup));

                if ($this->use_post_based_groups){
                        $USER_DATA['has_admin_access'] = (in_array($USER_DATA['groups'][0] - 100,$this->admingroups)) ? 1 : 0;
                } else {
                        $USER_DATA['has_admin_access'] = ($USER_DATA['groups'][0] == 1) ? 1 : 0;
                }

                $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'];

                // avoids a template error
                if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0;

                // For error checking
                $CONFIG['TABLE_USERS'] = '**ERROR**';


                define('USER_ID', $USER_DATA['user_id']);
        define('USER_NAME', addslashes($USER_DATA['user_name']));
        define('USER_GROUP', $USER_DATA['group_name']);
        define('USER_GROUP_SET', $user_group_set);
        define('USER_IS_ADMIN', $USER_DATA['has_admin_access']);
        define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
        define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
        define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
        define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
        define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
        define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
        define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
        define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
        define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);

        //Autocreating albums
        if($USER_DATA['user_id'] != 0)
        {
                $cid = 10000 + $USER_DATA['user_id'];
                $sql = "SELECT aid FROM cpg14x_albums WHERE category = " . $cid;
                $result = cpg_db_query($sql);
                if(mysql_num_rows($result) == 0)
                {
                        $sql = "INSERT INTO cpg14x_albums (category, title, uploads, pos) VALUES ('$cid', 'My Album', 'NO',  '1')";
                        cpg_db_query($sql);
                }
                mysql_free_result($result);
        }
                $this->session_update();
        }


Many thanks once again !

Dogbot.

Joachim Müller

Do not clutter this thread with unrelated stuff - start a thread of your own instead on the regular support board, providing the needed details there.

mathias.frei

Quote from: Nibbler on July 16, 2008, 04:18:06 PM
There's a typo in the bridge file. (...)

Thank you very much. The bridge works properly.

Raven24

Yes, works here too! Thank you VERY much!

simplysnaps

I have just installed this and when I click login in coppermine it takes me to the phpbb3 login page, I then login which works fine but when I go back to the gallery I'm not logged in and of course clicking the login option takes me to the phpbb3 page where I am logged in?

help please

Nibbler


simplysnaps

apologies for that being harrassed and missed the two obvious things

1) post correct info when asking for help

2) remember to get the cookie prefix correct or the gallery wont find the cookie that says you are logged in :-)

all working now  ;D

Imaboyo

I am having some problems trying to get this bridge completely working. My phpBB database is a conversion from the 2.x series and I think this might be having an effect on the bridge. I am using phpBB 3.0.2 and coppermine 1.4.18. I have already had to modify the bridge slightly to make me recognised as an administrator. The admin group was hard coded as 5 (line 112) where this is very much different in a converted board.

The gallery recognises that I am logged in, both with admin accounts and standard user accounts. When I visit the groups tab while logged in as admin the bridge fails to import the groups from phpbb so I am unable to apply permissions to any usergroups. Only the four default coppermine groups are displayed (Admin, Registered, Guests & Banned).

Can anyone suggest something I can do to try and fix this?

Nibbler

Did you enable 'post based groups' when you activated the bridge?

rphMedia

FWIW, I'm having the exact same problem (yes on Post-based groups)