diff options
author | Christoph Burschka | 2014-01-17 16:10:10 +0100 |
---|---|---|
committer | Christoph Burschka | 2014-01-17 16:10:10 +0100 |
commit | 045012f9b7619d441d8c5b5800519cb7ac6891b6 (patch) | |
tree | 4db383cb85c40b1fdc1b4b8c4413950d9134cedf /plugins/session | |
parent | Apparently that didn't need to be encoded. (diff) | |
download | ejabberd-auth-php-045012f9b7619d441d8c5b5800519cb7ac6891b6.tar.gz |
Okay, the last patch was actually rubbish.
It turns out that you can't hope to bootstrap more
than one PHP-based software without messing stuff
up, particularly because they rely on global variables
without exception. If it is risky and unpredictable for
different systems, it is completely impossible with multiple
instances of the same.
Therefore, the ability to use multiple plugins (and the
accompanying config.php structure) has been removed. The
only plugin that can be used in conjunction with another
is session.
Diffstat (limited to 'plugins/session')
-rw-r--r-- | plugins/session/README.md | 12 | ||||
-rw-r--r-- | plugins/session/install.php | 19 | ||||
-rw-r--r-- | plugins/session/install.sql | 7 | ||||
-rw-r--r-- | plugins/session/main.php | 8 |
4 files changed, 27 insertions, 19 deletions
diff --git a/plugins/session/README.md b/plugins/session/README.md index 3412f7d..6fccc82 100644 --- a/plugins/session/README.md +++ b/plugins/session/README.md @@ -26,16 +26,12 @@ The control flow is like this: Installation ------------ -This plugin uses a database table, described in the packaged install.sql file. -Install it with this command: +First, configure the database connection in `config.php` by filling in the host, +database, user, password and table name. - cat ./install.sql | replace '{TAB}' '<tablename>' | \ - mysql -h <host> -D <db> -u <user> -p<password> +Then, install the table by running `php plugins/session/install.php`. -Next, you need to configure the database connection both in the main configuration -file and in the local `./config.php` of this plugin. - -Finally, link the `www/rpc.php` file inside your website root somewhere inside +Finally, link the `www/rpc.php` file in your website root somewhere within your forum's cookie domain and path (most forums set the path to `/`, so the domain should be sufficient). diff --git a/plugins/session/install.php b/plugins/session/install.php new file mode 100644 index 0000000..29771b3 --- /dev/null +++ b/plugins/session/install.php @@ -0,0 +1,19 @@ +<?php + +define('ROOT', __DIR__ . '/../../'); + +require_once ROOT . 'plugins/session/session.module'; +require_once ROOT . 'config.php'; + +$db = session_db($config['session']['mysql']); + +$db->exec(sprintf(<<<SQL +CREATE TABLE `%s` ( + username VARCHAR(255), + secret VARCHAR(40), + created INT, + PRIMARY KEY(username, secret), + INDEX(created) +); +SQL +, $config['session']['mysql']['tablename'])); diff --git a/plugins/session/install.sql b/plugins/session/install.sql deleted file mode 100644 index ecf59f9..0000000 --- a/plugins/session/install.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE `{TAB}` ( - username VARCHAR(255), - secret VARCHAR(40), - created INT, - PRIMARY KEY(username, secret), - INDEX(created) -); diff --git a/plugins/session/main.php b/plugins/session/main.php index 18bacd8..49973a7 100644 --- a/plugins/session/main.php +++ b/plugins/session/main.php @@ -5,17 +5,17 @@ define('ROOT', __DIR__ . '/../../'); require_once ROOT . 'plugins/session/session.module'; function create_key($salt) { - require_once __DIR__ . '/config.php'; - $db = session_db($config['mysql']); + require_once ROOT . '/config.php'; + $db = session_db($config['session']['mysql']); $plugin = $config['plugin']; - $plugin_conf = $config['config']; + $plugin_conf = $config['plugin_conf']; require_once ROOT . 'plugins/' . $plugin . '/' . $plugin . '.module'; $function = $plugin . '_session'; $username = function_exists($function) ? $function($plugin_conf) : NULL; if ($username) { $entry = ['user' => $username, 'secret' => sha1($salt . time() . mt_rand()), 'time' => time()]; - $query = $db->prepare(sprintf('INSERT INTO `%s` (`username`, `secret`, `created`) VALUES (:user, :secret, :time);', $config['mysql']['tablename'])); + $query = $db->prepare(sprintf('INSERT INTO `%s` (`username`, `secret`, `created`) VALUES (:user, :secret, :time);', $config['session']['mysql']['tablename'])); $query->execute([':user' => $entry['user'], ':secret' => $entry['secret'], ':time' => $entry['time']]); return $entry; } |