summaryrefslogtreecommitdiff
path: root/main.php
blob: f9c5b833efafa1df363b73c977dfcb7c52bce345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/php
<?php

define('ROOT', __DIR__ . '/');
require_once ROOT . 'core/EjabberdAuth.php';
require_once ROOT . 'core/EjabberdAuthBridge.php';

main();

function main() {
  require_once ROOT . 'config.php';
  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(STDERR, "Plugin <{$plugin_file}> not found.\n");
    }
  }
  else {
    fwrite(STDERR, 'Incomplete configuration: $config[\'plugin\'] must be set to <name>, and $config[<name>] populated.' . "\n");
  }
}