summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorChristoph Burschka2012-11-01 00:01:08 +0100
committerChristoph Burschka2012-11-01 00:01:08 +0100
commit1a1ec38c95a25143bea1e3da38c65a60437d7883 (patch)
tree4784357112e6fce315bef1fc21848df7a1b50154 /core
parentHuge overhaul to deal with the global variables more cleanly. Avoid globals w... (diff)
downloadejabberd-auth-php-1a1ec38c95a25143bea1e3da38c65a60437d7883.tar.gz
Huge overhaul to deal with the global variables more cleanly. Avoid globals wherever possible, to avoid collisions with CMS systems.
Diffstat (limited to 'core')
-rw-r--r--core/EjabberdAuth.php30
1 files changed, 13 insertions, 17 deletions
diff --git a/core/EjabberdAuth.php b/core/EjabberdAuth.php
index 3e9d4df..d9b9776 100644
--- a/core/EjabberdAuth.php
+++ b/core/EjabberdAuth.php
@@ -1,20 +1,16 @@
<?php
-// Arancaytar, October 2012
-// This is a general PHP implementation of the ejabberd auth protocol.
-abstract class JabberAuth {
+/**
+ * Runs constantly and takes requests from an input stream
+ * as specified in the ejabberd auth protocol.
+ */
+class EjabberdAuth {
var $running;
- abstract function isuser($username, $server);
- abstract function auth($username, $server, $password);
- abstract function setpass($username, $server, $password);
- abstract function tryregister($username, $server, $password);
- abstract function removeuser($username, $server);
-
- function init() {
- global $config;
+ function __construct($config, EjabberdAuthBridge $bridge) {
$this->stdin = fopen('php://stdin', 'r');
$this->stdout = fopen('php://stdout', 'w');
+ $this->bridge = $bridge;
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');
}
@@ -74,22 +70,22 @@ abstract class JabberAuth {
switch ($command) {
case 'isuser':
list($username, $server) = $args;
- return $this->isuser($username, $server);
+ return $this->bridge->isuser($username, $server);
case 'auth':
list($username, $server, $password) = $args;
- return $this->auth($username, $server, $password);
+ return $this->bridge->auth($username, $server, $password);
case 'setpass':
list($username, $server, $password) = $args;
- return $this->setpass($username, $server, $password);
+ return $this->bridge->setpass($username, $server, $password);
case 'tryregister':
list($username, $server, $password) = $args;
- return $this->tryregister($username, $server, $password);
+ return $this->bridge->tryregister($username, $server, $password);
case 'removeuser':
list($username, $server) = $args;
- return $this->removeuser($username, $server);
+ return $this->bridge->removeuser($username, $server);
case 'removeuser3':
list($username, $server, $password) = $args;
- return $this->auth($username, $server, $password) && $this->removeuser($username, $password);
+ return $this->bridge->auth($username, $server, $password) && $this->bridge->removeuser($username, $password);
default:
$this->stop();
}