summaryrefslogtreecommitdiff
path: root/main.php
diff options
context:
space:
mode:
authorChristoph Burschka2012-11-01 00:01:08 +0100
committerChristoph Burschka2012-11-01 00:01:08 +0100
commit1a1ec38c95a25143bea1e3da38c65a60437d7883 (patch)
tree4784357112e6fce315bef1fc21848df7a1b50154 /main.php
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 'main.php')
-rwxr-xr-x[-rw-r--r--]main.php35
1 files changed, 20 insertions, 15 deletions
diff --git a/main.php b/main.php
index 2388e8f..5d6c9dd 100644..100755
--- a/main.php
+++ b/main.php
@@ -1,23 +1,28 @@
#!/usr/bin/php
<?php
-// by Aran, October 2012
-
define('ROOT', __DIR__ . '/');
-require_once ROOT . 'config.php';
-$err = fopen('php://stderr', 'w');
+require_once ROOT . 'core/EjabberdAuth.php';
+require_once ROOT . 'core/EjabberdAuthBridge.php';
+
+main();
-if (!empty($config['plugin']) && !empty($config[$config['plugin']])) {
- $plugin_file = 'plugins/' . $config['plugin'] . '/' . $config['plugin'] . '.module';
- if (file_exists(ROOT . $plugin_file)) {
- require_once ROOT . $plugin_file;
- $function = $config['plugin'] . '_init';
- $function($config[$config['plugin']])->run();
+function main() {
+ require_once ROOT . 'config.php';
+ $err = fopen('php://stderr', 'w');
+ if (!empty($config['plugin']) && !empty($config[$config['plugin']])) {
+ $plugin_file = 'plugins/' . $config['plugin'] . '/' . $config['plugin'] . '.module';
+ if (file_exists(ROOT . $plugin_file)) {
+ require_once ROOT . $plugin_file;
+ $function = $config['plugin'] . '_init';
+ $auth = new EjabberdAuth($config, $function($config[$config['plugin']]));
+ $auth->run();
+ }
+ else {
+ fwrite($err, "Plugin <{$plugin_file}> not found.\n");
+ }
}
else {
- fwrite($err, "Plugin <{$plugin_file}> not found.\n");
+ fwrite($err, 'Incomplete configuration: $config[\'plugin\'] must be set to <name>, and $config[<name>] populated.' . "\n");
}
-}
-else {
- fwrite($err, 'Incomplete configuration: $config[\'plugin\'] must be set to <name>, and $config[<name>] populated.' . "\n");
-}
+} \ No newline at end of file