diff options
Diffstat (limited to 'plugins/phpbb30')
-rw-r--r-- | plugins/phpbb30/BridgePhpBB30.php | 36 | ||||
-rw-r--r-- | plugins/phpbb30/noweb_user.php | 17 | ||||
-rw-r--r-- | plugins/phpbb30/phpbb30.module | 11 | ||||
-rw-r--r-- | plugins/phpbb30/phpbb30_bootstrap.php | 45 |
4 files changed, 109 insertions, 0 deletions
diff --git a/plugins/phpbb30/BridgePhpBB30.php b/plugins/phpbb30/BridgePhpBB30.php new file mode 100644 index 0000000..bc7d8c8 --- /dev/null +++ b/plugins/phpbb30/BridgePhpBB30.php @@ -0,0 +1,36 @@ +<?php + +class BridgePhpBB3 extends EjabberdAuthBridge { + var $auth; + var $db; + + function __construct($auth, $db) { + $this->auth = $auth; + $this->db = $db; + } + + function isuser($username, $server) { + $username_clean = utf8_clean_string($username); + $row = $this->db->sql_fetchrow($this->db->sql_query('SELECT username FROM ' . USERS_TABLE . ' WHERE username_clean = ' . "'" . $this->db->sql_escape($username_clean) . "'" . ';')); + return !empty($row); + } + + function auth($username, $server, $password) { + $result = $this->auth->login($username, $password); + return $result['status'] == LOGIN_SUCCESS; + } + + // The following functions are disabled. This script will not change the phpBB user database. + + function setpass($username, $server, $password) { + return FALSE; + } + + function tryregister($username, $server, $password) { + return FALSE; + } + + function removeuser($username, $server) { + return FALSE; + } +} diff --git a/plugins/phpbb30/noweb_user.php b/plugins/phpbb30/noweb_user.php new file mode 100644 index 0000000..3291222 --- /dev/null +++ b/plugins/phpbb30/noweb_user.php @@ -0,0 +1,17 @@ +<?php + +class noweb_user { + var $session_id = ''; + var $browser = 'N/A'; + var $forwarded_for = '127.0.0.1'; + var $ip = '127.0.0.1'; + + function session_create() { + // do absolutely nothing. however, unless we tell the auth module the session + // was successfully created, it won't pass back a success. + return TRUE; + } + + function setup() { + } +} diff --git a/plugins/phpbb30/phpbb30.module b/plugins/phpbb30/phpbb30.module new file mode 100644 index 0000000..7502094 --- /dev/null +++ b/plugins/phpbb30/phpbb30.module @@ -0,0 +1,11 @@ +<?php + +function phpbb3_init($config) { + global $phpbb_root_path; + $phpbb_root_path = $config['root_path']; + // Bootstrap the phpBB system. + require_once __DIR__ . '/phpbb3_bootstrap.php'; + // Load the plugin. + require_once __DIR__ . '/BridgePhpBB3.php'; + return new BridgePhpBB3($auth, $db); +} diff --git a/plugins/phpbb30/phpbb30_bootstrap.php b/plugins/phpbb30/phpbb30_bootstrap.php new file mode 100644 index 0000000..55c973f --- /dev/null +++ b/plugins/phpbb30/phpbb30_bootstrap.php @@ -0,0 +1,45 @@ +<?php +define('IN_PHPBB', TRUE); +global $phpEx, $db, $cache, $user, $config; +$phpEx = 'php'; + +if (!file_exists($phpbb_root_path . 'includes/startup.' . $phpEx)) { + file_put_contents('php://stderr', "phpBB not found at <{$phpbb_root_path}>.\n"); + exit; +} +require($phpbb_root_path . 'includes/startup.' . $phpEx); + +if (file_exists($phpbb_root_path . 'config.' . $phpEx)) +{ + require($phpbb_root_path . 'config.' . $phpEx); +} + +if (!defined('PHPBB_INSTALLED')) +{ + file_put_contents('php://stderr', "phpBB needs to be installed first.\n"); + exit; +} + +// Include files +require(__DIR__ . '/noweb_user.php'); +require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); +require($phpbb_root_path . 'includes/cache.' . $phpEx); +require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); + +require($phpbb_root_path . 'includes/constants.' . $phpEx); +require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +// Instantiate some basic classes +$user = new noweb_user(); +$auth = new auth(); +$db = new $sql_db(); +$cache = new cache(); + +// Connect to DB +$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); +// We do not need this any longer, unset for safety purposes +unset($dbpasswd); +$config = $cache->obtain_config(); |