Topic: who really successfully integrate mediawiki and punbb?

I've searched around the post on this topic, and i know there're many requests on that, and some extensions like this are avaliable:
http://www.mediawiki.org/wiki/Extension … entication

but after my trials, i still can't install them correctly. I'm using mediawiki 1.12 and punbb 2. Could anyone confirm me if there's actually any extension to integrate both systems (mw1.12 and punbb2) ?

Re: who really successfully integrate mediawiki and punbb?

I have used this extension with mediawiki 1.1.3.1 and punbb 1.3rc, but nothing happens after that, either.

In the half way it says FORUM_ROOT should be defined first so I define it the same as the PUN_ROOT. However, after I sign into punbb and then switch to mediawiki, it still ask me for account to access. Im faint ... what is the key?

Re: who really successfully integrate mediawiki and punbb?

Tihs must be a PunBB 1.2 integration mediawiki-extension.
It won't work with 1.3 branch.

Nevertheless, you may try to update this extension.
First of all, replace all "$pun_" with "$forum_" and "PUN_" with "FORUM_".
And PunBB URLs may need to be updated proper way.

Carpe diem

Re: who really successfully integrate mediawiki and punbb?

Thank you Anatoly! I just change all the "pun_" and "PUN_" to "forum_" and "FORUM_", and set the paths to my website. However, when I click login/register in MediaWiki, the whole page turns me back to the index page of my PunBB forum ...

It seems that there is a redirect problem when accessing PunBB's account information, following it my remodified PunBBAuth.php file:

<?php
# PunBB MediaWiki extension

if( !defined( 'MEDIAWIKI' ) )
die();

$wgExtensionCredits['other'][] = array(
    'name' => 'PunBB Authentication',
    'description' => 'Auto-authenticates the current PunBB user',
    'author' => 'Bradley Bell'
);


# PunBB integration

//define('FORUM_QUIET_VISIT', 1);
define('FORUM_ROOT', '/home/abc/abc.cn/arch/');
require FORUM_ROOT.'include/common.php';

$wgHooks['AutoAuthenticate'][] = 'AutoAuthenticatePunBB';
$wgHooks['UserLogout'][] = 'UserLogoutPunBB';
$wgHooks['UserLoginForm'][] = 'UserLoginFormPunBB';

function AutoAuthenticatePunBB(&$user) {
        global $forum_user;

        if ($forum_user['is_guest']) {
                return true;
        }


        $user = User::newFromName(ucfirst(strtolower($forum_user["username"])));
        if ( $user->getID() == 0 ) {
                $user->addToDatabase();
                $user->setId($user->idFromName(ucfirst(strtolower($forum_user["username"]))));
                $user->setToken();
                $user->setRealName($forum_user['realname']);
                $user->setEmail($forum_user['email']);
                $user->confirmEmail();
                if ($forum_user['g_id'] == FORUM_ADMIN) {
                        $user->addGroup("sysop");
                }
        } else {
                /* Should cache some day, I guess :) */
                $user->loadFromDatabase();
                $user->setToken();
        }

        return true;
}

function UserLogoutPunBB(&$user) {
        global $forum_user;

        redirect('../login.php?action=out&id='.$forum_user['id'], 'Logging out. Redirecting &hellip;');
}

function UserLoginFormPunBB(&$template) {
        $referer = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : 'index.php';
        header('Location: http://arch.abc.cn/login.php?redirect_url='.$referer);
       return true;
}

?>

The situation of mine is:

I installed PunBB 1.3rc in abc.cn/arch
              MediaWiki 1.13.1 in abc.cn/wiki

And I change the "cookie_domain = .abc.cn" in config.php

Re: who really successfully integrate mediawiki and punbb?

PunBB 1.3 is using the POST data to log user in via login.php.
See http://punbb.informer.com/trac/browser/ … in.php#L44

Try to send POST data to http://arch.abc.cn/login.php
Google out how to do this right.

Carpe diem

Re: who really successfully integrate mediawiki and punbb?

Problem solved!

The newest version of MediaWiki (1.13.1) dose not support this funtion: AutoAuthenticate

So my friend changed to use MediaWiki ver.1.21, this version support this function. And then we use the following codes and succeeded in the end wink:

<?php
# PunBB MediaWiki extension

if( !defined( 'MEDIAWIKI' ) )
die();

$wgExtensionCredits['other'][] = array(
    'name' => 'PunBB Authentication',
    'description' => 'Auto-authenticates the current PunBB user',
    'author' => 'Bradley Bell'
);


# PunBB integration

//define('FORUM_QUIET_VISIT', 1);
define('FORUM_ROOT', '/home/andywxy/andywxy.cn/arch/');
require FORUM_ROOT.'include/common.php';

$wgHooks['AutoAuthenticate'][] = 'AutoAuthenticatePunBB';
$wgHooks['UserLogout'][] = 'UserLogoutPunBB';
$wgHooks['UserLoginForm'][] = 'UserLoginFormPunBB';

function AutoAuthenticatePunBB(&$user) {
        global $forum_user;

        if ($forum_user['is_guest']) {
                return true;
        }

        $user = User::newFromName(ucfirst(strtolower($forum_user["username"])));
        if ( $user->getID() == 0 ) {
                $user->addToDatabase();
                $user->setId($user->idFromName(ucfirst(strtolower($forum_user["username"]))));
                $user->setToken();
                $user->setRealName($forum_user['realname']);
                $user->setEmail($forum_user['email']);
                $user->confirmEmail();
                if ($forum_user['g_id'] == FORUM_ADMIN) {
                        $user->addGroup("sysop");
                }
        } else {
                /* Should cache some day, I guess :) */
                $user->loadFromDatabase();
                $user->setToken();
        }

        return true;
}

function UserLogoutPunBB(&$user) {
        global $forum_user;
    $target_url = 'logout'.$forum_user['id'];
        $referer = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : 'index.php';
    $token = '&csrf_token='. sha1(str_replace('&amp;', '&', $target_url) . $forum_user['csrf_token']);
    //$token ="";
        redirect('../login.php?action=out&id='.$forum_user['id'].$token.'&redirect_url='.$referer, 'Logging out now ....');
}

function UserLoginFormPunBB(&$template) {
        $referer = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : 'index.php';
    redirect('../login.php?redirect_url='.$referer, 'Loggin now ....');
        #header('Location: http://arch.andywxy.cn/login.php?redirect_url='.$referer);
       return true;
}

?>