From 045012f9b7619d441d8c5b5800519cb7ac6891b6 Mon Sep 17 00:00:00 2001 From: Christoph Burschka Date: Fri, 17 Jan 2014 16:10:10 +0100 Subject: Okay, the last patch was actually rubbish. It turns out that you can't hope to bootstrap more than one PHP-based software without messing stuff up, particularly because they rely on global variables without exception. If it is risky and unpredictable for different systems, it is completely impossible with multiple instances of the same. Therefore, the ability to use multiple plugins (and the accompanying config.php structure) has been removed. The only plugin that can be used in conjunction with another is session. --- core/EjabberdAuth.php | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'core/EjabberdAuth.php') diff --git a/core/EjabberdAuth.php b/core/EjabberdAuth.php index c3cdff8..d88c990 100644 --- a/core/EjabberdAuth.php +++ b/core/EjabberdAuth.php @@ -7,13 +7,13 @@ class EjabberdAuth { var $running; - function __construct($meta, $bridges) { - $this->bridges = $bridges; - foreach ($bridges as $domain) foreach ($domain as $bridge) { - $bridge->parent = $this; - } - if (!empty($meta['log_path']) && is_dir($meta['log_path']) && is_writable($meta['log_path'])) - $this->logfile = fopen($meta['log_path'] . 'activity-' . date('Y-m-d') . '.log', 'a'); + function __construct($config, $bridge, $session) { + $this->bridge = $bridge; + $this->session = $session; + $this->bridge->parent = $this; + $this->session->parent = $this; + if (!empty($config['log_path']) && is_dir($config['log_path']) && is_writable($config['log_path'])) + $this->logfile = fopen($config['log_path'] . 'activity-' . date('Y-m-d') . '.log', 'a'); else $this->logfile = STDERR; $this->log('Initialized.'); } @@ -67,13 +67,13 @@ class EjabberdAuth { // Don't log the password, obviously. $this->log("Executing $command on {$username}@{$server}"); - $domain = array_key_exists($server, $this->bridges) ? $server : '*'; - switch ($command) { case 'isuser': - return $this->isuser($domain, $username, $server); + return $this->session->isuser($username, $server) || + $this->bridge->isuser($username, $server); case 'auth': - return $this->auth($domain, $username, $server, $password); + return $this->session->auth($username, $server, $password) || + $this->bridge->auth($username, $server, $password); case 'setpass': case 'tryregister': case 'removeuser': @@ -83,16 +83,4 @@ class EjabberdAuth { $this->stop(); } } - - function isuser($domain, $username, $server) { - foreach ($this->bridges[$domain] as $bridge) - if ($bridge->isuser($username, $server)) return TRUE; - return FALSE; - } - - function auth($domain, $username, $server, $password) { - foreach ($this->bridges[$domain] as $bridge) - if ($bridge->auth($username, $server, $password)) return TRUE; - return FALSE; - } } -- cgit v1.1