Passed
Push — master ( 5a3ed5...a919c1 )
by Nils
06:37 queued 14s
created
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Teampass - a collaborative passwords manager.
7
 * ---
8
 * This file is part of the TeamPass project.
9
 * 
10
 * TeamPass is free software: you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, version 3 of the License.
13
 * 
14
 * TeamPass is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU General Public License for more details.
18
 * 
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21
 * 
22
 * Certain components of this file may be under different licenses. For
23
 * details, see the `licenses` directory or individual file headers.
24
 * ---
25
 * @file      index.php
26
 * @author    Nils Laumaillé ([email protected])
27
 * @copyright 2009-2025 Teampass.net
28
 * @license   GPL-3.0
29
 * @see       https://www.teampass.net
30
 */
31
32
use voku\helper\AntiXSS;
33
use TeampassClasses\SessionManager\SessionManager;
34
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
35
use TeampassClasses\Language\Language;
36
use TeampassClasses\ConfigManager\ConfigManager;
37
38
// Security Headers
39
header('X-XSS-Protection: 1; mode=block');
40
// deepcode ignore TooPermissiveXFrameOptions: Not the case as sameorigin is used
41
header('X-Frame-Options: SameOrigin');
42
43
// Cache Headers
44
header("Cache-Control: no-cache, no-store, must-revalidate");
45
header("Pragma: no-cache");
46
header("Expires: 0");
47
48
// **PREVENTING SESSION HIJACKING**
49
// Prevents javascript XSS attacks aimed to steal the session ID
50
//ini_set('session.cookie_httponly', 1);
51
// **PREVENTING SESSION FIXATION**
52
// Session ID cannot be passed through URLs
53
//ini_set('session.use_only_cookies', 1);
54
// Uses a secure connection (HTTPS) if possible
55
//ini_set('session.cookie_secure', 0);
56
//ini_set('session.cookie_samesite', 'Lax');
57
// Before we start processing, we should abort no install is present
58
if (file_exists(__DIR__.'/includes/config/settings.php') === false) {
59
    // This should never happen, but in case it does
60
    // this means if headers are sent, redirect will fallback to JS
61
    if (headers_sent()) {
62
        echo '<script language="javascript" type="text/javascript">document.location.replace("install/install.php");</script>';
63
    } else {
64
        header('Location: install/install.php');
65
    }
66
    // Now either way, we should stop processing further
67
    exit;
68
}
69
70
// initialise CSRFGuard library
71
require_once __DIR__.'/includes/libraries/csrfp/libs/csrf/csrfprotector.php';
72
csrfProtector::init();
73
74
// Load functions
75
require_once __DIR__. '/includes/config/include.php';
76
require_once __DIR__.'/sources/main.functions.php';
77
78
// init
79
loadClasses();
80
$session = SessionManager::getSession();
81
82
// Random encryption key
83
if ($session->get('key') === null)
84
    $session->set('key', generateQuickPassword(30, false));
