Integrating dokuWiki with phpbb3
I needed to integrate the dokuWiki authentication against a phpbb3 database. The following code just authenticates against the user table, without considering groups and any admin roles. The code doesnt take into account and table prefixes used in the setup. It also expects the phpbb3 files to be available as a sibling to the wikidirectory(check the paths if unsure).
It also has some debug things left, and probably som holes in the concept, but it works for now. An idea might be to integrate the phpbb3 group memberships to mean something in dokuwiki. The inexistance of bugs can not be guaranteed. Comments appreciated.
I have configured dokuwiki.php to use the new auth type with
$conf['authtype'] = 'phpbb3';
I also set the acl.auth.php to
* @ALL 8
/** * Simple auth mechanism for integrating DokuWiki with phpbb3. * Should be placed in dokuwiki/inc/auth/phpbb3.class.php * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Eric Persson <eric@persson.tm> */ class auth_phpbb3 extends auth_basic { var $cnf = null; var $con = null; var $bound = 0; // 0: anonymous, 1: user, 2: superuser var $mysql_connection; /** * Constructor */ function auth_phpbb3(){ global $conf; if (method_exists($this, 'auth_basic')) parent::auth_basic(); //$this->cando['external'] = true; $this->defaultgroup = $conf['defaultgroup']; /* Hook it up to phpbbs config */ require(dirname(__FILE__).'/../../../phpBB3/config.php'); $this->mysql_connection = mysql_connect($dbhost, $dbuser, $dbpasswd); mysql_select_db($dbname, $this->mysql_connection); } function checkPass($user,$pass){ $res = mysql_query('SELECT * FROM phpbb_users WHERE username_clean="'.mysql_escape_string(strtolower(utf8_decode($user))).'"'); if( $user = mysql_fetch_array($res) ) { define('IN_PHPBB', true); require(dirname(__FILE__).'/../../../phpBB3/includes/functions.php'); if( phpbb_check_hash($pass, $user['user_password']) ) { $this->username = $user['username']; $this->email = $user['user_email']; return true; } } return false; } function getUserData($user,$inbind=false) { global $conf; if( $user==$this->username ) { $info = array(); $info['name'] = $this->username; $info['mail'] = $this->email; $info['grps'] = array(); return $info; }else{ return false; } } }
blog comments powered by Disqus
© 1997 - 2010 | Part of the PTM Network