phpbb3 bridge - from team andros's to Nibblers phpbb3 bridge - from team andros's to Nibblers
 

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

phpbb3 bridge - from team andros's to Nibblers

Started by Dogbot, December 09, 2008, 02:51:50 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Dogbot

Hi all

Untill recently I was using the bridge "written by Stephen from team-andro.com" (attached to this topic) for phpbb3 and coppermine. Post based groups never worked so just last week I swapped to using Nibblers bridge file, which works far better because it recognises all groups.

I had modified the team adros bridge to allow "album auto-creation" using the following code.


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();
        }


Now auto album creation does not work and I'm guessing it's because the two bridge filles approach the bridging in two different ways.

Is it possible that someone can advise me on how auto-album creation can be made available on Nibblers better bridge file, as it was available on the previous team andros bridge.

Many thanks

Dogbot

Nibbler

Just move the autocreation code to the end of include/init.inc.php. That way you don't need to worry about bridging atall.

Dogbot

Thanks Nibbler,

I've inserted the code above as instructed and nothing is happening, but no errors are given either.

Turned on debug mode and I could only see mention of one of the sql queries from the code above.

    [4] => SELECT u.user_id AS id, u.username AS username, u.user_password AS password, u.group_id+100 AS group_id FROM `ster1965_foCal`.phpbb_users AS u INNER JOIN `ster1965_foCal`.phpbb_groups AS g ON u.group_id=g.group_id WHERE u.user_id='169' (0s)

Can anyone help further?

Many thanks

Dogbot

Nibbler

You should have added this code to init.inc.php


        //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);
        }


So you should always see


SELECT aid FROM cpg14x_albums WHERE category = 10xxx


in the debug output when logged in.

Dogbot

Thanks Nibbler..works a treat now.

Can "My Album" be changed so that the users name is inserted?

I've tried

$sql = "INSERT INTO cpg14x_albums (category, title, uploads, pos) VALUES ('$cid', '[$user-name]\'s Gallery', 'NO',  '1')";

Many thanks once again.

Dogbot

Dogbot

Okay, I got it now.

        //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)
                {
$user_name = $USER_DATA['user_name'];
                        $sql = "INSERT INTO cpg14x_albums (category, title, uploads, pos) VALUES

('$cid', '$user_name\'s Gallery', 'NO',  '1')";
                        cpg_db_query($sql);
                }
                mysql_free_result($result);
        }


Dogbot

ZakRhino

So in the file init.inc.php the code from which was talked about in this thread at the end of the file but got an error. *Right Below,* How can I find this?


While executing query "SELECT aid FROM cpg14x_albums WHERE category = 10002" on 0

mySQL error: Table 'digimontest.cpg14x_albums' doesn't exist



Below is the init.inc.php file code.


<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2009 Coppermine 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.22
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/include/init.inc.php $
  $Revision: 5880 $
  $Author: pvanrompay $
  $Date: 2009-04-30 02:27:04 +0200 (Do, 30 Apr 2009) $
**********************************************/

define('COPPERMINE_VERSION''1.4.22');
define('COPPERMINE_VERSION_STATUS''stable');

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

// Store all reported errors in the $cpgdebugger
require_once('include/debugger.inc.php');

set_magic_quotes_runtime(0);
// used for timing purpose
$query_stats = array();
$queries = array();

function 
cpgGetMicroTime()
{
        list(
$usec$sec) = explode(" "microtime());
        return ((float)
$usec + (float)$sec);
}
$cpg_time_start cpgGetMicroTime();
// Do some cleanup in GET, POST and cookie data and un-register global vars
$HTML_SUBST = array('&' => '&amp;''"' => '&quot;''<' => '&lt;''>' => '&gt;''%26' => '&amp;''%22' => '&quot;''%3C' => '&lt;''%3E' => '&gt;','%27' => '&#38;#39;'"'" => '&#38;#39;');

$keysToSkip = array('_POST''_GET''_COOKIE''_REQUEST''_SERVER''HTML_SUBST''keysToSkip''register_globals_flag''cpgdebugger');

if (
ini_get('register_globals') == '1' || strtolower(ini_get('register_globals')) == 'on') {
    
$register_globals_flag true;
} else {
    
$register_globals_flag false;
}

