summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorChristoph Burschka2012-10-30 15:28:52 +0100
committerChristoph Burschka2012-10-30 15:28:52 +0100
commit12f6c2acb29cbea6f41d1152eb27affa358c196f (patch)
treede6a06f62967f9a98db3e8e254cae457536001cd /plugins
parentA version compatible with the stable phpBB3 (diff)
downloadejabberd-auth-php-12f6c2acb29cbea6f41d1152eb27affa358c196f.tar.gz
Refactor to a general, flexible and extensible architecture.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/phpbb3/JabberAuthPhpBB.php38
-rw-r--r--plugins/phpbb3/noweb_user.php17
-rw-r--r--plugins/phpbb3/phpbb_bootstrap.php40
3 files changed, 95 insertions, 0 deletions
diff --git a/plugins/phpbb3/JabberAuthPhpBB.php b/plugins/phpbb3/JabberAuthPhpBB.php
new file mode 100644
index 0000000..e60cbae
--- /dev/null
+++ b/plugins/phpbb3/JabberAuthPhpBB.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/phpbb3/noweb_user.php b/plugins/phpbb3/noweb_user.php
new file mode 100644
index 0000000..3291222
--- /dev/null
+++ b/plugins/phpbb3/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/phpbb3/phpbb_bootstrap.php b/plugins/phpbb3/phpbb_bootstrap.php
new file mode 100644
index 0000000..4ede950
--- /dev/null
+++ b/plugins/phpbb3/phpbb_bootstrap.php
@@ -0,0 +1,40 @@
+<?php
+define('IN_PHPBB', TRUE);
+$phpEx = 'php';
+
+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();