85
86
$request = SymfonyRequest::createFromGlobals();
87
$configManager = new ConfigManager(__DIR__, $request->getRequestUri());
88
$SETTINGS = $configManager->getAllSettings();
89
$antiXss = new AntiXSS();
90
$session->set('encryptClientServer', (int) $SETTINGS['encryptClientServer'] ?? 1);
91
92
// Quick major version check -> upgrade needed?
93
if (isset($SETTINGS['teampass_version']) === true && version_compare(TP_VERSION, $SETTINGS['teampass_version']) > 0) {
94
    $session->invalidate();
95
    // Perform redirection
96
    if (headers_sent()) {
97
        echo '<script language="javascript" type="text/javascript">document.location.replace("install/install.php");</script>';
98
    } else {
99
        header('Location: install/upgrade.php');
100
    }
101
    // No other way, we should stop processing further
102
    exit;
103
}
104
105
106
$SETTINGS = $antiXss->xss_clean($SETTINGS);
107
108
// Load Core library
109
require_once $SETTINGS['cpassman_dir'] . '/sources/core.php';
110
// Prepare POST variables
111
$post_language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
112
$session_user_language = $session->get('user-language');
113
$session_user_admin = $session->get('user-admin');
114
$session_user_human_resources = (int) $session->get('user-can_manage_all_users');
115
$session_name = $session->get('user-name');
116
$session_lastname = $session->get('user-lastname');
117
$session_user_manager = (int) $session->get('user-manager');
118
$session_initial_url = $session->get('user-initial_url');
119
$session_nb_users_online = $session->get('system-nb_users_online');
120
$session_auth_type = $session->get('user-auth_type');
121
122
$server = [];
123
$server['request_uri'] = (string) $request->getRequestUri();
124
$server['request_time'] = (int) $request->server->get('REQUEST_TIME');
125
126
$get = [];
127
$get['page'] = $request->query->get('page') === null ? '' : $antiXss->xss_clean($request->query->get('page'));
128
$get['otv'] = $request->query->get('otv') === null ? '' : $antiXss->xss_clean($request->query->get('otv'));
129
130
// Avoid blank page and session destroy if user go to index.php without ?page=
131
if (empty($get['page']) && !empty($session_name)) {
132
    if ($session_user_admin === 1) {
133
        $redirect_page = 'admin';
134
    } else {
135
        $redirect_page = 'items';
136
    }
137
138
    // Redirect user on default page.
139
    header('Location: index.php?page='.$redirect_page);
140
    exit();
141
}
142
143
// Force log of all queries
144
// Check if super privilege exists in session
145
if (!$session->has('hasSuperPrivilege')) {
146
    // Execute query
147
    $hasSuperPrivilege = (int) DB::queryFirstField(
148
        "SELECT COUNT(*) 
149
        FROM information_schema.user_privileges 
150
        WHERE GRANTEE = CONCAT(\"'\", CURRENT_USER(), \"'@'localhost'\") 
151
        AND PRIVILEGE_TYPE = 'SUPER'"
152
    );
153
    // Save in session
154
    $session->set('hasSuperPrivilege', $hasSuperPrivilege);
155
} else {
156
    // Get value from session
157
    $hasSuperPrivilege = (int) $session->get('hasSuperPrivilege');
158
}
159
// Enable or not if user has super privilege
160
if ($hasSuperPrivilege > 0) {
161
    if (defined('MYSQL_LOG') && MYSQL_LOG === true) {
0 ignored issues
show
The condition MYSQL_LOG === true is always false.
Loading history...
162
        DB::query("SET GLOBAL general_log = 'ON'");
163
        DB::query("SET GLOBAL general_log_file = " . (defined('MYSQL_LOG_FILE') ? MYSQL_LOG_FILE : "'/var/log/teampass_mysql_query.log'"));
164
    } else {
165
        DB::query("SET GLOBAL general_log = 'OFF'");
166
    }
167
}
168
169
/* DEFINE WHAT LANGUAGE TO USE */
170
if (null === $session->get('user-validite_pw') && $post_language === null && $session_user_language === null) {
171
    //get default language
172
    $dataLanguage = DB::queryFirstRow(
173
        'SELECT m.valeur AS valeur, l.flag AS flag
174
        FROM ' . prefixTable('misc') . ' AS m
175
        INNER JOIN ' . prefixTable('languages') . ' AS l ON (m.valeur = l.name)
176
        WHERE m.type=%s_type AND m.intitule=%s_intitule',
177
        [
178
            'type' => 'admin',
179
            'intitule' => 'default_language',
180
        ]
181
    );
182
    if (empty($dataLanguage['valeur'])) {
183
        $session->set('user-language', 'english');
184
        $session->set('user-language_flag', 'us.png');
185
        $session_user_language = 'english';
186
    } else {
187
        $session->set('user-language', $dataLanguage['valeur']);
188
        $session->set('user-language_flag', $dataLanguage['flag']);
189
        $session_user_language = $dataLanguage['valeur'];
190
    }
191
} elseif (isset($SETTINGS['default_language']) === true && $session_user_language === null) {
192
    $session->set('user-language', $SETTINGS['default_language']);
193
    $session_user_language = $SETTINGS['default_language'];
194
} elseif ($post_language !== null) {
195
    $session->set('user-language', $post_language);
196
    $session_user_language = $post_language;
197
} elseif ($session_user_language === null || empty($session_user_language) === true) {
198
    if ($post_language !== null) {
199
        $session->set('user-language', $post_language);
200
        $session_user_language = $post_language;
201
    } elseif ($session_user_language !== null) {
202
        $session->set('user-language', $SETTINGS['default_language']);
203
        $session_user_language = $SETTINGS['default_language'];
204
    }
205
}
206
$lang = new Language($session_user_language, __DIR__. '/includes/language/'); 
207
208
if (isset($SETTINGS['cpassman_dir']) === false || $SETTINGS['cpassman_dir'] === '') {
209
    $SETTINGS['cpassman_dir'] = __DIR__;
210
    $SETTINGS['cpassman_url'] = (string) $server['request_uri'];
211
}
212
213
// Get the URL
214
$cpassman_url = isset($SETTINGS['cpassman_url']) ? $SETTINGS['cpassman_url'] : '';
215
// URL validation
216
if (!filter_var($cpassman_url, FILTER_VALIDATE_URL)) {
217
    $cpassman_url = '';
218
}
219
// Sanitize the URL to prevent XSS
220
$cpassman_url = htmlspecialchars($cpassman_url, ENT_QUOTES, 'UTF-8');
221
222
// Some template adjust
223
if (array_key_exists($get['page'], $mngPages) === true) {
224
    $menuAdmin = true;
225
} else {
226
    $menuAdmin = false;
227
}
228
229
// Some template adjust
230
if (array_key_exists($get['page'], $utilitiesPages) === true) {
231
    $menuUtilities = true;
232
} else {
233
    $menuUtilities = false;
234
}
235
236
// Get the favicon
237
$favicon = isset($SETTINGS['favicon']) ? $SETTINGS['favicon'] : '';
238
// URL Validation
239
if (!filter_var($favicon, FILTER_VALIDATE_URL)) {
240
    $favicon = '';
241
}
242
// Sanitize the URL to prevent XSS
243
$favicon = htmlspecialchars($favicon, ENT_QUOTES, 'UTF-8');
244
245
// Define the date and time format
246
$date_format = isset($SETTINGS['date_format']) ? $SETTINGS['date_format'] : 'Y-m-d';
247
$time_format = isset($SETTINGS['time_format']) ? $SETTINGS['time_format'] : 'H:i:s';
248
249
// Force dark theme on page generation
250
$theme = $_COOKIE['teampass_theme'] ?? 'light';
251
$theme_body = $theme === 'dark' ? 'dark-mode' : '';
252
$theme_meta = $theme === 'dark' ? '#343a40' : '#fff';
253
$theme_navbar = $theme === 'dark' ? 'navbar-dark' : 'navbar-white navbar-light';
254
255
?>
256
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
257
258
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
259
260
<head>
261
    <meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
262
    <meta name="viewport" content="width=device-width, initial-scale=1" />
263
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
264
    <meta name="theme-color" content="<?php echo $theme_meta; ?>" />
265
    <title><?php echo $configManager->getSetting('teampass_title') ?? 'Teampass'; ?></title>
266
    <script type='text/javascript'>
267
        //<![CDATA[
268
        if (window.location.href.indexOf('page=') === -1 &&
269
            (window.location.href.indexOf('otv=') === -1 &&
270
                window.location.href.indexOf('action=') === -1)
271
        ) {
272
            if (window.location.href.indexOf('session_over=true') !== -1) {
273
                location.replace('./includes/core/logout.php');
274
            }
275
        }
276
        //]]>
277
    </script>
278
279
    <!-- IonIcons -->
280
    <link rel="stylesheet" href="includes/css/ionicons.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
281
    <!-- Theme style -->
282
    <link rel="stylesheet" href="plugins/adminlte/css/adminlte.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
283
    <link rel="stylesheet" href="plugins/pace-progress/themes/corner-indicator.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/css" />
284
    <link rel="stylesheet" href="plugins/select2/css/select2.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/css" />
285
    <link rel="stylesheet" href="plugins/select2/theme/select2-bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/css" />
286
    <!-- Theme style -->
287
    <link rel="stylesheet" href="includes/css/teampass.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
288
    <!-- Google Font: Source Sans Pro -->
289
    <link rel="stylesheet" type="text/css" href="includes/fonts/fonts.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
290
    <!-- Altertify -->
291
    <link rel="stylesheet" href="plugins/alertifyjs/css/alertify.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
292
    <link rel="stylesheet" href="plugins/alertifyjs/css/themes/bootstrap.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
293
    <!-- Toastr -->
294
    <link rel="stylesheet" href="plugins/toastr/toastr.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
295
    <!-- favicon -->
296
    <link rel="shortcut icon" type="image/png" href="<?php echo $favicon;?>"/>
297
    <!-- manifest (PWA) -->
298
    <link rel="manifest" href="manifest.json?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
299
    <!-- Custom style -->
300
    <?php
301
    if (file_exists(__DIR__ . '/includes/css/custom.css') === true) {?>
302
        <link rel="stylesheet" href="includes/css/custom.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
303
    <?php
304
    } ?>
305
</head>
306
307
308
309
310
<?php
311
// display an item in the context of OTV link
312
if ((null === $session->get('user-validite_pw') || empty($session->get('user-validite_pw')) === true || empty($session->get('user-id')) === true)
313
    && empty($get['otv']) === false)
314
{
315
    include './includes/core/otv.php';
316
    exit;
317
} elseif ($session->has('user-validite_pw') && null !== $session->get('user-validite_pw') && ($session->get('user-validite_pw') === 0 || $session->get('user-validite_pw') === 1)
318
    && empty($get['page']) === false && empty($session->get('user-id')) === false
319
) {
320
    ?>
321
    <body class="hold-transition sidebar-mini layout-navbar-fixed layout-fixed <?php echo $theme_body; ?>">
322
        <div class="wrapper">
323
324
            <!-- Navbar -->
325
            <nav class="main-header navbar navbar-expand <?php echo $theme_navbar ?>">
326
                <!-- User encryption still ongoing -->
327
                <div id="user_not_ready" class="alert alert-warning hidden pointer p-2 mt-2" style="position:absolute; left:200px;">
328
                    <span class="align-middle infotip ml-2" title="<?php echo $lang->get('keys_encryption_not_ready'); ?>"><?php echo $lang->get('account_not_ready'); ?><span id="user_not_ready_progress"></span><i class="fa-solid fa-hourglass-half fa-beat-fade mr-2 ml-2"></i></span>
329
                </div>
330
331
                <!-- Left navbar links -->
332
                <ul class="navbar-nav">
333
                    <li class="nav-item">
334
                        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa-solid fa-bars"></i></a>
335
                    </li>
336
                </ul>
337
338
                <!-- Right navbar links -->
339
                <ul class="navbar-nav ml-auto">
340
                    <span class="fa-stack infotip pointer hidden mr-2" title="<?php echo $lang->get('get_your_recovery_keys'); ?>" id="open_user_keys_management" style="vertical-align: top;">
341
                        <i class="fa-solid fa-circle text-danger fa-stack-2x"></i>
342
                        <i class="fa-solid fa-bell fa-shake fa-stack-1x fa-inverse"></i>
343
                    </span>
344
                    <!-- Messages Dropdown Menu -->
345
                    <li class="nav-item dropdown">
346
                        <div class="dropdown show">
347
                            <a class="btn btn-primary dropdown-toggle" href="#" data-toggle="dropdown">
348
                                <?php
349
                                    echo $session_name . '&nbsp;' . $session_lastname; ?>
350
                            </a>
351
352
                            <div class="dropdown-menu dropdown-menu-right">
353
                                <a class="dropdown-item user-menu" href="#" data-name="increase_session">
354
                                    <i class="far fa-clock fa-fw mr-2"></i><?php echo $lang->get('index_add_one_hour'); ?></a>
355
                                <div class="dropdown-divider"></div>
356
                                <a class="dropdown-item user-menu" href="#" data-name="profile">
357
                                    <i class="fa-solid fa-user-circle fa-fw mr-2"></i><?php echo $lang->get('my_profile'); ?>
358
                                </a>
359
                                <?php
360
                                    if (empty($session_auth_type) === false && $session_auth_type !== 'ldap' && $session_auth_type !== 'oauth2') {
361
                                        ?>
362
                                    <a class="dropdown-item user-menu" href="#" data-name="password-change">
363
                                        <i class="fa-solid fa-lock fa-fw mr-2"></i><?php echo $lang->get('index_change_pw'); ?>
364
                                    </a>
365
                                <?php
366
                                    } elseif ($session_auth_type === 'ldap') {
367
                                        ?>
368
                                    <a class="dropdown-item user-menu" href="#" data-name="sync-new-ldap-password">
369
                                        <i class="fa-solid fa-key fa-fw mr-2"></i><?php echo $lang->get('sync_new_ldap_password'); ?>
370
                                    </a>
371
                                <?php
372
                                    } ?>
373
                                <a class="dropdown-item user-menu<?php echo (int) $session_user_admin === 1 ? ' hidden' : '';?>" href="#" data-name="generate-new_keys">
374
                                    <i class="fa-solid fa-spray-can-sparkles fa-fw mr-2"></i><?php echo $lang->get('generate_new_keys'); ?>
375
                                </a>
376
377
                                <!--
378
                                <div class="dropdown-divider"></div>
379
                                <a class="dropdown-item user-menu" href="#" data-name="generate-an-otp">
380
                                    <i class="fa-solid fa-qrcode fa-fw mr-2"></i><?php echo $lang->get('generate_an_otp'); ?>
381
                                </a>
382
                                -->
383
384
                                <div class="dropdown-divider"></div>
385
                                <a class="dropdown-item user-menu" href="#" data-name="logout">
386
                                    <i class="fa-solid fa-sign-out-alt fa-fw mr-2"></i><?php echo $lang->get('disconnect'); ?>
387
                                </a>
388
                            </div>
389
                        </div>
390
                    </li>
391
                    <li>
392
                        <span class="align-middle infotip ml-2 text-info" title="<?php echo $lang->get('index_expiration_in'); ?>" id="countdown"></span>
393
                    </li>
394
                    <li class="nav-item">
395
                        <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#" id="controlsidebar"><i class="fa-solid fa-th-large"></i></a>
396
                    </li>
397
                    <li id="switch-theme" class="nav-item pointer">
398
                        <i class="fa-solid fa-circle-half-stroke m-2 m-2"></i>
399
                    </li>
400
                </ul>
401
            </nav>
402
            <!-- /.navbar -->
403
404
            <!-- Main Sidebar Container -->
405
            <aside class="main-sidebar sidebar-dark-primary elevation-4">
406
                <!-- Brand Logo -->
407
                <a href="<?php echo $cpassman_url . '/index.php?page=' . ((int) $session_user_admin === 1 ? 'admin' : 'items'); ?>" class="brand-link">
408
                    <img src="includes/images/teampass-logo2-home.png" alt="Teampass Logo" class="brand-image">
409
                    <span class="brand-text font-weight-light"><?php echo TP_TOOL_NAME; ?></span>
410
                </a>
411
412
                <!-- Sidebar -->
413
                <div class="sidebar">
414
                    <!-- Sidebar Menu -->
415
                    <nav class="mt-2" style="margin-bottom:40px;">
416
                        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
417
                            <?php
418
                                if ($session_user_admin === 0) {
419
                                    // ITEMS & SEARCH
420
                                    echo '
421
                    <li class="nav-item">
422
                        <a href="#" data-name="items" class="nav-link', $get['page'] === 'items' ? ' active' : '', '">
423
                        <i class="nav-icon fa-solid fa-key"></i>
424
                        <p>
425
                            ' . $lang->get('pw') . '
426
                        </p>
427
                        </a>
428
                    </li>';
429
                                }
430
431
    // IMPORT menu
432
    if (isset($SETTINGS['allow_import']) === true && (int) $SETTINGS['allow_import'] === 1 && (int) $session_user_admin === 0) {
433
        echo '
434
                    <li class="nav-item">
435
                        <a href="#" data-name="import" class="nav-link', $get['page'] === 'import' ? ' active' : '', '">
436
                        <i class="nav-icon fa-solid fa-file-import"></i>
437
                        <p>
438
                            ' . $lang->get('import') . '
439
                        </p>
440
                        </a>
441
                    </li>';
442
    }
443
    // EXPORT menu
444
    if (
445
                                    isset($SETTINGS['allow_print']) === true && (int) $SETTINGS['allow_print'] === 1
446
                                    && isset($SETTINGS['roles_allowed_to_print_select']) === true
447
                                    && empty($SETTINGS['roles_allowed_to_print_select']) === false
448
                                    && count(array_intersect(
449
                                        explode(';', $session->get('user-roles')),
450
                                        explode(',', str_replace(['"', '[', ']'], '', $SETTINGS['roles_allowed_to_print_select']))
451
                                    )) > 0
452
                                    && (int) $session_user_admin === 0
453
                                ) {
454
        echo '
455
                    <li class="nav-item">
456
                        <a href="#" data-name="export" class="nav-link', $get['page'] === 'export' ? ' active' : '', '">
457
                        <i class="nav-icon fa-solid fa-file-export"></i>
458
                        <p>
459
                            ' . $lang->get('export') . '
460
                        </p>
461
                        </a>
462
                    </li>';
463
    }
464
465
    /*
466
    // OFFLINE MODE menu
467
    if (isset($SETTINGS['settings_offline_mode']) === true && (int) $SETTINGS['settings_offline_mode'] === 1) {
468
        echo '
469
                    <li class="nav-item">
470
                        <a href="#" data-name="offline" class="nav-link', $get['page'] === 'offline' ? ' active' : '' ,'">
471
                        <i class="nav-icon fa-solid fa-plug"></i>
472
                        <p>
473
                            '.$lang->get('offline').'
474
                        </p>
475
                        </a>
476
                    </li>';
477
    }
478
    */
479
480
    if ($session_user_admin === 0) {
481
        echo '
482
                    <li class="nav-item">
483
                        <a href="#" data-name="search" class="nav-link', $get['page'] === 'search' ? ' active' : '', '">
484
                        <i class="nav-icon fa-solid fa-search"></i>
485
                        <p>
486
                            ' . $lang->get('find') . '
487
                        </p>
488
                        </a>
489
                    </li>';
490
    }
491
492
    // Favourites menu
493
    if (
494
                                    isset($SETTINGS['enable_favourites']) === true && (int) $SETTINGS['enable_favourites'] === 1
495
                                    && (int) $session_user_admin === 0
496
                                ) {
497
        echo '
498
                    <li class="nav-item">
499
                        <a href="#" data-name="favourites" class="nav-link', $get['page'] === 'favourites' ? ' active' : '', '">
500
                        <i class="nav-icon fa-solid fa-star"></i>
501
                        <p>
502
                            ' . $lang->get('favorites') . '
503
                        </p>
504
                        </a>
505
                    </li>';
506
    }
507
    /*
508
        // KB menu
509
        if (isset($SETTINGS['enable_kb']) === true && $SETTINGS['enable_kb'] === '1'
510
        ) {
511
            echo '
512
                        <li class="nav-item">
513
                            <a href="#" data-name="kb" class="nav-link', $get['page'] === 'kb' ? ' active' : '' ,'">
514
                            <i class="nav-icon fa-solid fa-map-signs"></i>
515
                            <p>
516
    '.$lang->get('kb_menu').'
517
                            </p>
518
                            </a>
519
                        </li>';
520
        }
521
    */
522
    // SUGGESTION menu
523
    if (
524
                                    isset($SETTINGS['enable_suggestion']) && (int) $SETTINGS['enable_suggestion'] === 1
525
                                    && $session_user_manager === 1
526
                                ) {
527
        echo '
528
                    <li class="nav-item">
529
                        <a href="#" data-name="suggestion" class="nav-link', $get['page'] === 'suggestion' ? ' active' : '', '">
530
                        <i class="nav-icon fa-solid fa-lightbulb"></i>
531
                        <p>
532
                            ' . $lang->get('suggestion_menu') . '
533
                        </p>
534
                        </a>
535
                    </li>';
536
    }
537
538
    // Admin menu
539
    if ($session_user_admin === 1) {
540
        echo '
541
                    <li class="nav-item">
542
                        <a href="#" data-name="admin" class="nav-link', $get['page'] === 'admin' ? ' active' : '', '">
543
                        <i class="nav-icon fa-solid fa-info"></i>
544
                        <p>
545
                            ' . $lang->get('admin_main') . '
546
                        </p>
547
                        </a>
548
                    </li>
549
                    <li class="nav-item has-treeview', $menuAdmin === true ? ' menu-open' : '', '">
550
                        <a href="#" class="nav-link">
551
                            <i class="nav-icon fa-solid fa-wrench"></i>
552
                            <p>
553
                                ' . $lang->get('admin_settings') . '
554
                                <i class="fa-solid fa-angle-left right"></i>
555
                            </p>
556
                        </a>
557
                        <ul class="nav-item nav-treeview">
558
                            <li class="nav-item">
559
                                <a href="#" data-name="options" class="nav-link', $get['page'] === 'options' ? ' active' : '', '">
560
                                    <i class="fa-solid fa-check-double nav-icon"></i>
561
                                    <p>' . $lang->get('options') . '</p>
562
                                </a>
563
                            </li>
564
                            <li class="nav-item">
565
                                <a href="#" data-name="2fa" class="nav-link', $get['page'] === '2fa' ? ' active' : '', '">
566
                                    <i class="fa-solid fa-qrcode nav-icon"></i>
567
                                    <p>' . $lang->get('mfa_short') . '</p>
568
                                </a>
569
                            </li>
570
                            <li class="nav-item">
571
                                <a href="#" data-name="api" class="nav-link', $get['page'] === 'api' ? ' active' : '', '">
572
                                    <i class="fa-solid fa-cubes nav-icon"></i>
573
                                    <p>' . $lang->get('api') . '</p>
574
                                </a>
575
                            </li>
576
                            <li class="nav-item">
577
                                <a href="#" data-name="backups" class="nav-link', $get['page'] === 'backups' ? ' active' : '', '">
578
                                    <i class="fa-solid fa-database nav-icon"></i>
579
                                    <p>' . $lang->get('backups') . '</p>
580
                                </a>
581
                            </li>
582
                            <li class="nav-item">
583
                                <a href="#" data-name="emails" class="nav-link', $get['page'] === 'emails' ? ' active' : '', '">
584
                                    <i class="fa-solid fa-envelope nav-icon"></i>
585
                                    <p>' . $lang->get('emails') . '</p>
586
                                </a>
587
                            </li>
588
                            <li class="nav-item">
589
                                <a href="#" data-name="fields" class="nav-link', $get['page'] === 'fields' ? ' active' : '', '">
590
                                    <i class="fa-solid fa-keyboard nav-icon"></i>
591
                                    <p>' . $lang->get('fields') . '</p>
592
                                </a>
593
                            </li>
594
                            <li class="nav-item">
595
                                <a href="#" data-name="ldap" class="nav-link', $get['page'] === 'ldap' ? ' active' : '', '">
596
                                    <i class="fa-solid fa-id-card nav-icon"></i>
597
                                    <p>' . $lang->get('ldap') . '</p>
598
                                </a>
599
                            </li>
600
601
                            <li class="nav-item">
602
                                <a href="#" data-name="oauth" class="nav-link', $get['page'] === 'oauth' ? ' active' : '', '">
603
                                    <i class="fa-solid fa-plug nav-icon"></i>
604
                                    <p>' . $lang->get('oauth') . '</p>
605
                                </a>
606
                            </li>
607
                            
608
                            <li class="nav-item">
609
                                <a href="#" data-name="uploads" class="nav-link', $get['page'] === 'uploads' ? ' active' : '', '">
610
                                    <i class="fa-solid fa-file-upload nav-icon"></i>
611
                                    <p>' . $lang->get('uploads') . '</p>
612
                                </a>
613
                            </li>
614
                            <li class="nav-item">
615
                                <a href="#" data-name="statistics" class="nav-link', $get['page'] === 'statistics' ? ' active' : '', '">
616
                                    <i class="fa-solid fa-chart-bar nav-icon"></i>
617
                                    <p>' . $lang->get('statistics') . '</p>
618
                                </a>
619
                            </li>
620
                        </ul>
621
                    </li>';
622
623
        if (isset($SETTINGS['enable_tasks_manager']) && (int) $SETTINGS['enable_tasks_manager'] === 1) {
624
            echo '
625
                    <li class="nav-item">
626
                        <a href="#" data-name="tasks" class="nav-link', $get['page'] === 'tasks' ? ' active' : '', '">
627
                        <i class="fa-solid fa-tasks nav-icon"></i>
628
                        <p>' . $lang->get('tasks') . '</p>
629
                        </a>
630
                    </li>';
631
        }
632
        
633
        if (WIP === true) {
634
            echo '
635
                    <li class="nav-item">
636
                        <a href="#" data-name="tools" class="nav-link', $get['page'] === 'tools' ? ' active' : '', '">
637
                        <i class="nav-icon fa-solid fa-person-drowning"></i>
638
                        <p>
639
                            ' . $lang->get('tools') . '
640
                        </p>
641
                        </a>
642
                    </li>';
643
        }
644
        echo '
645
                    <li class="nav-item">
646
                        <a href="#" data-name="import" class="nav-link', $get['page'] === 'import' ? ' active' : '', '">
647
                        <i class="nav-icon fa-solid fa-file-import"></i>
648
                        <p>
649
                            ' . $lang->get('import') . '
650
                        </p>
651
                        </a>
652
                    </li>';
653
    }
654
655
    if (
656
        $session_user_admin === 1
657
        || $session_user_manager === 1
658
        || $session_user_human_resources === 1
659
    ) {
660
        echo '
661
                    <li class="nav-item">
662
                        <a href="#" data-name="folders" class="nav-link', $get['page'] === 'folders' ? ' active' : '', '">
663
                        <i class="nav-icon fa-solid fa-folder-open"></i>
664
                        <p>
665
                            ' . $lang->get('folders') . '
666
                        </p>
667
                        </a>
668
                    </li>
669
                    <li class="nav-item">
670
                        <a href="#" data-name="roles" class="nav-link', $get['page'] === 'roles' ? ' active' : '', '">
671
                        <i class="nav-icon fa-solid fa-graduation-cap"></i>
672
                        <p>
673
                            ' . $lang->get('roles') . '
674
                        </p>
675
                        </a>
676
                    </li>
677
                    <li class="nav-item">
678
                        <a href="#" data-name="users" class="nav-link', $get['page'] === 'users' ? ' active' : '', '">
679
                        <i class="nav-icon fa-solid fa-users"></i>
680
                        <p>
681
                            ' . $lang->get('users') . '
682
                        </p>
683
                        </a>
684
                    </li>
685
                    <li class="nav-item has-treeview', $menuUtilities === true ? ' menu-open' : '', '">
686
                        <a href="#" class="nav-link">
687
                        <i class="nav-icon fa-solid fa-cubes"></i>
688
                        <p>' . $lang->get('admin_views') . '<i class="fa-solid fa-angle-left right"></i></p>
689
                        </a>
690
                        <ul class="nav nav-treeview">
691
                            <li class="nav-item">
692
                                <a href="#" data-name="utilities.renewal" class="nav-link', $get['page'] === 'utilities.renewal' ? ' active' : '', '">
693
                                <i class="far fa-calendar-alt nav-icon"></i>
694
                                <p>' . $lang->get('renewal') . '</p>
695
                                </a>
696
                            </li>
697
                            <li class="nav-item">
698
                                <a href="#" data-name="utilities.deletion" class="nav-link', $get['page'] === 'utilities.deletion' ? ' active' : '', '">
699
                                <i class="fa-solid fa-trash-alt nav-icon"></i>
700
                                <p>' . $lang->get('deletion') . '</p>
701
                                </a>
702
                            </li>
703
                            <li class="nav-item">
704
                                <a href="#" data-name="utilities.logs" class="nav-link', $get['page'] === 'utilities.logs' ? ' active' : '', '">
705
                                <i class="fa-solid fa-history nav-icon"></i>
706
                                <p>' . $lang->get('logs') . '</p>
707
                                </a>
708
                            </li>
709
                            <li class="nav-item">
710
                                <a href="#" data-name="utilities.database" class="nav-link', $get['page'] === 'utilities.database' ? ' active' : '', '">
711
                                <i class="fa-solid fa-database nav-icon"></i>
712
                                <p>' . $lang->get('database') . '</p>
713
                                </a>
714
                            </li>
715
                        </ul>
716
                    </li>';
717
    } ?>
718
                        </ul>
719
                    </nav>
720
                    <!-- /.sidebar-menu -->
721
                <div class="menu-footer">
722
                    <div class="" id="sidebar-footer">
723
                        <i class="fa-solid fa-clock-o mr-2 infotip text-info pointer" title="<?php echo htmlspecialchars($lang->get('server_time') . ' ' .
724
                            date($date_format, (int) $server['request_time']) . ' - ' .
725
                            date($time_format, (int) $server['request_time']), ENT_QUOTES, 'UTF-8'); ?>"></i>
726
                        <i class="fa-solid fa-users mr-2 infotip text-info pointer" title="<?php echo $session_nb_users_online . ' ' . $lang->get('users_online'); ?>"></i>
727
                        <a href="<?php echo DOCUMENTATION_URL; ?>" target="_blank" class="text-info"><i class="fa-solid fa-book mr-2 infotip" title="<?php echo $lang->get('documentation_canal'); ?>"></i></a>
728
                        <a href="<?php echo HELP_URL; ?>" target="_blank" class="text-info"><i class="fa-solid fa-life-ring mr-2 infotip" title="<?php echo $lang->get('admin_help'); ?>"></i></a>
729
                        <?php if ($session_user_admin === 1) : ?><i class="fa-solid fa-bug infotip pointer text-info" title="<?php echo $lang->get('bugs_page'); ?>" onclick="generateBugReport()"></i><?php endif; ?>
730
                    </div>
731
                    <?php
732
    ?>
733
                </div>
734
                </div>
735
                <!-- /.sidebar -->
736
            </aside>
737
738
            <!-- Content Wrapper. Contains page content -->
739
            <div class="content-wrapper">
740
741
                <!-- DEFECT REPORT -->
742
                <div class="card card-danger m-2 hidden" id="dialog-bug-report">
743
                    <div class="card-header">
744
                        <h3 class="card-title">
745
                            <i class="fa-solid fa-bug mr-2"></i>
746
                            <?php echo $lang->get('defect_report'); ?>
747
                        </h3>
748
                    </div>
749
                    <div class="card-body">
750
                        <div class="row">
751
                            <div class="col-sm-12 col-md-12">
752
                                <div class="mb-2 alert alert-info">
753
                                    <i class="icon fa-solid fa-info mr-2"></i>
754
                                    <?php echo $lang->get('bug_report_to_github'); ?>
755
                                </div>
756
                                <textarea class="form-control" style="min-height:300px;" id="dialog-bug-report-text" placeholder="<?php echo $lang->get('please_wait_while_loading'); ?>"></textarea>
757
                            </div>
758
                        </div>
759
                    </div>
760
                    <div class="card-footer">
761
                        <button class="btn btn-primary mr-2 clipboard-copy" data-clipboard-text="dialog-bug-report-text" id="dialog-bug-report-select-button"><?php echo $lang->get('copy_to_clipboard'); ?></button>
762
                        <button class="btn btn-primary" id="dialog-bug-report-github-button"><?php echo $lang->get('open_bug_report_in_github'); ?></button>
763
                        <button class="btn btn-default float-right close-element"><?php echo $lang->get('close'); ?></button>
764
                    </div>
765
                </div>
766
                <!-- /.DEFECT REPORT -->
767
768
769
                <!-- USER CHANGE AUTH PASSWORD -->
770
                <div class="card card-warning m-3 hidden" id="dialog-user-change-password">
771
                    <div class="card-header">
772
                        <h3 class="card-title">
773
                            <i class="fa-solid fa-bullhorn mr-2"></i>
774
                            <?php echo $lang->get('your_attention_is_required'); ?>
775
                        </h3>
776
                    </div>
777
                    <div class="card-body">
778
                        <div class="row">
779
                            <div class="col-sm-12 col-md-12">
780
                                <div class="mb-5 alert alert-info" id="dialog-user-change-password-info">
781
                                    <i class="icon fa-solid fa-info mr-2"></i>
782
                                    <?php echo $lang->get('user_password_policy_tip'); ?>
783
                                </div>
784
                                <div class="input-group mb-3">
785
                                    <div class="input-group-prepend">
786
                                        <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span>
787
                                    </div>
788
                                    <input type="password" class="form-control" id="profile-current-password">
789
                                </div>
790
                                <div class="input-group mb-3">
791
                                    <div class="input-group-prepend">
792
                                        <span class="input-group-text"><?php echo $lang->get('index_new_pw'); ?></span>
793
                                    </div>
794
                                    <input type="password" class="form-control" id="profile-password">
795
                                    <div class="input-group-append" style="margin: 0px;">
796
                                        <span class="input-group-text" id="profile-password-strength"></span>
797
                                        <input type="hidden" id="profile-password-complex" />
798
                                    </div>
799
                                </div>
800
                                <div class="input-group mb-3">
801
                                    <div class="input-group-prepend">
802
                                        <span class="input-group-text"><?php echo $lang->get('index_change_pw_confirmation'); ?></span>
803
                                    </div>
804
                                    <input type="password" class="form-control" id="profile-password-confirm">
805
                                </div>
806
                                <div class="form-control mt-3 font-weight-light grey" id="dialog-user-change-password-progress">
807
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
808
                                </div>
809
                            </div>
810
                        </div>
811
                    </div>
812
                    <div class="card-footer">
813
                        <button class="btn btn-primary" id="dialog-user-change-password-do"><?php echo $lang->get('launch'); ?></button>
814
                        <button class="btn btn-default float-right" id="dialog-user-change-password-close"><?php echo $lang->get('close'); ?></button>
815
                    </div>
816
                </div>
817
                <!-- /.USER CHANGE AUTH PASSWORD -->
818
819
820
                <!-- LDAP USER HAS CHANGED AUTH PASSWORD -->
821
                <div class="card card-warning m-3 hidden" id="dialog-ldap-user-change-password">
822
                    <div class="card-header">
823
                        <h3 class="card-title">
824
                            <i class="fa-solid fa-bullhorn mr-2"></i>
825
                            <?php echo $lang->get('your_attention_is_required'); ?>
826
                        </h3>
827
                    </div>
828
                    <div class="card-body">
829
                        <div class="row">
830
                            <div class="col-sm-12 col-md-12">
831
                                <div class="mb-5 alert alert-info hidden" id="dialog-ldap-user-change-password-info">
832
                                </div>
833
                                <div class="input-group mb-3">
834
                                    <div class="input-group-prepend">
835
                                        <span class="input-group-text"><?php echo $lang->get('provide_your_previous_password'); ?></span>
836
                                    </div>
837
                                    <input type="password" class="form-control" id="dialog-ldap-user-change-password-old">
838
                                </div>
839
                                <div class="input-group mb-3"  id="new-password-field">
840
                                    <div class="input-group-prepend">
841
                                        <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span>
842
                                    </div>
843
                                    <input type="password" class="form-control" id="dialog-ldap-user-change-password-current">
844
                                </div>
845
                                <div class="form-control mt-3 font-weight-light grey" id="dialog-ldap-user-change-password-progress">
846
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
847
                                </div>
848
                            </div>
849
                        </div>
850
                    </div>
851
                    <div class="card-footer">
852
                        <button class="btn btn-primary" id="dialog-ldap-user-change-password-do"><?php echo $lang->get('launch'); ?></button>
853
                        <button class="btn btn-default float-right" id="dialog-ldap-user-change-password-close"><?php echo $lang->get('close'); ?></button>
854
                    </div>
855
                </div>
856
                <!-- /.LDAP USER HAS CHANGED AUTH PASSWORD -->
857
858
859
                <!-- ADMIN ASKS FOR USER PASSWORD CHANGE -->
860
                <div class="card card-warning m-3 hidden" id="dialog-admin-change-user-password">
861
                    <div class="card-header">
862
                        <h3 class="card-title">
863
                            <i class="fa-solid fa-bullhorn mr-2"></i>
864
                            <?php echo $lang->get('your_attention_is_required'); ?>
865
                        </h3>
866
                    </div>
867
                    <div class="card-body">
868
                        <div class="row">
869
                            <div class="col-sm-12 col-md-12">
870
                                <div class="mb-2 alert alert-info" id="dialog-admin-change-user-password-info">
871
                                </div>
872
                                <div class="form-control mt-3 font-weight-light grey" id="dialog-admin-change-user-password-progress">
873
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
874
                                </div>
875
                                <div class="mt-3">                                    
876
                                    <label>
877
                                        <span class="mr-2 pointer fw-normal"><i class="fa-solid fa-eye mr-2 text-orange"></i><?php echo $lang->get('show_user_password');?></span>
878
                                        <input type="checkbox" id="dialog-admin-change-user-password-do-show-password" class="pointer">
879
                                    </label>
880
                                </div>
881
                            </div>
882
                        </div>
883
                        <input type="hidden" id="admin_change_user_password_target_user" value="">
884
                        <input type="hidden" id="admin_change_user_encryption_code_target_user" value="">
885
                    </div>
886
                    <div class="card-footer">
887
                        <button class="btn btn-primary mr-3" id="dialog-admin-change-user-password-do"><?php echo $lang->get('launch'); ?></button>
888
                        <button class="btn btn-default float-right" id="dialog-admin-change-user-password-close"><?php echo $lang->get('close'); ?></button>
889
                    </div>
890
                </div>
891
                <!-- /.ADMIN ASKS FOR USER PASSWORD CHANGE -->
892
893
894
                <!-- USER PROVIDES TEMPORARY CODE -->
895
                <div class="card card-warning m-3 hidden" id="dialog-user-temporary-code">
896
                    <div class="card-header">
897
                        <h3 class="card-title">
898
                            <i class="fa-solid fa-bullhorn mr-2"></i>
899
                            <?php echo $lang->get('your_attention_is_required'); ?>
900
                        </h3>
901
                    </div>
902
                    <div class="card-body">
903
                        <div class="row">
904
                            <div class="col-sm-12 col-md-12">
905
                                <div class="mb-5 alert alert-info" id="dialog-user-temporary-code-info">
906
                                </div>
907
                                <div class="input-group mb-3">
908
                                    <div class="input-group-prepend">
909
                                        <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span>
910
                                    </div>
911
                                    <input type="password" class="form-control" id="dialog-user-temporary-code-current-password">
912
                                </div>
913
                                <div class="input-group mb-3">
914
                                    <div class="input-group-prepend">
915
                                        <span class="input-group-text"><?php echo $lang->get('temporary_encryption_code'); ?></span>
916
                                    </div>
917
                                    <input type="password" class="form-control" id="dialog-user-temporary-code-value">
918
                                </div>
919
                                <div class="form-control mt-3 font-weight-light grey" id="dialog-user-temporary-code-progress">
920
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
921
                                </div>
922
                            </div>
923
                        </div>
924
                    </div>
925
                    <div class="card-footer">
926
                        <button class="btn btn-primary" id="dialog-user-temporary-code-do"><?php echo $lang->get('launch'); ?></button>
927
                        <button class="btn btn-default float-right" id="dialog-user-temporary-code-close"><?php echo $lang->get('close'); ?></button>
928
                    </div>
929
                </div>
930
                <!-- /.USER PROVIDES TEMPORARY CODE -->
931
932
933
                <!-- ENCRYPTION KEYS GENERATION -->
934
                <div class="card card-warning m-3 mt-3 hidden" id="dialog-encryption-keys">
935
                    <div class="card-header">
936
                        <h3 class="card-title">
937
                            <i class="fa-solid fa-bullhorn mr-2"></i>
938
                            <?php echo $lang->get('your_attention_is_required'); ?>
939
                        </h3>
940
                    </div>
941
                    <div class="card-body">
942
                        <div class="row">
943
                            <div class="col-sm-12 col-md-12">
944
                                <div class="mb-2 alert alert-info" id="warning-text-reencryption">
945
                                    <i class="icon fa-solid fa-info mr-2"></i>
946
                                    <?php echo $lang->get('objects_encryption_explanation'); ?>
947
                                </div>
948
                            </div>
949
                        </div>
950
                        <input type="hidden" id="sharekeys_reencryption_target_user" value="">
951
                    </div>
952
                    <div class="card-footer">
953
                        <button class="btn btn-primary" id="button_do_sharekeys_reencryption"><?php echo $lang->get('launch'); ?></button>
954
                        <button class="btn btn-default float-right" id="button_close_sharekeys_reencryption"><?php echo $lang->get('close'); ?></button>
955
                    </div>
956
                </div>
957
                <!-- /.ENCRYPTION KEYS GENERATION -->
958
959
960
                <!-- ENCRYPTION KEYS GENERATION FOR LDAP NEW USER -->
961
                <div class="card card-warning m-3 mt-3 hidden" id="dialog-ldap-user-build-keys-database">
962
                    <div class="card-header">
963
                        <h3 class="card-title">
964
                            <i class="fa-solid fa-bullhorn mr-2"></i>
965
                            <?php echo $lang->get('your_attention_is_required'); ?>
966
                        </h3>
967
                    </div>
968
                    <div class="card-body">
969
                        <div class="row">
970
                            <div class="col-sm-12 col-md-12">
971
                                <div class="mb-2 alert alert-info" id="warning-text-reencryption">
972
                                    <i class="icon fa-solid fa-info mr-2"></i>
973
                                    <?php echo $lang->get('help_for_launching_items_encryption'); ?>
974
                                </div>
975
976
                                <div class="input-group mb-3">
977
                                    <div class="input-group-prepend">
978
                                        <span class="input-group-text"><?php echo $lang->get('temporary_encryption_code'); ?></span>
979
                                    </div>
980
                                    <input type="password" class="form-control" id="dialog-ldap-user-build-keys-database-code">
981
                                    <br/>
982
                                </div>
983
                                <div class="input-group mb-3<?php if ($session_auth_type === 'oauth2') echo ' hidden'; ?>">
984
                                    <div class="input-group-prepend">
985
                                        <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span>
986
                                    </div>
987
                                    <input type="password" class="form-control" id="dialog-ldap-user-build-keys-database-userpassword">
988
                                </div>
989
                                
990
                                <div class="form-control mt-3 font-weight-light grey" id="dialog-ldap-user-build-keys-database-progress">
991
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
992
                                </div>
993
                            </div>
994
                        </div>
995
                        <input type="hidden" id="sharekeys_reencryption_target_user" value="">
996
                    </div>
997
                    <div class="card-footer">
998
                        <button class="btn btn-primary" id="dialog-ldap-user-build-keys-database-do"><?php echo $lang->get('launch'); ?></button>
999
                        <button class="btn btn-default float-right" id="dialog-ldap-user-build-keys-database-close"><?php echo $lang->get('close'); ?></button>
1000
                    </div>
1001
                </div>
1002
                <!-- /.ENCRYPTION KEYS GENERATION -->
1003
1004
                <!-- ENCRYPTION PERSONAL ITEMS GENERATION -->
1005
                <div class="card card-warning m-3 hidden" id="dialog-encryption-personal-items-after-upgrade">
1006
                    <div class="card-header">
1007
                        <h3 class="card-title">
1008
                            <i class="fa-solid fa-bullhorn mr-2"></i>
1009
                            <?php echo $lang->get('your_attention_is_required'); ?>
1010
                        </h3>
1011
                    </div>
1012
                    <div class="card-body">
1013
                        <div class="row">
1014
                            <div class="col-sm-12 col-md-12">
1015
                                <div class="mb-2 alert alert-info" id="warning-text-changing-password">
1016
                                    <i class="icon fa-solid fa-info mr-2"></i>
1017
                                    <?php echo $lang->get('objects_encryption_explanation'); ?>
1018
                                </div>
1019
                                <div class="input-group mb-3">
1020
                                    <div class="input-group-prepend">
1021
                                        <span class="input-group-text"><?php echo $lang->get('personal_salt_key'); ?></span>
1022
                                    </div>
1023
                                    <input type="password" class="form-control" id="user-current-defuse-psk">
1024
                                </div>
1025
                                <div class="form-control mt-3 font-weight-light grey" id="user-current-defuse-psk-progress">
1026
                                    <?php echo $lang->get('provide_current_psk_and_click_launch'); ?>
1027
                                </div>
1028
                            </div>
1029
                        </div>
1030
                    </div>
1031
                    <div class="card-footer">
1032
                        <button class="btn btn-primary" id="button_do_personal_items_reencryption"><?php echo $lang->get('launch'); ?></button>
1033
                        <button class="btn btn-default float-right" id="button_close_personal_items_reencryption"><?php echo $lang->get('close'); ?></button>
1034
                    </div>
1035
                </div>
1036
                <!-- /.ENCRYPTION PERSONAL ITEMS GENERATION -->
1037
                
1038
1039
                <?php
1040
                    // Case where user is allowed to see the page
1041
                    if ($get['page'] === 'items') {
1042
                        // SHow page with Items
1043
                        if ((int) $session_user_admin !== 1) {
1044
                            include $SETTINGS['cpassman_dir'] . '/pages/items.php';
1045
                        } elseif ((int) $session_user_admin === 1) {
1046
                            include $SETTINGS['cpassman_dir'] . '/pages/admin.php';
1047
                        } else {
1048
                            $session->set('system-error_code', ERR_NOT_ALLOWED);
1049
                            //not allowed page
1050
                            include $SETTINGS['cpassman_dir'] . '/error.php';
1051
                        }
1052
                    } elseif (in_array($get['page'], array_keys($mngPages)) === true) {
1053
                        // Define if user is allowed to see management pages
1054
                        if ($session_user_admin === 1) {
1055
                            // deepcode ignore FileInclusion: $get['page'] is secured through usage of array_keys test bellow
1056
                            include $SETTINGS['cpassman_dir'] . '/pages/' . basename($mngPages[$get['page']]);
1057
                        } elseif ($session_user_manager === 1 || $session_user_human_resources === 1) {
1058
                            if ($get['page'] === 'manage_main' || $get['page'] === 'manage_settings'
1059
                            ) {
1060
                                $session->set('system-error_code', ERR_NOT_ALLOWED);
1061
                                //not allowed page
1062
                                include $SETTINGS['cpassman_dir'] . '/error.php';
1063
                            }
1064
                        } else {
1065
                            $session->set('system-error_code', ERR_NOT_ALLOWED);
1066
                            //not allowed page
1067
                            include $SETTINGS['cpassman_dir'] . '/error.php';
1068
                        }
1069
                    } elseif (empty($get['page']) === false && file_exists($SETTINGS['cpassman_dir'] . '/pages/' . $get['page'] . '.php') === true) {
1070
                        // deepcode ignore FileInclusion: $get['page'] is tested against file_exists just below
1071
                        include $SETTINGS['cpassman_dir'] . '/pages/' . basename($get['page'] . '.php');
1072
                    } else {
1073
                        $session->set('system-array_roles', ERR_NOT_EXIST);
1074
                        //page doesn't exist
1075
                        include $SETTINGS['cpassman_dir'].'/error.php';
1076
                    }
1077
1078
?>
1079
1080
            </div>
1081
            <!-- /.content-wrapper -->
1082
1083
            <!-- Control Sidebar -->
1084
            <aside class="control-sidebar control-sidebar-dark">
1085
                <!-- Control sidebar content goes here -->
1086
                <div class="p-3">
1087
                    <h5><?php echo $lang->get('last_items_title'); ?></h5>
1088
                    <div>
1089
                        <ul class="list-unstyled" id="index-last-pwds">
1090
                        </ul>
1091
                    </div>
1092
                </div>
1093
            </aside>
1094
            <!-- /.control-sidebar -->
1095
1096
            <!-- Main Footer -->
1097
            <footer class="main-footer">
1098
                <!-- To the right -->
1099
                <div class="float-right d-none d-sm-inline">
1100
                    <?php echo $lang->get('version_alone'); ?>&nbsp;<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>
1101
                </div>
1102
                <!-- Default to the left -->
1103
                <strong>Copyright &copy; <?php echo TP_COPYRIGHT; ?> <a href="<?php echo TEAMPASS_URL; ?>"><?php echo TP_TOOL_NAME; ?></a>.</strong> All rights reserved.
1104
            </footer>
1105
        </div>
1106
        <!-- ./wrapper -->
1107
1108
    <?php
1109
        /* MAIN PAGE */
1110
1111
        echo '
1112
<input type="hidden" id="temps_restant" value="', $session->get('user-session_duration') ?? '', '" />';
1113
// display an item in the context of OTV link
1114
} elseif ((null === $session->get('user-validite_pw')|| empty($session->get('user-validite_pw')) === true || empty($session->get('user-id')) === true)
1115
    && empty($get['otv']) === false
1116
) {
1117
    // case where one-shot viewer
1118
    if (empty($request->query->get('code')) === false && empty($request->query->get('stamp')) === false
1119
    ) {
1120
        include './includes/core/otv.php';
1121
    } else {
1122
        $session->set('system-error_code', ERR_VALID_SESSION);
1123
        $session->set(
1124
            'user-initial_url',
1125
            filter_var(
1126
                substr(
1127
                    $server['request_uri'],
1128
                    strpos($server['request_uri'], 'index.php?')
1129
                ),
1130
                FILTER_SANITIZE_URL
1131
            )
1132
        );
1133
        include $SETTINGS['cpassman_dir'] . '/error.php';
1134
    }
1135
} elseif (//(empty($session->get('user-id')) === false && $session->get('user-id') !== null) ||
1136
        empty($session->get('user-id')) === true
1137
        || null === $session->get('user-validite_pw')
1138
        || $session->get('user-validite_pw') === 0
1139
    ) {
1140
    // case where user not logged and can't access a direct link
1141
    if (empty($get['page']) === false) {
1142
        $session->set(
1143
            'user-initial_url',
1144
            filter_var(
1145
                substr($server['request_uri'], strpos($server['request_uri'], 'index.php?')),
1146
                FILTER_SANITIZE_URL
1147
            )
1148
        );
1149
        // REDIRECTION PAGE ERREUR
1150
        echo '
1151
            <script language="javascript" type="text/javascript">
1152
                window.location.href = "./index.php";
1153
            </script>';
1154
        exit;
1155
    }
1156
    
1157
    // LOGIN form  
1158
    include $SETTINGS['cpassman_dir'] . '/includes/core/login.php';
1159
    
1160
} else {
1161
    // Clear session
1162
    $session->invalidate();
1163
}
1164
    ?>
