forked from nilsteampassnet/TeamPass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.php
123 lines (112 loc) · 4 KB
/
error.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?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
*
* @file error.php
* ---
*
* @author Nils Laumaillé ([email protected])
*
* @copyright 2009-2022 Teampass.net
*
* @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0
* ---
*
* @see https://www.teampass.net
*/
if (file_exists('../sources/SecureHandler.php')) {
include_once '../sources/SecureHandler.php';
} elseif (file_exists('./sources/SecureHandler.php')) {
include_once './sources/SecureHandler.php';
} else {
throw new Exception("Error file '/sources/SecureHandler.php' not exists", 1);
}
if (isset($_SESSION) === false) {
session_name('teampass_session');
session_start();
}
if (isset($_SESSION['CPM']) === false || $_SESSION['CPM'] !== 1) {
die('Hacking attempt...');
}
// Load config
if (file_exists('../includes/config/tp.config.php')) {
include_once '../includes/config/tp.config.php';
} elseif (file_exists('./includes/config/tp.config.php')) {
include_once './includes/config/tp.config.php';
} else {
throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1);
}
if (
filter_input(INPUT_POST, 'session', FILTER_SANITIZE_STRING) !== null
&& filter_input(INPUT_POST, 'session', FILTER_SANITIZE_STRING) === 'expired'
) {
//Include files
require_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
require_once $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
require_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
// connect to DB
require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
if (defined('DB_PASSWD_CLEAR') === false) {
define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
}
// Include main functions used by TeamPass
require_once 'sources/main.functions.php';
// Update table by deleting ID
if (isset($_SESSION['user_id'])) {
DB::update(
DB_PREFIX . 'users',
[
'key_tempo' => '',
],
'id=%i',
$_SESSION['user_id']
);
}
//Log into DB the user's disconnection
if (isset($SETTINGS['log_connections']) && (int) $SETTINGS['log_connections'] === 1) {
logEvents($SETTINGS, 'user_connection', 'disconnect', (string) $_SESSION['user_id'], $_SESSION['login']);
}
} else {
require_once $SETTINGS['cpassman_dir'] . '/sources/main.queries.php';
$errorCode = '';
if (@$_SESSION['error']['code'] === ERR_NOT_ALLOWED) {
$errorCode = 'ERROR NOT ALLOWED';
} elseif (@$_SESSION['error']['code'] === ERR_NOT_EXIST) {
$errorCode = 'ERROR NOT EXISTS';
} elseif (@$_SESSION['error']['code'] === ERR_SESS_EXPIRED) {
$errorCode = 'ERROR SESSION EXPIRED';
} elseif (@$_SESSION['error']['code'] === ERR_VALID_SESSION) {
$errorCode = 'ERROR NOT ALLOWED';
} ?>
<!-- Main content -->
<section class="content">
<div class="error-page" style="width:100%;">
<h2 class="headline text-danger">500</h2>
<div class="error-content">
<h3><i class="fa fa-warning text-danger"></i> Oops! <?php echo $errorCode; ?>.</h3>
<p>
For security reason, you have been disconnected. Click to <a href="./includes/core/logout.php?user_id=" + <?php echo isset($_SESSION['user_id']) === true ? $_SESSION['user_id'] : ''; ?>>log in</a>.
</p>
</div>
<!-- /.error-content -->
</div>
<!-- /.error-page -->
</section>
<!-- /.content -->
<?php
}
// erase session table
$_SESSION = [];
// Kill session
session_destroy();
die;
?>