diff options
author | Christoph Burschka | 2014-01-17 16:10:10 +0100 |
---|---|---|
committer | Christoph Burschka | 2014-01-17 16:10:10 +0100 |
commit | 045012f9b7619d441d8c5b5800519cb7ac6891b6 (patch) | |
tree | 4db383cb85c40b1fdc1b4b8c4413950d9134cedf /core/EjabberdAuth.php | |
parent | Apparently that didn't need to be encoded. (diff) | |
download | ejabberd-auth-php-045012f9b7619d441d8c5b5800519cb7ac6891b6.tar.gz |
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.
Diffstat (limited to 'core/EjabberdAuth.php')
-rw-r--r-- | core/EjabberdAuth.php | 34 |
1 files changed, 11 insertions, 23 deletions
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; - } } |