1165
1166
    <!-- Modal -->
1167
    <div class="modal fade" id="warningModal" tabindex="-1" role="dialog" aria-labelledby="Caution" aria-hidden="true">
1168
        <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
1169
            <div class="modal-content">
1170
                <div class="modal-header">
1171
                    <h5 class="modal-title" id="warningModalTitle"></h5>
1172
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="warningModalCrossClose">
1173
                        <span aria-hidden="true">&times;</span>
1174
                    </button>
1175
                </div>
1176
                <div class="modal-body" id="warningModalBody">
1177
                </div>
1178
                <div class="modal-footer">
1179
                    <button type="button" class="btn btn-secondary" data-dismiss="modal" id="warningModalButtonClose"></button>
1180
                    <button type="button" class="btn btn-primary" id="warningModalButtonAction"></button>
1181
                </div>
1182
            </div>
1183
        </div>
1184
    </div>
1185
1186
1187
1188
    <!-- REQUIRED SCRIPTS -->
1189
1190
    <!-- Font Awesome Icons -->
1191
    <link href="plugins/fontawesome-free-6/css/fontawesome.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" rel="stylesheet">
1192
    <link href="plugins/fontawesome-free-6/css/solid.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" rel="stylesheet">
1193
    <link href="plugins/fontawesome-free-6/css/regular.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" rel="stylesheet">
