summaryrefslogtreecommitdiff
path: root/main.php
blob: 5d6c9dd5a36ec6017fff3e3149606b8660a2847f (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
28
#!/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';
  $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, 'Incomplete configuration: $config[\'plugin\'] must be set to <name>, and $config[<name>] populated.' . "\n");
  }
}