diff options
author | Christoph Burschka | 2012-10-30 15:28:52 +0100 |
---|---|---|
committer | Christoph Burschka | 2012-10-30 15:28:52 +0100 |
commit | 12f6c2acb29cbea6f41d1152eb27affa358c196f (patch) | |
tree | de6a06f62967f9a98db3e8e254cae457536001cd | |
parent | A version compatible with the stable phpBB3 (diff) | |
download | ejabberd-auth-php-12f6c2acb29cbea6f41d1152eb27affa358c196f.tar.gz |
Refactor to a general, flexible and extensible architecture.
-rw-r--r-- | config.php | 4 | ||||
-rw-r--r-- | config.sample.php | 25 | ||||
-rw-r--r-- | core/JabberAuth.php (renamed from classes/JabberAuth.php) | 8 | ||||
-rw-r--r-- | main.php | 27 | ||||
-rw-r--r-- | plugins/phpbb3/JabberAuthPhpBB.php (renamed from classes/JabberAuthPhpBB.php) | 0 | ||||
-rw-r--r-- | plugins/phpbb3/noweb_user.php (renamed from phpbb-bridge/noweb_user.php) | 0 | ||||
-rw-r--r-- | plugins/phpbb3/phpbb_bootstrap.php (renamed from phpbb-bridge/phpbb_bootstrap.php) | 0 |
7 files changed, 49 insertions, 15 deletions
diff --git a/config.php b/config.php deleted file mode 100644 index dd5f8f1..0000000 --- a/config.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -$phpbb_root_path = '/home/arancaytar/development/phpbb3/phpBB/'; -$log_path = __DIR__ . '/logs/';
\ No newline at end of file diff --git a/config.sample.php b/config.sample.php new file mode 100644 index 0000000..0f1b9fa --- /dev/null +++ b/config.sample.php @@ -0,0 +1,25 @@ +<?php + +/* copy this file to config.php */ + +$config['plugin'] = 'phpbb3'; +$config['log_path'] = __DIR__ . '/logs/'; + +$config['phpbb3'] = array( + 'root_path' => '' /* path to your phpBB3 installation */, +); + +$config['phpbb4'] = array( + 'root_path' => '' /* path to your phpBB4 installation */, +); + +$config['drupal7'] = array( + 'root_path' => '' /* path to your Drupal 7 installation */, + 'site' => 'default' /* site directory */, +); + +$config['drupal8'] = array( + 'root_path' => '' /* path to your Drupal 7 installation */, + 'site' => 'default' /* site directory */, +); + diff --git a/classes/JabberAuth.php b/core/JabberAuth.php index 69bb858..3e9d4df 100644 --- a/classes/JabberAuth.php +++ b/core/JabberAuth.php @@ -12,9 +12,15 @@ abstract class JabberAuth { abstract function removeuser($username, $server); function init() { + global $config; $this->stdin = fopen('php://stdin', 'r'); $this->stdout = fopen('php://stdout', 'w'); - $this->logfile = fopen($this->logpath . 'activity-' . date('Y-m-d') . '.log', 'a'); + 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'); + } + else { + $this->logfile = fopen('php://stderr', 'w'); + } $this->log('Starting...'); $this->running = TRUE; } @@ -2,15 +2,22 @@ <?php // by Aran, October 2012 -// Bootstrap the phpBB system. -define('ROOT', __DIR__); -require_once __DIR__ . '/config.php'; -require_once __DIR__ . '/phpbb-bridge/phpbb_bootstrap.php'; -// Load the classes. -require_once __DIR__ . '/classes/JabberAuth.php'; -require_once __DIR__ . '/classes/JabberAuthPhpBB.php'; +define('ROOT', __DIR__ . '/'); +require_once ROOT . 'config.php'; +$err = fopen('php://stderr', 'w'); -// Launch the script. -$main = new JabberAuthPhpBB($auth, $db, $log_path); -$main->run(); +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(); + } + 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"); +} diff --git a/classes/JabberAuthPhpBB.php b/plugins/phpbb3/JabberAuthPhpBB.php index e60cbae..e60cbae 100644 --- a/classes/JabberAuthPhpBB.php +++ b/plugins/phpbb3/JabberAuthPhpBB.php diff --git a/phpbb-bridge/noweb_user.php b/plugins/phpbb3/noweb_user.php index 3291222..3291222 100644 --- a/phpbb-bridge/noweb_user.php +++ b/plugins/phpbb3/noweb_user.php diff --git a/phpbb-bridge/phpbb_bootstrap.php b/plugins/phpbb3/phpbb_bootstrap.php index 4ede950..4ede950 100644 --- a/phpbb-bridge/phpbb_bootstrap.php +++ b/plugins/phpbb3/phpbb_bootstrap.php |