-
-
Notifications
You must be signed in to change notification settings - Fork 531
/
logout.php
executable file
·104 lines (96 loc) · 3.06 KB
/
logout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
declare(strict_types=1);
/**
* Teampass - a collaborative passwords manager.
* ---
* This library 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.
* ---
*
* @project Teampass
* @version 3.0.0.23
* @file logout.php
* ---
*
* @author Nils Laumaillé (nils@teampass.net)
*
* @copyright 2009-2023 Teampass.net
*
* @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0
* ---
*
* @see https://www.teampass.net
*/
require_once '../../sources/SecureHandler.php';
session_name('teampass_session');
session_start();
// Load superglobal library
require_once '../../includes/libraries/protect/SuperGlobal/SuperGlobal.php';
$superGlobal = new protect\SuperGlobal\SuperGlobal();
$get = [];
$get['user_id'] = $superGlobal->get('user_id', 'GET');
// Update table by deleting ID
if (isset($_SESSION['user_id']) === true && empty($_SESSION['user_id']) === false) {
$user_id = $_SESSION['user_id'];
} elseif (isset($get['token']) === true && empty($get['token']) === false) {
$user_token = $get['token'];
} else {
$user_id = '';
$user_token = '';
}
if (empty($user_id) === false && isset($_SESSION['CPM']) === true) {
// connect to the server
include_once '../../sources/main.functions.php';
include_once '../../includes/config/settings.php';
include_once '../../includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = DB_HOST;
DB::$user = DB_USER;
DB::$password = defuseReturnDecrypted(DB_PASSWD, $SETTINGS);
DB::$dbName = DB_NAME;
DB::$port = DB_PORT;
DB::$encoding = DB_ENCODING;
DB::$ssl = DB_SSL;
DB::$connect_options = DB_CONNECT_OPTIONS;
// clear in db
DB::update(
DB_PREFIX.'users',
[
'key_tempo' => '',
'timestamp' => '',
'session_end' => '',
],
'id=%i || key_tempo=%s',
$user_id,
$user_token
);
//Log into DB the user's disconnection
if (isset($SETTINGS['log_connections']) === true
&& (int) $SETTINGS['log_connections'] === 1
) {
include_once '../../sources/main.functions.php';
logEvents($SETTINGS, 'user_connection', 'disconnect', (string) $user_id, isset($_SESSION['login']) === true ? $_SESSION['login'] : '');
}
}
// erase session table
session_destroy();
$_SESSION = [];
require_once '../../sources/SecureHandler.php';
session_name('teampass_session');
session_start();
$_SESSION['CPM'] = 1;
echo '
<script type="text/javascript" src="../../plugins/store.js/dist/store.everything.min.js"></script>
<script language="javascript" type="text/javascript">
<!--
// Clear localstorage
store.remove("teampassApplication");
store.remove("teampassSettings");
store.remove("teampassUser");
store.remove("teampassItem");
sessionStorage.clear();
setTimeout(function() {
document.location.href="../../index.php"
}, 1);
-->
</script>';