1194
    <link href="plugins/fontawesome-free-6/css/brands.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" rel="stylesheet">
1195
    <link href="plugins/fontawesome-free-6/css/v5-font-face.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" rel="stylesheet" /> 
1196
    <!-- jQuery -->
1197
    <script src="plugins/jquery/jquery.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1198
    <script src="plugins/jquery/jquery.cookie.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/javascript"></script>
1199
    <!-- jQuery UI -->
1200
    <script src="plugins/jqueryUI/jquery-ui.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1201
    <link rel="stylesheet" href="plugins/jqueryUI/jquery-ui.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1202
    <!-- Popper -->
1203
    <script src="plugins/popper/umd/popper.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1204
    <!-- Bootstrap -->
1205
    <script src="plugins/bootstrap/js/bootstrap.bundle.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1206
    <!-- AdminLTE -->
1207
    <script src="plugins/adminlte/js/adminlte.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1208
    <!-- Altertify -->
1209
    <!--<script type="text/javascript" src="plugins/alertifyjs/alertify.min.js"></script>-->
1210
    <!-- Toastr -->
1211
    <script type="text/javascript" src="plugins/toastr/toastr.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1212
    <!-- STORE.JS -->
1213
    <script type="text/javascript" src="plugins/store.js/dist/store.everything.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1214
    <!-- cryptojs-aesphp -->
1215
    <script type="text/javascript" src="includes/libraries/cryptojs/crypto-js.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1216
    <script type="text/javascript" src="includes/libraries/cryptojs/encryption.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1217
    <!-- pace -->
1218
    <script type="text/javascript" data-pace-options='{ "ajax": true, "eventLag": false }' src="plugins/pace-progress/pace.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1219
    <!-- select2 -->
1220
    <script type="text/javascript" src="plugins/select2/js/select2.full.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1221
    <!-- simplePassMeter -->
1222
    <link rel="stylesheet" href="plugins/simplePassMeter/simplePassMeter.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/css" />
1223
    <script type="text/javascript" src="plugins/simplePassMeter/simplePassMeter.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1224
    <!-- platform -->
1225
    <script type="text/javascript" src="plugins/platform/platform.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1226
    <!-- radiobuttons -->
1227
    <link rel="stylesheet" href="plugins/radioforbuttons/bootstrap-buttons.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/css" />
1228
    <script type="text/javascript" src="plugins/radioforbuttons/jquery.radiosforbuttons.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1229
    <!-- ICHECK -->
1230
    <!--<link rel="stylesheet" href="./plugins/icheck-material/icheck-material.min.css">-->
1231
    <link rel="stylesheet" href="./plugins/icheck/skins/all.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1232
    <script type="text/javascript" src="./plugins/icheck/icheck.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1233
    <!-- bootstrap-add-clear -->
