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 …');
}
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