2020-08-27 05:28:11 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web logout view file, $Date$, $Revision$
|
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
global $CLANG;
|
|
|
|
?>
|
|
|
|
<div id="modalLogout" class="modal" tabindex="-1" role="dialog">
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title"><?php echo validHtmlStr(ZM_WEB_TITLE) . ' ' . translate('Logout') ?></h5>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p><?php echo sprintf( $CLANG['CurrentLogin'], $user['Username'] ) ?></p>
|
2020-10-03 03:56:39 +08:00
|
|
|
<?php if ( canView('System') ) { ?>
|
2020-10-03 03:21:58 +08:00
|
|
|
<p>Other logged in users:<br/>
|
2020-10-03 04:04:56 +08:00
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
2020-10-03 03:21:58 +08:00
|
|
|
<tr>
|
2020-10-03 04:04:56 +08:00
|
|
|
<th class="text-left"><?php echo translate('Username') ?></th>
|
|
|
|
<th class="text-left"><?php echo translate('IPAddress') ?></th>
|
|
|
|
<th class="text-left"><?php echo translate('Last Access') ?></th>
|
2020-10-03 03:21:58 +08:00
|
|
|
</tr>
|
2020-10-03 04:04:56 +08:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
2020-10-03 03:21:58 +08:00
|
|
|
<?php
|
2020-10-03 03:56:39 +08:00
|
|
|
require_once('includes/User.php');
|
2021-06-12 23:57:10 +08:00
|
|
|
$result = dbQuery('SELECT * FROM Sessions ORDER BY access DESC LIMIT 1000');
|
|
|
|
if (!$result) return;
|
2020-10-03 03:21:58 +08:00
|
|
|
|
|
|
|
$current_session = $_SESSION;
|
2020-10-03 03:56:39 +08:00
|
|
|
zm_session_start();
|
2020-10-03 03:21:58 +08:00
|
|
|
|
2020-10-12 23:25:20 +08:00
|
|
|
$user_cache = array();
|
2020-10-03 03:21:58 +08:00
|
|
|
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
|
|
|
|
$_SESSION = array();
|
2021-06-12 23:57:10 +08:00
|
|
|
if (!session_decode($row['data'])) {
|
|
|
|
ZM\Warning('Failed to decode '.$row['data']);
|
2020-10-03 03:56:39 +08:00
|
|
|
continue;
|
|
|
|
}
|
2021-06-12 23:57:10 +08:00
|
|
|
if (isset($_SESSION['last_time'])) {
|
2020-10-03 03:56:39 +08:00
|
|
|
# This is a dead session
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-12 23:57:10 +08:00
|
|
|
if (!isset($_SESSION['username'])) {
|
2020-10-05 22:30:57 +08:00
|
|
|
# Not logged in
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-12 23:57:10 +08:00
|
|
|
if (isset($user_cache[$_SESSION['username']])) {
|
2020-10-12 23:25:20 +08:00
|
|
|
$user = $user_cache[$_SESSION['username']];
|
|
|
|
} else {
|
|
|
|
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
|
2021-06-12 23:57:10 +08:00
|
|
|
if (!$user) {
|
|
|
|
ZM\Debug('User not found for '.$_SESSION['username']);
|
2020-10-12 23:25:20 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$user_cache[$_SESSION['username']] = $user;
|
2020-10-03 03:56:39 +08:00
|
|
|
}
|
2020-10-03 03:21:58 +08:00
|
|
|
|
2020-10-03 04:04:56 +08:00
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td>'.$user->Username().'</td>
|
|
|
|
<td>'.$_SESSION['remoteAddr'].'</td>
|
|
|
|
<td>'.strftime(STRF_FMT_DATETIME_SHORTER, $row['access']).'</td>
|
|
|
|
</tr>
|
|
|
|
';
|
2020-10-03 03:21:58 +08:00
|
|
|
} # end while
|
2020-10-03 03:56:39 +08:00
|
|
|
session_abort();
|
2020-10-03 03:21:58 +08:00
|
|
|
$_SESSION = $current_session;
|
|
|
|
?>
|
2020-10-03 04:04:56 +08:00
|
|
|
</tbody>
|
2020-10-03 03:21:58 +08:00
|
|
|
</table>
|
2020-10-03 03:56:39 +08:00
|
|
|
<?php } # end if canView(System) ?>
|
2020-08-27 05:28:11 +08:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
2020-10-21 00:31:38 +08:00
|
|
|
<form name="logoutForm" id="logoutForm" method="post" action="?view=logout">
|
2020-09-19 23:44:05 +08:00
|
|
|
<?php
|
|
|
|
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
|
|
|
|
echo getCSRFinputHTML();
|
|
|
|
?>
|
2020-08-27 05:28:11 +08:00
|
|
|
<button type="submit" name="action" value="logout"><?php echo translate('Logout') ?></button>
|
|
|
|
<?php if ( ZM_USER_SELF_EDIT ) echo '<button type="submit" name="action" value="config">'.translate('Config').'</button>'.PHP_EOL; ?>
|
|
|
|
<button type="button" data-dismiss="modal"><?php echo translate('Cancel') ?></button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|