1234
    <script type="text/javascript" src="plugins/bootstrap-add-clear/bootstrap-add-clear.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1235
    <!-- DOMPurify -->
1236
    <script type="text/javascript" src="plugins/DOMPurify/purify.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1237
1238
    <?php
1239
    $get['page'] = $request->query->filter('page', null, FILTER_SANITIZE_SPECIAL_CHARS);
1240
    if ($menuAdmin === true) {
1241
        ?>
1242
        <link rel="stylesheet" href="./plugins/toggles/css/toggles.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1243
        <link rel="stylesheet" href="./plugins/toggles/css/toggles-modern.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1244
        <script src="./plugins/toggles/toggles.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/javascript"></script>
1245
        <!-- InputMask -->
1246
        <script src="./plugins/inputmask/jquery.inputmask.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1247
        <!-- Sortable -->
1248
        <!--<script src="./plugins/sortable/jquery.sortable.js"></script>-->
1249
        <!-- PLUPLOAD -->
1250
        <script type="text/javascript" src="plugins/plupload/js/plupload.full.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1251
        <!-- DataTables -->
1252
        <link rel="stylesheet" src="./plugins/datatables/css/jquery.dataTables.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1253
        <link rel="stylesheet" src="./plugins/datatables/css/dataTables.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1254
        <script type="text/javascript" src="./plugins/datatables/js/jquery.dataTables.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1255
        <script type="text/javascript" src="./plugins/datatables/js/dataTables.bootstrap4.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1256
        <link rel="stylesheet" src="./plugins/datatables/extensions/Responsive-2.2.2/css/responsive.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1257
        <script type="text/javascript" src="./plugins/datatables/extensions/Responsive-2.2.2/js/dataTables.responsive.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1258
        <script type="text/javascript" src="./plugins/datatables/extensions/Responsive-2.2.2/js/responsive.bootstrap4.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1259
        <script type="text/javascript" src="./plugins/datatables/plugins/select.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1260
        <link rel="stylesheet" src="./plugins/datatables/extensions/Scroller-1.5.0/css/scroller.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1261
        <script type="text/javascript" src="./plugins/datatables/extensions/Scroller-1.5.0/js/dataTables.scroller.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1262
    <?php
1263
    } elseif (isset($get['page']) === true) {
1264
        if (in_array($get['page'], ['items', 'import']) === true) {
1265
            ?>
1266
            <link rel="stylesheet" href="./plugins/jstree/themes/default/style.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1267
            <link rel="stylesheet" href="./plugins/jstree/themes/default-dark/style.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1268
            <script src="./plugins/jstree/jstree.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/javascript"></script>
1269
            <!-- countdownTimer -->
1270
            <script src="./plugins/jquery.countdown360/jquery.countdown360.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1271
            <!-- SUMMERNOTE -->
1272
            <link rel="stylesheet" href="./plugins/summernote/summernote-bs4.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1273
            <script src="./plugins/summernote/summernote-bs4.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1274
            <!-- date-picker -->
1275
            <link rel="stylesheet" href="./plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1276
            <script src="./plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1277
            <!-- time-picker -->
1278
            <link rel="stylesheet" href="./plugins/timepicker/bootstrap-timepicker.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1279
            <script src="./plugins/timepicker/bootstrap-timepicker.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1280
            <!-- PLUPLOAD -->
1281
            <script type="text/javascript" src="plugins/plupload/js/plupload.full.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1282
            <!-- VALIDATE -->
1283
            <script type="text/javascript" src="plugins/jquery-validation/jquery.validate.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1284
            <!-- PWSTRENGHT -->
1285
            <script type="text/javascript" src="plugins/zxcvbn/zxcvbn.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1286
            <script type="text/javascript" src="plugins/jquery.pwstrength/pwstrength-bootstrap.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1287
            <!-- TOGGLE -->
1288
            <link rel="stylesheet" href="./plugins/toggles/css/toggles.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1289
            <link rel="stylesheet" href="./plugins/toggles/css/toggles-modern.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" />
1290
            <script src="./plugins/toggles/toggles.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>" type="text/javascript"></script>
1291
        <?php
1292
        } elseif (in_array($get['page'], ['search', 'folders', 'users', 'roles', 'utilities.deletion', 'utilities.logs', 'utilities.database', 'utilities.renewal', 'tasks']) === true) {
1293
            ?>
1294
            <!-- DataTables -->
1295
            <link rel="stylesheet" src="./plugins/datatables/css/jquery.dataTables.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1296
            <link rel="stylesheet" src="./plugins/datatables/css/dataTables.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1297
            <script type="text/javascript" src="./plugins/datatables/js/jquery.dataTables.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1298
            <script type="text/javascript" src="./plugins/datatables/js/dataTables.bootstrap4.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1299
            <link rel="stylesheet" src="./plugins/datatables/extensions/Responsive-2.2.2/css/responsive.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1300
            <script type="text/javascript" src="./plugins/datatables/extensions/Responsive-2.2.2/js/dataTables.responsive.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1301
            <script type="text/javascript" src="./plugins/datatables/extensions/Responsive-2.2.2/js/responsive.bootstrap4.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1302
            <script type="text/javascript" src="./plugins/datatables/plugins/select.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1303
            <link rel="stylesheet" src="./plugins/datatables/extensions/Scroller-1.5.0/css/scroller.bootstrap4.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1304
            <script type="text/javascript" src="./plugins/datatables/extensions/Scroller-1.5.0/js/dataTables.scroller.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1305
            <!-- dater picker -->
1306
            <link rel="stylesheet" href="./plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1307
            <script src="./plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1308
            <!-- daterange picker -->
1309
            <link rel="stylesheet" href="./plugins/daterangepicker/daterangepicker.css?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>">
1310
            <script src="./plugins/moment/moment.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1311
            <script src="./plugins/daterangepicker/daterangepicker.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1312
            <!-- SlimScroll -->
1313
            <script src="./plugins/slimScroll/jquery.slimscroll.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1314
            <!-- FastClick -->
1315
            <script src="./plugins/fastclick/fastclick.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1316
        <?php
1317
        } elseif ($get['page'] === 'profile') {
1318
            ?>
1319
            <!-- FILESAVER -->
1320
            <script type="text/javascript" src="plugins/downloadjs/download.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1321
            <!-- PLUPLOAD -->
1322
            <script type="text/javascript" src="plugins/plupload/js/plupload.full.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1323
        <?php
1324
        } elseif ($get['page'] === 'export') {
1325
            ?>
1326
            <!-- FILESAVER -->
1327
            <script type="text/javascript" src="plugins/downloadjs/download.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1328
            <!-- PWSTRENGHT -->
1329
            <script type="text/javascript" src="plugins/zxcvbn/zxcvbn.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1330
            <script type="text/javascript" src="plugins/jquery.pwstrength/pwstrength-bootstrap.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1331
        <?php
1332
        }
1333
    }
1334
    ?>
1335
    <!-- functions -->
1336
    <script type="text/javascript" src="includes/js/functions.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1337
    <script type="text/javascript" src="includes/js/CreateRandomString.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1338
    <input type="hidden" id="encryptClientServerStatus" value="<?php echo $SETTINGS['encryptClientServer'] ?? 1; ?>" />
1339
1340
    </body>
1341
1342
</html>
1343
1344
<script type="text/javascript">
1345
    //override defaults
1346
    /*alertify.defaults.transition = "slide";
1347
    alertify.defaults.theme.ok = "btn btn-primary";
1348
    alertify.defaults.theme.cancel = "btn btn-danger";
1349
    alertify.defaults.theme.input = "form-control";*/
1350
1351
    toastr.options = {
1352
        "closeButton": false,
1353
        "debug": false,
1354
        "newestOnTop": false,
1355
        "progressBar": false,
1356
        "positionClass": "toast-bottom-right",
1357
        "preventDuplicates": true,
1358
        "onClick": "close",
1359
        "showDuration": "300",
1360
        "hideDuration": "1000",
1361
        "timeOut": "0",
1362
        "extendedTimeOut": "0",
1363
        "showEasing": "swing",
1364
        "hideEasing": "linear",
1365
        "showMethod": "fadeIn",
1366
        "hideMethod": "fadeOut"
1367
    }
