MyBB Community Forums

Full Version: Coppermine Gallery Integration...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I posted this over at their support forums, but since I want good measure, I'll post here too.

How do I get coppermine to recognize the right database information?

When it tries to bridge, the bridge information is blank, database name, database user, database host, etc. Trying to add these all in manually via the bridge table doesn't help, still gives the error mentioned in the post there on their forums.

Is the config.php that different from MyBB 1.02? gallery2 doesn't have integration with MyBB according to their documentation. If they did, I'd use it.
Well they make the bridge so I don't really know what to tell you.

Has it been updated for 1.4?
(2008-09-12, 02:01 AM)NetSage Wrote: [ -> ]Well they make the bridge so I don't really know what to tell you.

Has it been updated for 1.4?

Not at all, read the replies in that thread. Seems session data isn't gotten correctly even after editing it to get the correct configurations. Here's their bridge:

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.
  
  ********************************************
  Coppermine version: 1.4.19
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/bridge/mybb.inc.php $
  $Revision: 4392 $
  $Author: gaugau $
  $Date: 2008-04-16 09:25:35 +0200 (Mi, 16 Apr 2008) $
**********************************************/

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

// 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) { // the vars that are used when bridgemgr is disabled

			// URL of your punbb
			$this->boardurl = 'http://localhost/mybb';

			// local path to your punbb config file
			require_once('../mybb/inc/config.php');
			
			$this->use_post_based_groups = 1;

		} else { // the vars from the bridgemgr
			$this->boardurl = $BRIDGE['full_forum_url'];
			require_once($BRIDGE['relative_path_to_config_file'] . 'config.php');
			$this->use_post_based_groups = $BRIDGE['use_post_based_groups'];
		}
		
		$this->multigroups = 0;
		$this->group_overrride = 0;
		
		// Database connection settings
		$this->db = array(
			'name' => $config['database']['database'],
			'host' => $config['database']['hostname'],
			'user' => $config['database']['username'],
			'password' => $config['database']['password'],
			'prefix' =>$config['database']['table_prefix']
		);
		
		// Board table names
		$this->table = array(
			'users' => 'users',
			'groups' => 'usergroups',
			'sessions' => 'sessions',
		);

		// 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'];
		
		// Table field names
		$this->field = array(
			'username' => 'username', // name of 'username' field in users table
			'user_id' => 'uid', // name of 'id' field in users table
			'password' => 'loginkey', // name of 'password' field in users table
			'email' => 'email', // name of 'email' field in users table
			'regdate' => 'regdate', // name of 'registered' field in users table
			'location' => "''", // name of 'location' field in users table
			'website' => 'website', // name of 'website' field in users table
			'usertbl_group_id' => 'usergroup', // name of 'group id' field in users table
			'grouptbl_group_id' => 'gid', // name of 'group id' field in groups table
			'grouptbl_group_name' => 'title' // name of 'group name' field in groups table
		);
		
		// Pages to redirect to
		$this->page = array(
			'register' => '/member.php?action=register',
			'editusers' => '/memberlist.php',
			'edituserprofile' => "/member.php?action=profile&uid="
		);
		
		// Group ids
		$this->admingroups = array(4);
		$this->guestgroup = $this->use_post_based_groups ? 101 : 3;
		
		// Connect to db
		$this->connect();
	}

	// definition of how to extract id, name, group from a session cookie
	function session_extraction()
	{
		if (!isset($_COOKIE['sid'])) return false;
	
		$this->sid = addslashes($_COOKIE['sid']);
		
		if (!$this->sid) return false;
		
		$this->ipaddress = $this->getip();
		
		$result = cpg_db_query("SELECT u.{$this->field['user_id']}, u.{$this->field['password']} FROM {$this->sessionstable} AS s INNER JOIN {$this->usertable} AS u ON u.uid = s.uid WHERE sid='".$this->sid."' AND ip='".$this->ipaddress."'", $this->link_id);
		
		if (!mysql_num_rows($result)) return false;
		
		$row = mysql_fetch_row($result);

		return $row; 
	}
	
	// definition of how to extract an id and password hash from a cookie
	function cookie_extraction()
	{
		return  isset($_COOKIE['mybbuser']) ? array_map('addslashes', explode("_", $_COOKIE['mybbuser'], 2)) : false;
	}
	
	// imported function
	function getip() {

		if($_SERVER['HTTP_X_FORWARDED_FOR'])
		{
			if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses))
			{
				while(list($key, $val) = each($addresses[0]))
				{
					if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))
					{
						$ip = $val;
						break;
					}
				}
			}
		}
		if(!$ip)
		{
			if($_SERVER['HTTP_CLIENT_IP'])
			{
				$ip = $_SERVER['HTTP_CLIENT_IP'];
			}
			else
			{
				$ip = $_SERVER['REMOTE_ADDR'];
			}
		}
		return $ip;
	}

	// definition of actions required to convert a password from user database form to cookie form
	function udb_hash_db($password)
	{
		return $password;
	}
	
	// Login
	function login_page()
	{
		$this->redirect('/member.php?action=login');
	}

	// Logout
	function logout_page()
	{
		$this->redirect('/member.php?action=logout&uid=' . USER_ID . '&sid=' . $this->sid);
	}
	
	function view_users()
	{
		if (!$this->use_post_based_groups) $this->redirect($this->page['editusers']);
	}
	
	function get_users($options = array())
    {
    }
	
	function view_profile($uid)
	{
	}
}

// and go !
$cpg_udb = new cpg_udb;
?>

It's edited to get the correct config info, by me. I need to figure out why it won't get the correct session data. It keeps me logged out of coppermine, but I can login to the board.
I found out coppermine doesn't take MySQLi, seems that's the problem. But I still can't be logged in *sighs*
Seems I fixed my problem.