Commit ef2bf4d6 authored by Richard Mansfield's avatar Richard Mansfield

Close login sessions when closing site

Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent a0e7e16f
......@@ -100,6 +100,8 @@ function close_site_submit(Pieform $form, $values) {
global $closed;
if (!$closed && $values['close']) {
set_config('siteclosedbyadmin', 1);
require_once(get_config('docroot') . 'auth/session.php');
remove_user_sessions();
}
else if ($closed && !$values['close']) {
set_config('siteclosedbyadmin', 0);
......
......@@ -275,16 +275,27 @@ function insert_messages() {
}
function remove_user_sessions($userid) {
function remove_user_sessions($userid=null) {
global $sessionpath, $USER;
if (!$sessionids = get_column('usr_session', 'session', 'usr', $userid)) {
if (is_null($userid)) {
$sessionids = get_column('usr_session', 'session');
}
else {
$sessionids = get_column('usr_session', 'session', 'usr', $userid);
}
if (empty($sessionids)) {
return;
}
$alive = array();
$dead = array();
$sid = $USER->get('sessionid');
foreach ($sessionids as $sessionid) {
if ($sessionid == $sid) {
continue;
}
$file = $sessionpath;
for ($i = 0; $i < 3; $i++) {
$file .= '/' . substr($sessionid, $i, 1);
......@@ -306,8 +317,6 @@ function remove_user_sessions($userid) {
return;
}
$sid = $USER->get('sessionid');
session_commit();
foreach ($alive as $sessionid) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment