coppermine & phpbb2 : login rediretion on subdomain coppermine & phpbb2 : login rediretion on subdomain
 

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

coppermine & phpbb2 : login rediretion on subdomain

Started by john degey, August 28, 2007, 07:55:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

john degey

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

Joachim Müller

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.

Nibbler

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.