diff options
author | Christoph Burschka | 2012-11-01 00:01:08 +0100 |
---|---|---|
committer | Christoph Burschka | 2012-11-01 00:01:08 +0100 |
commit | 1a1ec38c95a25143bea1e3da38c65a60437d7883 (patch) | |
tree | 4784357112e6fce315bef1fc21848df7a1b50154 /main.php | |
parent | Huge overhaul to deal with the global variables more cleanly. Avoid globals w... (diff) | |
download | ejabberd-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.php | 35 |
1 files changed, 20 insertions, 15 deletions
@@ -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 |