Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Building a Bridge for gallery app, help please

vrijvlindervrijvlinder Papillon-Sauvage MVP

I am trying to build a bridge for a coppermine gallery app, I want to be able to use the gallery logged into vanilla etc..
The app I am using does not have a bridge for vanilla specifically but one can hack other ones like phpbb.

I have modified an existing phpbb , I am missing some info I am not sure is correct with regards to setting up the cookie prefix . I did not post all of it, the rest is just table stuff. I just need to know if this is the correct setting to bridge coppermine app with vanilla. In the admin for the app it asks for cookie name but that is confusing when there are so many cookies involved...

Thanks !


if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

if (isset($bridge_lookup)) {
    $default_bridge_data[$bridge_lookup] = array(
        'full_name' => 'Vanilla version 2.0.18.4',
        'short_name' => 'Vanilla',
        'support_url' => 'http://www.vanilla.org/',
        'full_forum_url_default' => 'http://www.mydatabass.com/Forum',
        'full_forum_url_used' => 'http://www.mydatabass.com',
        'relative_path_to_config_file_default' => '../Forum/',
        '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' => 'SALT',
        'cookie_prefix_used' => 'cookie',
    );
} else {

    // Switch that allows overriding the bridge manager with hard-coded values
    define('USE_BRIDGEMGR', 1);

    require_once 'bridge/udb_base.inc.php';

    class cpg_udb extends core_udb {

        function cpg_udb()
        {
            global $BRIDGE;
            
            if (!USE_BRIDGEMGR) {
                $this->boardurl = 'http://www.mydatabass.com/Forum';
                require_once('../conf/config.php');

            } else {
                $this->boardurl = $BRIDGE['full_forum_url'];
                require_once($BRIDGE['relative_path_to_config_file'] . 'conf/config.php');
                $this->use_post_based_groups = $BRIDGE['use_post_based_groups'];
            }
            
            $this->multigroups = 1;
            
            // Database connection settings
            $this->db = array(
                'name' => $dbname,
                'host' => $dbhost ? $dbhost : 'localhost',
                'user' => $dbuser,
                'password' => $dbpasswd,
                'prefix' =>$table_prefix
            );
            
            // Board table names
            $this->table = array(
                'users' => 'users',
                'groups' => 'groups',
                'sessions' => 'sessions',
                'usergroups' => 'user_group'
            );

            // Derived full table names
            $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users'];
            $this->groupstable =  '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups'];
            $this->sessionstable =  '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions'];
            $this->usergroupstable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['usergroups'];
            
            // Table field names
            $this->field = array(
                'username' => 'username', // name of 'username' field in users table
                'user_id' => 'user_id', // name of 'id' field in users table
                'password' => 'user_password', // name of 'password' field in users table
                'email' => 'user_email', // name of 'email' field in users table
                'regdate' => 'user_regdate', // name of 'registered' field in users table
                'active' => 'user_active', // is user account active?
                'lastvisit' => 'user_lastvisit', // name of 'location' field in users table
                'location' => 'user_from', // name of 'location' field in users table
                'website' => 'user_website', // name of 'website' field in users table
                'usertbl_group_id' => 'group_id', // name of 'group id' field in users table
                'grouptbl_group_id' => 'group_id', // name of 'group id' field in groups table
                'grouptbl_group_name' => 'group_name' // name of 'group name' field in groups table
            );
            
            // Pages to redirect to
            $this->page = array(
                'register' => '/ucp.php?mode=register',
                'editusers' => '/memberlist.php',
                'edituserprofile' => "/memberlist.php?mode=viewprofile&u=",
            );
            
            // Group ids - admin and guest only.
            $this->admingroups = array(2);
            $this->guestgroup = 3;
            
            // Use a special function to collect groups for cpg groups table
            $this->group_overrride = 1;
            
            // Cookie settings - used in following functions only
            $this->cookie_name = $BRIDGE['cookie_prefix'];
            
            // Connect to db
            $this->connect();
        }

        function collect_groups()
        {
            $sql ="SELECT * FROM {$this->groupstable} WHERE group_single_user = 0";
        
            $result = cpg_db_query($sql, $this->link_id);
            
            $udb_groups = array(102 =>'Administrators', 2=> 'Registered', 3=>'Guests');
                
            while ($row = mysql_fetch_assoc($result))
            {
                $udb_groups[$row[$this->field['grouptbl_group_id']]+100] = utf_ucfirst(utf_strtolower($row[$this->field['grouptbl_group_name']]));
            }

            return $udb_groups;
            
        }
        // definition of how to extract id, name, group from a session cookie
        function session_extraction()
        {
            $superCage = Inspekt::makeSuperCage();
            //if (isset($_COOKIE[$this->cookie_name . '_sid'])) {           
            //  $session_id = addslashes($_COOKIE[$this->cookie_name . '_sid']);
            if ($superCage->cookie->keyExists($this->cookie_name . '_sid')) {           
                $session_id = $superCage->cookie->getEscaped($this->cookie_name . '_sid');

                $sql = "SELECT u.{$this->field['user_id']} AS user_id, u.{$this->field['password']} AS password FROM {$this->usertable} AS u, {$this->sessionstable} AS s WHERE u.{$this->field['user_id']}=s.session_user_id AND s.session_id = '$session_id' AND u.user_id > 0";
                
                $result = cpg_db_query($sql, $this->link_id);

                if (mysql_num_rows($result)){
                    $row = mysql_fetch_array($result);
                    return $row;
                } else {
                    return false;
                }
            }
        }
        
