summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/session/README.md12
-rw-r--r--plugins/session/install.php19
-rw-r--r--plugins/session/install.sql7
-rw-r--r--plugins/session/main.php8
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;
}