if (
get_magic_quotes_gpc()) {
        if (
is_array($_POST)) {
                foreach (
$_POST as $key => $value) {
                        if (!
is_array($value))
                                
$_POST[$key] = strtr(stripslashes($value), $HTML_SUBST);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }

        if (
is_array($_GET)) {
                foreach (
$_GET as $key => $value) {
                        unset(
$_GET[$key]);
                        
$_GET[strtr(stripslashes($key), $HTML_SUBST)] = strtr(stripslashes($value), $HTML_SUBST);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }

        if (
is_array($_COOKIE)) {
                foreach (
$_COOKIE as $key => $value) {
                        if (!
is_array($value))
                                
$_COOKIE[$key] = stripslashes($value);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }
        if (
is_array($_REQUEST)) {
                foreach (
$_REQUEST as $key => $value) {
                        if (!
is_array($value))
                                
$_REQUEST[$key] = strtr(stripslashes($value), $HTML_SUBST);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }
} else {
        if (
is_array($_POST)) {
                foreach (
$_POST as $key => $value) {
                        if (!
is_array($value))
                                
$_POST[$key] = strtr($value$HTML_SUBST);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }

        if (
is_array($_GET)) {
                foreach (
$_GET as $key => $value) {
                        unset(
$_GET[$key]);
                        
$_GET[strtr(stripslashes($key), $HTML_SUBST)] = strtr(stripslashes($value), $HTML_SUBST);

                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) {
                            unset($
$key);
                        }
                }
        }

        if (
is_array($_COOKIE)) {
                foreach (
$_COOKIE as $key => $value) {
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }
        if (
is_array($_REQUEST)) {
                foreach (
$_REQUEST as $key => $value) {
                        if (!
is_array($value))
                                
$_REQUEST[$key] = strtr($value$HTML_SUBST);
                        if (!
in_array($key$keysToSkip) && isset($$key) && $register_globals_flag) unset($$key);
                }
        }
}
// Initialise the $CONFIG array and some other variables
$CONFIG = array();
//$PHP_SELF = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['SCRIPT_NAME'];

$PHP_SELF '';
$ORIGINAL_PHP_SELF $_SERVER['PHP_SELF'];
$possibilities = array('REDIRECT_URL''PHP_SELF''SCRIPT_URL''SCRIPT_NAME','SCRIPT_FILENAME');
foreach (
$possibilities as $test){
  if (isset(
$_SERVER[$test]) && preg_match('/([^\/]+\.php)$/'$_SERVER[$test], $matches)){
        
$PHP_SELF $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = $matches[1];
        break;
  }
}

$REFERER urlencode($_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' $_SERVER['QUERY_STRING'] : ''));
$ALBUM_SET '';
$META_ALBUM_SET '';
$FORBIDDEN_SET '';
$FORBIDDEN_SET_DATA = array();
$CURRENT_CAT_NAME '';
$CAT_LIST '';
// Record User's IP address
$raw_ip stripslashes($_SERVER['REMOTE_ADDR']);

if (isset(
$_SERVER['HTTP_CLIENT_IP'])) {
        
$hdr_ip stripslashes($_SERVER['HTTP_CLIENT_IP']);
} else {
        if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR'])) {
                
$hdr_ip stripslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
        } else {
                
$hdr_ip $raw_ip;
        }
}

if (!
preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/'$raw_ip)) $raw_ip '0.0.0.0';
if (!
preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/'$hdr_ip)) $hdr_ip '0.0.0.0';

// Define some constants
define('USER_GAL_CAT'1);
define('FIRST_USER_CAT'10000);
define('RANDPOS_MAX_PIC'200);
define('TEMPLATE_FILE''template.html');
// Constants used by the cpg_die function
define('INFORMATION'1);
define('ERROR'2);
define('CRITICAL_ERROR'3);

// Include config and functions files
if(file_exists('include/config.inc.php')){
                
ob_start();
                require_once 
'include/config.inc.php';
                
ob_clean();
} else {
  
// error handling: if the config file doesn't exist go to install
  
die('<html>
        <head>
          <title>Coppermine not installed yet</title>
          <meta http-equiv="refresh" content="10;url=install.php">
          <style type="text/css">
          <!--
          body { font-size: 12px; background: #FFFFFF; margin: 20%; color: black; font-family: verdana, arial, helvetica, sans-serif;}
          -->
          </style>
        </head>
        <body>
          <img src="images/coppermine_logo.png" alt="Coppermine Photo Gallery - Your Online Photo Gallery" /><br />
          Coppermine Photo Gallery seems not to be installed correctly, or you are running coppermine for the first time. You\'ll be redirected to the installer. If your browser doesn\'t support redirect, click <a href="install.php">here</a>.
        </body>
</html>'
);
}
$mb_utf8_regex '[\xE1-\xEF][\x80-\xBF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xC2-\xDF][\x80-\xBF]';
require 
'include/functions.inc.php';
# see http://php.net/mbstring for details
if (function_exists('mb_internal_encoding')) { mb_internal_encoding('UTF-8'); }

$CONFIG['TABLE_PICTURES']   = $CONFIG['TABLE_PREFIX'].'pictures';
$CONFIG['TABLE_ALBUMS']     = $CONFIG['TABLE_PREFIX'].'albums';
$CONFIG['TABLE_COMMENTS']   = $CONFIG['TABLE_PREFIX'].'comments';
$CONFIG['TABLE_CATEGORIES'] = $CONFIG['TABLE_PREFIX'].'categories';
$CONFIG['TABLE_CONFIG']     = $CONFIG['TABLE_PREFIX'].'config';
$CONFIG['TABLE_USERGROUPS'] = $CONFIG['TABLE_PREFIX'].'usergroups';
$CONFIG['TABLE_VOTES']      = $CONFIG['TABLE_PREFIX'].'votes';
$CONFIG['TABLE_USERS']      = $CONFIG['TABLE_PREFIX'].'users';
$CONFIG['TABLE_BANNED']     = $CONFIG['TABLE_PREFIX'].'banned';
$CONFIG['TABLE_EXIF']       = $CONFIG['TABLE_PREFIX'].'exif';
$CONFIG['TABLE_FILETYPES']  = $CONFIG['TABLE_PREFIX'].'filetypes';
$CONFIG['TABLE_ECARDS']     = $CONFIG['TABLE_PREFIX'].'ecards';
$CONFIG['TABLE_TEMPDATA']   = $CONFIG['TABLE_PREFIX'].'temp_data';
$CONFIG['TABLE_FAVPICS']    = $CONFIG['TABLE_PREFIX'].'favpics';
$CONFIG['TABLE_BRIDGE']     = $CONFIG['TABLE_PREFIX'].'bridge';
$CONFIG['TABLE_VOTE_STATS'] = $CONFIG['TABLE_PREFIX'].'vote_stats';
$CONFIG['TABLE_HIT_STATS']  = $CONFIG['TABLE_PREFIX'].'hit_stats';
// Connect to database
($CONFIG['LINK_ID'] = cpg_db_connect()) || die('<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>' mysql_error() . '</b>');
// Retrieve DB stored configuration
$results cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
while (
$row mysql_fetch_array($results)) {
        
$CONFIG[$row['name']] = $row['value'];
// while
mysql_free_result($results);

// Reference 'site_url' to 'ecards_more_pic_target'
$CONFIG['site_url'] =& $CONFIG['ecards_more_pic_target'];

// Include logger functions
include_once('include/logger.inc.php');

// Include media functions
require 'include/media.functions.inc.php';

// Check for GD GIF Create support
if ($CONFIG['thumb_method'] == 'im' || function_exists('imagecreatefromgif'))
  
$CONFIG['GIF_support'] = 1;
else
  
$CONFIG['GIF_support'] = 0;

// Include plugin API
require('include/plugin_api.inc.php');
if (
$CONFIG['enable_plugins'] == 1) {
        
CPGPluginAPI::load();
}

// Set UDB_INTEGRATION if enabled in admin
if ($CONFIG['bridge_enable'] == && !defined('BRIDGEMGR_PHP')) {
        
$BRIDGE cpg_get_bridge_db_values();
} else {
  
$BRIDGE['short_name'] = 'coppermine';
  
$BRIDGE['use_standard_groups'] = 1;
  
$BRIDGE['recovery_logon_failures'] = 0;
  
$BRIDGE['use_post_based_groups'] = false;
}

define('UDB_INTEGRATION'$BRIDGE['short_name']);

require_once 
'bridge/' UDB_INTEGRATION '.inc.php';

/*

Removed temporarily due to non-compliance with bridging system - Nibbler

// Retrieve Array of Admin Groups (used for hiding admin usernames on thumbnails)
$results = cpg_db_query("SELECT group_id FROM {$CONFIG['TABLE_USERGROUPS']} WHERE has_admin_access ");
$CONFIG['ADMIN_GROUPS']=array();
while ($row = mysql_fetch_array($results)) {
        $CONFIG['ADMIN_GROUPS'][]= $row['group_id'];
} // while
mysql_free_result($results);

// Retrieve Array of Admin Users (used for hiding admin usernames on thumbnails)
$results = cpg_db_query("SELECT {$cpg_udb->field['user_id']} as user_id FROM $cpg_udb->usertable WHERE {$cpg_udb->field['usertbl_group_id']} in (" . implode(',',$CONFIG['ADMIN_GROUPS']).')');
$CONFIG['ADMIN_USERS']=array();
while ($row = mysql_fetch_array($results)) {
        $CONFIG['ADMIN_USERS'][] = $row['user_id'];
} // while
mysql_free_result($results);

*/

// Start output buffering
ob_start('cpg_filter_page_html');

// Parse cookie stored user profile
user_get_profile();

// Authenticate
$cpg_udb->authenticate();

// Test if admin mode
$USER['am'] = isset($USER['am']) ? (int)$USER['am'] : 0;
define('GALLERY_ADMIN_MODE'USER_IS_ADMIN && $USER['am']);
define('USER_ADMIN_MODE'USER_ID && USER_CAN_CREATE_ALBUMS && $USER['am'] && !GALLERY_ADMIN_MODE);


// Set error logging level
// Maze's new error report system
if (!USER_IS_ADMIN) {
        if (!
$CONFIG['debug_mode']) $cpgdebugger->stop(); // useless to run debugger cos there's no output
        
error_reporting(E_PARSE); // hide all errors for visitors
}

// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
        
$USER['theme'] = $_GET['theme'];
}
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' $USER['theme'])) {
        
$CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`''____________');
} else {
        unset(
$USER['theme']);
}

if (!
file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require 
"themes/{$CONFIG['theme']}/theme.php";
require 
"include/themes.inc.php";  //All Fallback Theme Templates and Functions
$THEME_DIR "themes/{$CONFIG['theme']}/";


// Process language selection if present in URI or in user profile or try
// autodetection if default charset is utf-8
if (!empty($_GET['lang']))
{
        
$USER['lang'] = ereg("^[a-z0-9_-]*$"$_GET['lang']) ? $_GET['lang'] : $CONFIG['lang'];
}

if (isset(
$USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' $USER['lang'] . '.php'))
{
        
$CONFIG['default_lang'] = $CONFIG['lang'];          // Save default language
        
$CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`''____________');
}
elseif (
$CONFIG['charset'] == 'utf-8')
{
        include(
'include/select_lang.inc.php');
        if (
file_exists('lang/' $USER['lang'] . '.php'))
        {
                
$CONFIG['default_lang'] = $CONFIG['lang'];      // Save default language
                
$CONFIG['lang'] = $USER['lang'];
        }
}
else
{
        unset(
$USER['lang']);
}

if (isset(
$CONFIG['default_lang']) && ($CONFIG['default_lang']==$CONFIG['lang']))
{
                unset(
$CONFIG['default_lang']);
}

if (!
file_exists("lang/{$CONFIG['lang']}.php"))
  
$CONFIG['lang'] = 'english';

// We load the chosen language file
require "lang/{$CONFIG['lang']}.php";

// Include and process fallback here if lang <> english
if($CONFIG['lang'] != 'english' && $CONFIG['language_fallback']==){
                require 
"include/langfallback.inc.php";
}


// See if the fav cookie is set else set it
if (isset($_COOKIE[$CONFIG['cookie_name'] . '_fav'])) {
        
$FAVPICS = @unserialize(@base64_decode($_COOKIE[$CONFIG['cookie_name'] . '_fav']));
        foreach (
$FAVPICS as $key => $id ){
                
$FAVPICS[$key] = (int)$id//protect against sql injection attacks
        
}
} else {
        
$FAVPICS = array();
}

// If the person is logged in get favs from DB those in the DB have precedence
if (USER_ID 0){
                
$sql "SELECT user_favpics FROM {$CONFIG['TABLE_FAVPICS']} WHERE user_id = ".USER_ID;
                
$results cpg_db_query($sql);
                
$row mysql_fetch_array($results);
                if (!empty(
$row['user_favpics'])){
                                
$FAVPICS = @unserialize(@base64_decode($row['user_favpics']));
                }else{
                                
$FAVPICS = array();
                }
}

// If referer is set in URL and it contains 'http' or 'script' texts then set it to 'index.php' script
if (isset($_GET['referer'])) {
        if (
preg_match('/((\%3C)|<)[^\n]+((\%3E)|>)|(.*http.*)|(.*script.*)/i'$_GET['referer'])) {
                
$_GET['referer'] = 'index.php';
        }
}

/**
 * CPGPluginAPI::action('page_start',null)
 *
 * Executes page_start action on all plugins
 *
 * @param null
 * @return N/A
 **/

CPGPluginAPI::action('page_start',null);

// load the main template
load_template();
$CONFIG['template_loaded'] = true;

// Remove expired bans
$now date('Y-m-d H:i:s');
cpg_db_query("DELETE FROM {$CONFIG['TABLE_BANNED']} WHERE expiry < '$now'");
// Check if the user is banned
$user_id USER_ID;
$result cpg_db_query("SELECT * FROM {$CONFIG['TABLE_BANNED']} WHERE (ip_addr='$raw_ip' OR ip_addr='$hdr_ip' OR user_id=$user_id) AND brute_force=0");
if (
mysql_num_rows($result)) {
        
pageheader($lang_error);
        
msg_box($lang_info$lang_errors['banned']);
        
pagefooter();
        exit;
}
mysql_free_result($result);

// Retrieve the "private" album set
if (!GALLERY_ADMIN_MODE && $CONFIG['allow_private_albums']) get_private_album_set();

if (!
USER_IS_ADMIN && $CONFIG['offline'] && !strstr($_SERVER["SCRIPT_NAME"],'login')) {
        
pageheader($lang_errors['offline_title']);
        
msg_box($lang_errors['offline_title'], $lang_errors['offline_text']);
        
pagefooter();
        exit;
}

// kick user into user_admin_mode (needed to fix "removed user mode for users" when upgrading)
if (USER_ID && !USER_IS_ADMIN && !$USER['am']) { // user is logged in, but is not gallery admin and not in admin mode
        
$USER['am'] = 1;
        
pageheader($lang_info"<META http-equiv=\"refresh\" content=\"1;url=$referer\">");
        
msg_box($lang_info'Sending you to admin mode'$lang_continue$referer);
        
pagefooter();
        
ob_end_flush();
        die();
}

//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)
                {
$user_name $USER_DATA['user_name'];
                        
$sql "INSERT INTO cpg14x_albums (category, title, uploads, pos) VALUES 

('
$cid', '$user_name\'s Gallery', 'NO',  '1')";
                        
cpg_db_query($sql);
                }
                
mysql_free_result($result);
        }

?>


ZakRhino

Quote from: Dogbot on December 09, 2008, 02:51:50 AM
Hi all

Untill recently I was using the bridge "written by Stephen from team-andro.com" (attached to this topic) for phpbb3 and coppermine. Post based groups never worked so just last week I swapped to using Nibblers bridge file, which works far better because it recognises all groups.

I had modified the team adros bridge to allow "album auto-creation" using the following code.


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();
        }


Now auto album creation does not work and I'm guessing it's because the two bridge filles approach the bridging in two different ways.

Is it possible that someone can advise me on how auto-album creation can be made available on Nibblers better bridge file, as it was available on the previous team andros bridge.

Many thanks

Dogbot

Joachim Müller

The error message you got is not related. You shouldn't try to hijack someone else's thread. The error message says that a table is missing - fix that. If you have an actual bridging issue, do as suggested in the sticky thread on this board. Locking.