Tagged:
«1

Comments

  • 422422 Developer MVP

    perhaps @todd or @lincoln could assist you

    There was an error rendering this rich post.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2013

    That would be greatly appreciated !! ♥♥♥♥

    here is a link to the documentation for the app about bridging

    http://documentation.coppermine-gallery.net/en/bridging.htm#integrating_cookie_start

  • businessdadbusinessdad Stealth contributor MVP

    I may be wrong, but the cookie that Vanilla sets by default is called "Vanilla".

  • GaryFunkGaryFunk Senior Application Developer ✭✭

    I can help you with the cookie. I'll get you the info tomorrow.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    thanks you guys, but I am still trying to figure it out. I tried using Vanilla as the cookie name but something did not go right. the cookie for phpbb is phpbb3mysql or something like that, I also have a numerical cookie for Salt and the domain cookie .

    if I can't get the name of the cookie can I at least get some milk please ;) ?

  • Was this bridge ever completed/figured out? I've been messing around with galleries, and Coppermine seems the easiest and most attractive for me to customize to replicate my forums. I'd just like to have them bridged for SSO -- I already have WordPress and Vanilla connected for SSO. I checked the Coppermine forums, and there still hasn't been a user submitted bridge for Vanilla created.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    no, sadly the best I could come up with was the Galleries plugin , and peregrine made the My Attachments plugin.

    I did like coppermine gallery but was not able to make it integrate successfully.

    :(

  • Does this ever come?

    I would pay for it so bad...

    Its an musthave for my website, a gallery for designs..

  • peregrineperegrine MVP
    edited October 2014

    @Schryvers said:
    Does this ever come?

    I would pay for it so bad...

    Its an musthave for my website, a gallery for designs..

    money talks, and specific amounts of pledges talk even louder, to separate the wheat from the chaff.

    e.g. Someone said they badly wanted something and would pay me to develop.something that would have required 40 hours of work). When i asked how much it was worth to them for me to do - and they said they were willing to pay $5 for it :), since they were a student.

    OTOH - lets say someone wrote sphinx plugin or yaga or some other great app or plugin that involved alot of hours (much more than the number of hours to develop a premium theme), and lots of people voluntarily donated (even though the air was free). That developer might have been more willing to take something on that they put alot of time into, since they were rewarded before (even though there was no requirement to be rewarded). Get my gist.

    start with the amount you will pledge for it, and maybe someone will also wish to pledge, and then if a developer sees a reasonable pledge amounts they might take it on. Usually this helps get the process started, at least form what I've seen.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I'll do 50euros dunno how much it is in dollars to get coppermine workin with vanilla (login to coppermine with vanilla userinformation).

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Well , try the Galleries plugin ...

  • BleistivtBleistivt Moderator
    edited October 2014

    I have successfully managed to connect Piwigo to my vanilla forum userbase in the past.

    I have attached the user.inc.php, which is a drop-in replacement for the user.inc.php in the /includes folder of Piwigo that forces your Vanilla session and user ID in piwigo.

    A few things to make this work:

    1: You need the > VanillaIdentity.php < in your root (or change line 28 in the attached file accordingly) and configure it.

    2: For users to actually be able to upload images, you need to install the community plugin (as Piwigo is not a multi-user gallery by default)

    3: Piwigo and Vanilla need to use the same database as they will share a user table!
    add this to your piwigo configuration file to map the fields:

    $conf['external_authentification'] = true;
    $conf['users_table'] = 'GDN_User';
    $conf['user_fields'] = array(
      'id' => 'UserID',
      'username' => 'Name',
      'password' => 'Password',
      'email' => 'Email'
      );
    

    A few other config values that might prove helpful:

    $conf['guest_id']
    $conf['default_user_id']
    $conf['webmaster_id']
    

    Set them according to the IDs in your vanilla install.

    4: Enable the "Personal Plugin" which ships with piwigo and lets you add plugin code through the ACP. These are a few modifications I made to improve the integration between the systems, just paste them into your personal plugin:

    <?php
    
    // remove signout and profile edit links
    
    add_event_handler('loc_end_page_tail', 'custom_footer');
    function custom_footer() {
      global $template, $conf, $user, $page;
      $template->assign('CONTACT_MAIL', null);
      $template->assign('U_LOGOUT', null);
      $template->assign('U_PROFILE', null);
      if ($user['id'] == $conf['guest_id'])
        $template->assign('U_LOGIN', '../entry/signin?Target=gallery'); //<-modify this to link to your gallery
    }
    
    // show the user who uploaded the image in the image description
    // taken from a post on the piwigo.org forum and modified to link to vanilla user profiles
    
    if (script_basename() == 'picture')  {
      add_event_handler('loc_begin_picture', 'pabI', 55 );
    
      function pabI() {
        global $template;
        $template->set_prefilter('picture', 'pabIT');
      }
    
      function pabIT($content, &$smarty) {
        $search = '#<div id="Categories" class="imageInfo">#';
        $replacement = '
      {if $PAB}
      <div id="pab1" class="imageInfo">
        <dt>By</dt>
    <dd><a href="/profile/{$PAB}">{$PAB}</a></dd>
      </div>
    {/if}
    <div id="Categories" class="imageInfo">';
        return preg_replace($search, $replacement, $content);
      }
    
      add_event_handler('loc_begin_picture', 'pab');
    
      function pab() {
        global $conf, $page, $template;
        if (empty($page['image_id']))
          return;
        $query = '
        select added_by
          FROM ' . IMAGES_TABLE . '
          WHERE id = \''.$page['image_id'].'\'
          ;';
        $result = pwg_query($query);
        $row = pwg_db_fetch_assoc($result);
        $userab=$row['added_by'];
        $query = '
        select '.$conf['user_fields']['username'].'
          FROM ' . USERS_TABLE . '
          WHERE '.$conf['user_fields']['id'].' = \''.$userab.'\'
          ;';
        $result = pwg_query($query);
        $row = pwg_db_fetch_assoc($result);
        $pab=$row[$conf['user_fields']['username']];
        $template->assign (array('PAB' => $pab,));
      }
    }
    

    5: pick a theme and integrate it to look like your forum/website
    There a quite a few, I recommend the "elegant" theme

  • perhaps @x00 @bleistivt @hgtonight @r_j or some of the other developers might be interested.

    one pledge by Schryvers for 50 euros. maybe others are interested in pledging.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • BleistivtBleistivt Moderator
    edited October 2014

    No thanks, I wouldn't have the nerves to support something like that :smiley:

    But if he doesn't mind if it's not coppermine, he can try what I posted , but I won't be able to help much more, because I have removed the gallery from my site a few months ago as it added no value for my community.

  • peregrineperegrine MVP
    edited October 2014

    @Bleistivt No thanks, I wouldn't have the nerves to support something like that :smiley:

    I cross-posted before I saw your post. just wanted to let you know in case you were interested.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Looks similar to the coppermine bridge. I suspect they work the same way. Coppermine is a pretty cool app because it allows editing and such. They offer bridges to many other apps. I am no longer using it because the Galleries plugin is sufficient for the purpose. But I can see how for art and photography it could be very useful.

  • x00x00 MVP
    edited October 2014

    I do wish people wouldn't use the word "bridge" It is kind of like unicorns: mythical.

    There are a number of different things the people mean when they say "bridge", each of them different, ironically not of them are to do with the technical term "bridge pattern".

    grep is your friend.

  • R_JR_J Ex-Fanboy Munich Admin

    @peregrine said:
    perhaps x00 bleistivt hgtonight r_j or some of the other developers might be interested.

    one pledge by Schryvers for 50 euros. maybe others are interested in pledging.

    Neither pledging nor developing ;)

  • hgtonighthgtonight ∞ · New Moderator
    edited October 2014

    I have a client in the works that wants this type of functionality. If she actually takes my bid, I will look into coppermine.

    Actually, I just did. I don't think I will ever use that. Probably easier to write your own simple gallery application on top of Garden.

    Count me out. :(

    EDIT - I will still pledge $10 to anyone that does create this bridge.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • still pledge 50eu

Sign In or Register to comment.