1368
1369
    // Clipboard translations
1370
    const TRANSLATIONS_CLIPBOARD = {
1371
        clipboard_unsafe: "<?php echo $lang->get('clipboard_unsafe'); ?>",
1372
        clipboard_clear_now: "<?php echo $lang->get('clipboard_clear_now'); ?>",
1373
        clipboard_clearing_failed: "<?php echo $lang->get('clipboard_clearing_failed'); ?>",
1374
        clipboard_cleared: "<?php echo $lang->get('clipboard_cleared'); ?>",
1375
        unable_to_clear_clipboard: "<?php echo $lang->get('unable_to_clear_clipboard'); ?>"
1376
    };
1377
</script>
1378
1379
<script type="text/javascript" src="includes/js/secure-clipboard-cleaner.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
1380
1381
<script>
1382
    $(document).ready(function() {
1383
        // PWA with windowControlsOverlay
1384
        if ('windowControlsOverlay' in navigator) {
1385
            // Event listener for window-controls-overlay changes
1386
            navigator.windowControlsOverlay.addEventListener('geometrychange', function(event) {
1387
                // Wait few time for resize animations
1388
                $(this).delay(250).queue(function() {
1389
                    // Move header content
1390
                    adjustForWindowControlsOverlay(event.titlebarAreaRect);
1391
                    $(this).dequeue();
1392
                });
1393
            });
1394
1395
            // Move header content
1396
            adjustForWindowControlsOverlay(navigator.windowControlsOverlay.getTitlebarAreaRect());
1397
        }
1398
1399
        function adjustForWindowControlsOverlay(rect) {
1400
            // Display width - available space + 5px margin
1401
            let margin = 5;
1402
            let width = document.documentElement.clientWidth - rect.width + margin;
1403
1404
            if (width - margin !== document.documentElement.clientWidth) {
1405
                // Add right padding to main-header
1406
                $('.main-header').css('padding-right', width + 'px');
1407
1408
                // Window drag area
1409
                $('.main-header').css('-webkit-app-region', 'drag');
1410
                $('.main-header *').css('-webkit-app-region', 'no-drag');
1411
            } else {
1412
                // Remove right padding to main-header
1413
                $('.main-header').css('padding-right', '0px');
1414
1415
                // No window drag area when titlebar is present
1416
                $('.main-header').css('-webkit-app-region', 'no-drag');
1417
            }
1418
        }
1419
    });
1420
1421
    // Handle external link open in current PWA
1422
    if ("launchQueue" in window) {
1423
        window.launchQueue.setConsumer((launchParams) => {
1424
            if (launchParams.targetURL) {
1425
                // Redirect on new URL in focus-existing client mode
1426
                window.location.href = launchParams.targetURL;
1427
            }
1428
        });
1429
    }
1430
</script>
1431
1432
<?php
1433
//$get = [];
1434
//$get['page'] = $request->query->get('page') === null ? '' : $request->query->get('page');
1435
1436
// Load links, css and javascripts
1437
if (isset($SETTINGS['cpassman_dir']) === true) {
1438
    include_once $SETTINGS['cpassman_dir'] . '/includes/core/load.js.php';
1439
    if ($menuAdmin === true) {
1440
        include_once $SETTINGS['cpassman_dir'] . '/pages/admin.js.php';
1441
        if ($get['page'] === '2fa') {
1442
            include_once $SETTINGS['cpassman_dir'] . '/pages/2fa.js.php';
1443
        } elseif ($get['page'] === 'api') {
1444
            include_once $SETTINGS['cpassman_dir'] . '/pages/api.js.php';
1445
        } elseif ($get['page'] === 'backups') {
1446
            include_once $SETTINGS['cpassman_dir'] . '/pages/backups.js.php';
1447
        } elseif ($get['page'] === 'emails') {
1448
            include_once $SETTINGS['cpassman_dir'] . '/pages/emails.js.php';
1449
        } elseif ($get['page'] === 'ldap') {
1450
            include_once $SETTINGS['cpassman_dir'] . '/pages/ldap.js.php';
1451
        } elseif ($get['page'] === 'uploads') {
1452
            include_once $SETTINGS['cpassman_dir'] . '/pages/uploads.js.php';
1453
        } elseif ($get['page'] === 'fields') {
1454
            include_once $SETTINGS['cpassman_dir'] . '/pages/fields.js.php';
1455
        } elseif ($get['page'] === 'options') {
1456
            include_once $SETTINGS['cpassman_dir'] . '/pages/options.js.php';
1457
        } elseif ($get['page'] === 'statistics') {
1458
            include_once $SETTINGS['cpassman_dir'] . '/pages/statistics.js.php';
1459
        } elseif ($get['page'] === 'tasks') {
1460
            include_once $SETTINGS['cpassman_dir'] . '/pages/tasks.js.php';
1461
        } elseif ($get['page'] === 'oauth') {
1462
            include_once $SETTINGS['cpassman_dir'] . '/pages/oauth.js.php';        
1463
        } elseif ($get['page'] === 'tools') {
1464
            include_once $SETTINGS['cpassman_dir'] . '/pages/tools.js.php';
1465
        }
1466
    } elseif (isset($get['page']) === true && $get['page'] !== '') {
1467
        if ($get['page'] === 'items') {
1468
            include_once $SETTINGS['cpassman_dir'] . '/pages/items.js.php';
1469
        } elseif ($get['page'] === 'import') {
1470
            include_once $SETTINGS['cpassman_dir'] . '/pages/import.js.php';
1471
        } elseif ($get['page'] === 'export') {
1472
            include_once $SETTINGS['cpassman_dir'] . '/pages/export.js.php';
1473
        } elseif ($get['page'] === 'offline') {
1474
            include_once $SETTINGS['cpassman_dir'] . '/pages/offline.js.php';
1475
        } elseif ($get['page'] === 'search') {
1476
            include_once $SETTINGS['cpassman_dir'] . '/pages/search.js.php';
1477
        } elseif ($get['page'] === 'profile') {
1478
            include_once $SETTINGS['cpassman_dir'] . '/pages/profile.js.php';
1479
        } elseif ($get['page'] === 'favourites') {
1480
            include_once $SETTINGS['cpassman_dir'] . '/pages/favorites.js.php';
1481
        } elseif ($get['page'] === 'folders') {
1482
            include_once $SETTINGS['cpassman_dir'] . '/pages/folders.js.php';
1483
        } elseif ($get['page'] === 'users') {
1484
            include_once $SETTINGS['cpassman_dir'] . '/pages/users.js.php';
1485
        } elseif ($get['page'] === 'roles') {
1486
            include_once $SETTINGS['cpassman_dir'] . '/pages/roles.js.php';
1487
        } elseif ($get['page'] === 'utilities.deletion') {
1488
            include_once $SETTINGS['cpassman_dir'] . '/pages/utilities.deletion.js.php';
1489
        } elseif ($get['page'] === 'utilities.logs') {
1490
            include_once $SETTINGS['cpassman_dir'] . '/pages/utilities.logs.js.php';
1491
        } elseif ($get['page'] === 'utilities.database') {
1492
            include_once $SETTINGS['cpassman_dir'] . '/pages/utilities.database.js.php';
1493
        } elseif ($get['page'] === 'utilities.renewal') {
1494
            include_once $SETTINGS['cpassman_dir'] . '/pages/utilities.renewal.js.php';
1495
        }
1496
    } else {
1497
        include_once $SETTINGS['cpassman_dir'] . '/includes/core/login.js.php';
1498
    }
1499
}
1500