coppermine-gallery.com/forum

No Support => Modifications/Add-Ons/Hacks => Mods: Bridging/Integration => Topic started by: john degey on August 28, 2007, 07:55:56 PM

Title: coppermine & phpbb2 : login rediretion on subdomain
Post by: john degey on August 28, 2007, 07:55:56 PM
hi all
i was using coppermine's integration with phpbb2 on the same domain.
now, i've changed my configuration with 2 subdomains.
i have little redirection problems that unsatisfied me, so i've made some change to coppermine's code and release a phpbb mod to integrate well with this changes.

the changes for coppermine are here http://www.johndegey.org/ressources/coppermine/mod/SubDomainRedirection.mod
it use the phpbb mod format.
it requires just to change 2 files: the bridge/phpbb2018.inc.php and teh base class file bridge/udb_base.inc.php

the php mod is here http://www.johndegey.org/ressources/phpbb2/mod/SubDomainRedirection.mod
it was submitted this afternoon to the phpbb mod team, but it works well for what it is design.

regards,
john
Title: Re: coppermine & phpbb2 : login rediretion on subdomain
Post by: Joachim Müller on September 04, 2007, 11:11:54 AM
For ease of use I will provide the code changes here as well: edit bridge/phpbb2018.inc.php, find function login_page()
{
global $CONFIG;

        $cpg = parse_url($CONFIG['site_url']);
        $bb = parse_url($this->boardurl);
        $levels = count(explode('/', $bb['path'])) - 1;
$redirect = str_repeat('../', $levels) . trim($cpg['path'], '/') . '/';
$this->redirect("/login.php?redirect=$redirect");
}
and replace with//---------------------------------------------------------------------------------
// Subdomain Redirection For Log In - Begin Code Addition
//
function login_page()
{
global $CONFIG;

        if(!$this->redirecting_subdomain()) {
            $cpg = parse_url($CONFIG['site_url']);
    $bb = parse_url($this->boardurl);
            $levels = count(explode('/', $bb['path'])) - 1;
    $redirect = str_repeat('../', $levels) . trim($cpg['path'], '/') . '/';
    $this->redirect("/login.php?redirect=$redirect");
        }
}
//
// Subdomain Redirection For Log In - End Code Addition
//---------------------------------------------------------------------------------
Thanks for your contribution.

@others: please review the mod and report your results.
Title: Re: coppermine & phpbb2 : login rediretion on subdomain
Post by: Nibbler on September 04, 2007, 09:35:50 PM
The mod also requires you to add this method:


    function redirecting_subdomain() {
global $CONFIG;

        $cpgHost = parse_url($CONFIG['site_url'],PHP_URL_HOST);
        $boardHost = parse_url($this->boardurl,PHP_URL_HOST);
        if($cpgHost == $boardHost) return FALSE;
        /*
          we check the subdomain a little bit
        */
        $cpgDomain = substr($cpgHost,strpos($cpgHost,'.')+1);
        $boardDomain = substr($boardHost,strpos($boardHost,'.')+1);
       
        if($cpgDomain != $boardDomain) return FALSE;

        $this->redirect("/login.php?redirect=${CONFIG['site_url']}&subdomain=1");
        return TRUE;
    }


Contrary to the instructions, this should go into phpbb2018.inc.php - it is cleaner this way,

Note this mod requires PHP >= 5.1.2, although you can code around this.