forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogout.php
74 lines (67 loc) · 2.13 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
<?php
/**
*
* @package logout.php
* @author Nils Laumaillé <[email protected]>
* @version 2.1.27
* @copyright 2009-2019 Nils Laumaillé
* @license GNU GPL-3.0
* @link https://www.teampass.net
*
* 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.
*/
require_once 'sources/SecureHandler.php';
session_start();
// Update table by deleting ID
if (isset($_SESSION['user_id']) && empty($_SESSION['user_id']) === false) {
$user_id = $_SESSION['user_id'];
} elseif (isset($_GET['user_id']) && empty($_GET['user_id']) === false) {
$user_id = $_GET['user_id'];
} else {
$user_id = "";
}
if (empty($user_id) === false && isset($_SESSION['CPM']) === true) {
// connect to the server
require_once './sources/main.functions.php';
require_once './includes/config/settings.php';
require_once './includes/libraries/Database/Meekrodb/db.class.php';
$pass = defuse_return_decrypted($pass);
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$encoding = $encoding;
DB::$error_handler = true;
$link = mysqli_connect($server, $user, $pass, $database, $port);
$link->set_charset($encoding);
// clear in db
DB::update(
$pre."users",
array(
'key_tempo' => '',
'timestamp' => '',
'session_end' => ''
),
"id=%i",
$user_id
);
//Log into DB the user's disconnection
if (isset($_SESSION['settings']['log_connections']) && $_SESSION['settings']['log_connections'] == 1) {
require_once 'sources/main.functions.php';
logEvents('user_connection', 'disconnection', $user_id, @$_SESSION['login']);
}
}
// erase session table
session_unset();
session_destroy();
$_SESSION = array();
echo '
<script language="javascript" type="text/javascript">
<!--
sessionStorage.clear();
setTimeout(function(){document.location.href="index.php"}, 1);
-->
</script>';