diff options
author | Christoph Burschka | 2012-10-30 15:40:38 +0100 |
---|---|---|
committer | Christoph Burschka | 2012-10-30 15:40:38 +0100 |
commit | b04c17301ec17397f858fb8cca7cb0043c16d4d5 (patch) | |
tree | 720e0d076e035f00e300e426b9323f05b77f9e36 /plugins/phpbb4 | |
parent | Refactor to a general, flexible and extensible architecture. (diff) | |
download | ejabberd-auth-php-b04c17301ec17397f858fb8cca7cb0043c16d4d5.tar.gz |
Add phpbb4 plugin (for trunk of phpBB)
Diffstat (limited to 'plugins/phpbb4')
-rw-r--r-- | plugins/phpbb4/JabberAuthPhpBB4.php | 38 | ||||
-rw-r--r-- | plugins/phpbb4/noweb_user.php | 17 | ||||
-rw-r--r-- | plugins/phpbb4/phpbb4.module | 10 | ||||
-rw-r--r-- | plugins/phpbb4/phpbb4_bootstrap.php | 51 |
4 files changed, 116 insertions, 0 deletions
diff --git a/plugins/phpbb4/JabberAuthPhpBB4.php b/plugins/phpbb4/JabberAuthPhpBB4.php new file mode 100644 index 0000000..e60cbae --- /dev/null +++ b/plugins/phpbb4/JabberAuthPhpBB4.php @@ -0,0 +1,38 @@ +<?php + +class JabberAuthPhpBB extends JabberAuth { + var $auth; + var $db; + + function __construct($auth, $db, $logpath) { + $this->logpath = $logpath; + parent::init(); + $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/phpbb4/noweb_user.php b/plugins/phpbb4/noweb_user.php new file mode 100644 index 0000000..3291222 --- /dev/null +++ b/plugins/phpbb4/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/phpbb4/phpbb4.module b/plugins/phpbb4/phpbb4.module new file mode 100644 index 0000000..22b4de6 --- /dev/null +++ b/plugins/phpbb4/phpbb4.module @@ -0,0 +1,10 @@ +<?php + +function phpbb4_init($config) { + $phpbb_root_path = $config['root_path']; + // Bootstrap the phpBB system. + require_once __DIR__ . '/phpbb4_bootstrap.php'; + // Load the plugin. + require_once __DIR__ . '/JabberAuthPhpBB4.php'; + return new JabberAuthPhpBB4($config['auth'], $config['db']); +} diff --git a/plugins/phpbb4/phpbb4_bootstrap.php b/plugins/phpbb4/phpbb4_bootstrap.php new file mode 100644 index 0000000..3f7dee5 --- /dev/null +++ b/plugins/phpbb4/phpbb4_bootstrap.php @@ -0,0 +1,51 @@ +<?php +define('IN_PHPBB', TRUE); +$phpEx = 'php'; + +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +require($phpbb_root_path . 'includes/startup.' . $phpEx); +require_once __DIR__ . '/noweb_user.php'; + +if (file_exists($phpbb_root_path . 'config.' . $phpEx)) +{ + require($phpbb_root_path . 'config.' . $phpEx); +} + +// Include files +require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/config.' . $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/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); + +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator($phpbb_root_path.'/config')); +$loader->load('services.yml'); + +$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); +$processor->process($phpbb_container); + +// Setup class loader first +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); + +// Instantiate some basic classes +$user = new noweb_user; +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); + +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); |