diff options
author | Christoph Burschka | 2014-01-16 04:25:51 +0100 |
---|---|---|
committer | Christoph Burschka | 2014-01-16 04:25:51 +0100 |
commit | 86a4fd69d53b61a624dfc332c7a0e70b9a79218a (patch) | |
tree | 4f9c652f7ea30737b29a0864ac1806919cbc1314 /plugins/session/www | |
parent | Formatting of README headings. (diff) | |
download | ejabberd-auth-php-86a4fd69d53b61a624dfc332c7a0e70b9a79218a.tar.gz |
Implement smf2_session and finish RPC code. (#1)
This patch should be ready for testing with SMF.
(cburschka/cadence/#31)
Diffstat (limited to 'plugins/session/www')
-rw-r--r-- | plugins/session/www/rpc.php | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/plugins/session/www/rpc.php b/plugins/session/www/rpc.php index 58f3634..fca85a0 100644 --- a/plugins/session/www/rpc.php +++ b/plugins/session/www/rpc.php @@ -1,25 +1,16 @@ <?php -define('ROOT', __DIR__ . '/../../../'); -define('SESS_ROOT' , __DIR__ . '/../'); +define('SESS_ROOT', __DIR__ . '/../'); -main(); +require_once SESS_ROOT . 'main.php'; -function main() { - require_once ROOT . 'config.php'; - require_once SESS_ROOT . 'session.module'; - $bridge = session_init($config['session']); - $plugin = $config['session']['plugin']; - $plugin_conf = $config['session']['plugins'][$plugin_conf]; - $plugin_id = $plugin_conf['file']; - require_once SESS_ROOT . 'plugins/' . $plugin_id . '/' . $plugin_id . '.module'; - $function = $plugin_id . '_authenticate'; - $username = $function($plugin_conf); - if ($username) { - $entry = ['user' => $username, 'secret' => sha1($_POST['salt'] . time() . mt_rand()), 'time' => time()]; - $bridge->create($entry); - header('Content-type: text/plain; charset=UTF-8'); - print json_encode($entry); - } - else header('HTTP/1.1 403 Forbidden'); +$entry = (!empty($_POST['salt']) && strlen($_POST['salt']) >= 16) ? + create_key($_POST['salt']) : FALSE; + +if ($entry) { + header('Content-type: text/plain; charset=UTF-8'); + print json_encode($entry); +} +else { + header('HTTP/1.1 403 Forbidden'); } |