Passed
Push — development ( 9f6224...3f3c06 )
by Nils
04:02
created

index.php (1 issue)

Severity
1
<?php
2
/**
3
 *
4
 * @file          index.php
5
 * @author        Nils Laumaillé
6
 * @version       2.1.27
7
 * @copyright     (c) 2009-2018 Nils Laumaillé
8
 * @licensing     GNU GPL-3.0
9
 * @link          http://www.teampass.net
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 */
15
16
header("X-XSS-Protection: 1; mode=block");
17
header("X-Frame-Options: SameOrigin");
18
19
// **PREVENTING SESSION HIJACKING**
20
// Prevents javascript XSS attacks aimed to steal the session ID
21
ini_set('session.cookie_httponly', 1);
22
23
// **PREVENTING SESSION FIXATION**
24
// Session ID cannot be passed through URLs
25
ini_set('session.use_only_cookies', 1);
26
27
// Uses a secure connection (HTTPS) if possible
28
ini_set('session.cookie_secure', 0);
29
30
// Before we start processing, we should abort no install is present
31
if (!file_exists('includes/config/settings.php')) {
32
    // This should never happen, but in case it does
33
    // this means if headers are sent, redirect will fallback to JS
34
    if (headers_sent()) {
35
        echo '<script language="javascript" type="text/javascript">document.location.replace("install/install.php");</script>';
36
    } else {
37
        header('Location: install/install.php');
38
    }
39
    // Now either way, we should stop processing further
40
    exit();
41
}
42
43
// initialise CSRFGuard library
44
require_once('./includes/libraries/csrfp/libs/csrf/csrfprotector.php');
45
csrfProtector::init();
46
session_id();
47
48
// Load config
49
if (file_exists('../includes/config/tp.config.php')) {
50
    require_once '../includes/config/tp.config.php';
51
} elseif (file_exists('./includes/config/tp.config.php')) {
52
    require_once './includes/config/tp.config.php';
53
} else {
54
    throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1);
55
}
56
57
// Include files
58
require_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
59
require_once $SETTINGS['cpassman_dir'].'/includes/config/include.php';
60
require_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
61
$superGlobal = new protect\SuperGlobal\SuperGlobal();
62
63
64
// initialize session
65
$_SESSION['CPM'] = 1;
66
if (isset($SETTINGS['cpassman_dir']) === false || $SETTINGS['cpassman_dir'] === "") {
67
    $SETTINGS['cpassman_dir'] = ".";
68
    $SETTINGS['cpassman_url'] = $superGlobal->get("REQUEST_URI", "SERVER");
69
}
70
71
// Include files
72
require_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
73
require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
74
75
76
// Open MYSQL database connection
77
require_once './includes/libraries/Database/Meekrodb/db.class.php';
78
$pass = defuse_return_decrypted($pass);
79
DB::$host = $server;
80
DB::$user = $user;
81
DB::$password = $pass;
82
DB::$dbName = $database;
83
DB::$port = $port;
84
DB::$encoding = $encoding;
85
DB::$error_handler = true;
86
$link = mysqli_connect($server, $user, $pass, $database, $port);
87
$link->set_charset($encoding);
88
89
90
// Load Core library
91
require_once $SETTINGS['cpassman_dir'].'/sources/core.php';
92
93
// Prepare POST variables
94
$post_language =        filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
95
$post_sig_response =    filter_input(INPUT_POST, 'sig_response', FILTER_SANITIZE_STRING);
96
$post_duo_login =       filter_input(INPUT_POST, 'duo_login', FILTER_SANITIZE_STRING);
97
$post_duo_pwd =         filter_input(INPUT_POST, 'duo_pwd', FILTER_SANITIZE_STRING);
98
$post_duo_data =        filter_input(INPUT_POST, 'duo_data', FILTER_SANITIZE_STRING);
99
$post_login =           filter_input(INPUT_POST, 'login', FILTER_SANITIZE_STRING);
100
$post_pw =              filter_input(INPUT_POST, 'pw', FILTER_SANITIZE_STRING);
101
102
// Prepare superGlobal variables
103
$session_user_language =        $superGlobal->get("user_language", "SESSION");
104
$session_user_id =              $superGlobal->get("user_id", "SESSION");
105
$session_user_flag =            $superGlobal->get("user_language_flag", "SESSION");
106
$session_user_admin =           $superGlobal->get("user_admin", "SESSION");
107
$session_user_human_resources = $superGlobal->get("user_can_manage_all_users", "SESSION");
108
$session_user_avatar_thumb =    $superGlobal->get("user_avatar_thumb", "SESSION");
109
$session_name =                 $superGlobal->get("name", "SESSION");
110
$session_lastname =             $superGlobal->get("lastname", "SESSION");
111
$session_user_manager =         $superGlobal->get("user_manager", "SESSION");
112
$session_user_read_only =       $superGlobal->get("user_read_only", "SESSION");
113
$session_is_admin =             $superGlobal->get("is_admin", "SESSION");
114
$session_login =                $superGlobal->get("login", "SESSION");
115
$session_validite_pw =          $superGlobal->get("validite_pw", "SESSION");
116
$session_nb_folders =           $superGlobal->get("nb_folders", "SESSION");
117
$session_nb_roles =             $superGlobal->get("nb_roles", "SESSION");
118
$session_autoriser =            $superGlobal->get("autoriser", "SESSION");
119
$session_hide_maintenance =     $superGlobal->get("hide_maintenance", "SESSION");
120
$session_initial_url =          $superGlobal->get("initial_url", "SESSION");
121
$server_request_uri =           $superGlobal->get("REQUEST_URI", "SERVER");
122
$session_nb_users_online =      $superGlobal->get("nb_users_online", "SESSION");
123
124
/* DEFINE WHAT LANGUAGE TO USE */
125
if (isset($_GET['language']) === true) {
126
    // case of user has change language in the login page
127
    $dataLanguage = DB::queryFirstRow(
128
        "SELECT flag, name
129
        FROM ".prefix_table("languages")."
130
        WHERE name = %s",
131
        filter_var($_GET['language'], FILTER_SANITIZE_STRING)
132
    );
133
    $superGlobal->put("user_language", $dataLanguage['name'], "SESSION");
134
    $superGlobal->put("user_language_flag", $dataLanguage['flag'], "SESSION");
135
} elseif ($session_user_id === null && null === $post_language && $session_user_language === null) {
136
    //get default language
137
    $dataLanguage = DB::queryFirstRow(
138
        "SELECT m.valeur AS valeur, l.flag AS flag
139
        FROM ".prefix_table("misc")." AS m
140
        INNER JOIN ".prefix_table("languages")." AS l ON (m.valeur = l.name)
141
        WHERE m.type=%s_type AND m.intitule=%s_intitule",
142
        array(
143
            'type' => "admin",
144
            'intitule' => "default_language"
145
        )
146
    );
147
    if (empty($dataLanguage['valeur'])) {
148
        $superGlobal->put("user_language", "english", "SESSION");
149
        $superGlobal->put("user_language_flag", "us.png", "SESSION");
150
        $session_user_language = "english";
151
    } else {
152
        $superGlobal->put("user_language", $dataLanguage['valeur'], "SESSION");
153
        $superGlobal->put("user_language_flag", $dataLanguage['flag'], "SESSION");
154
        $session_user_language = $dataLanguage['valeur'];
155
    }
156
} elseif (isset($SETTINGS['default_language']) === true && $session_user_language === null) {
157
    $superGlobal->put("user_language", $SETTINGS['default_language'], "SESSION");
158
    $session_user_language = $SETTINGS['default_language'];
159
} elseif (null !== $post_language) {
160
    $superGlobal->put("user_language", $post_language, "SESSION");
161
    $session_user_language = $post_language;
162
} elseif ($session_user_language === null || empty($session_user_language) === true) {
163
    if (null !== $post_language) {
164
        $superGlobal->put("user_language", $post_language, "SESSION");
165
        $session_user_language = $post_language;
166
    } elseif ($session_user_language !== null) {
167
        $superGlobal->put("user_language", $SETTINGS['default_language'], "SESSION");
168
        $session_user_language = $SETTINGS['default_language'];
169
    }
170
} elseif ($session_user_language === '0') {
171
    $superGlobal->put("user_language", $SETTINGS['default_language'], "SESSION");
172
    $session_user_language = $SETTINGS['default_language'];
173
}
174
175
if (isset($SETTINGS['cpassman_dir']) === false || $SETTINGS['cpassman_dir'] === "") {
176
    $SETTINGS['cpassman_dir'] = ".";
177
    $SETTINGS['cpassman_url'] = (string) $server_request_uri;
178
}
179
180
// Load user languages files
181
if (in_array($session_user_language, $languagesList) === true) {
182
    if (file_exists($SETTINGS['cpassman_dir'].'/includes/language/'.$session_user_language.'.php') === true) {
183
        require_once $SETTINGS['cpassman_dir'].'/includes/language/'.$session_user_language.'.php';
184
    }
185
} else {
186
    $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
187
    include $SETTINGS['cpassman_dir'].'/error.php';
188
}
189
190
// load 2FA Google
191
if (isset($SETTINGS['google_authentication']) === true && $SETTINGS['google_authentication'] === "1") {
192
    include_once($SETTINGS['cpassman_dir']."/includes/libraries/Authentication/TwoFactorAuth/TwoFactorAuth.php");
193
}
194
195
// load 2FA Yubico
196
if (isset($SETTINGS['yubico_authentication']) === true && $SETTINGS['yubico_authentication'] === "1") {
197
    include_once($SETTINGS['cpassman_dir']."/includes/libraries/Authentication/Yubico/Yubico.php");
198
}
199
200
// Load links, css and javascripts
201
if (isset($_SESSION['CPM']) === true && isset($SETTINGS['cpassman_dir']) === true) {
202
    require_once $SETTINGS['cpassman_dir'].'/load.php';
203
}
204
205
?>
206
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
207
208
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
209
<head>
210
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
211
<meta http-equiv="X-UA-Compatible" content="IE=edge">
212
<title>Teampass</title>
213
<script type="text/javascript">
214
    //<![CDATA[
215
    if (window.location.href.indexOf("page=") == -1 && (window.location.href.indexOf("otv=") == -1 && window.location.href.indexOf("action=") == -1)) {
216
        if (window.location.href.indexOf("session_over=true") == -1) {
217
            //location.replace("./index.php?page=items");
218
        } else {
219
            location.replace("./logout.php");
220
        }
221
    }
222
    //]]>
223
</script>
224
<?php
225
226
// load HEADERS
227
if (isset($_SESSION['CPM'])) {
228
    echo $htmlHeaders;
229
}
230
?>
231
    </head>
232
233
<body>
234
    <?php
235
236
/* HEADER */
237
    echo '
238
    <div id="top">
239
        <div id="logo"><img src="includes/images/canevas/logo.png" alt="" /></div>';
240
    // Display menu
241
    if (empty($session_login) === false) {
242
        // welcome message
243
        echo '
244
        <div style="float:right; margin:-10px 5px 0 0; color:#FFF;">'
245
            .$LANG['index_welcome'].'&nbsp;<b>'.$session_name.'&nbsp;'.$session_lastname
246
            .'&nbsp;['.$session_login.']</b>&nbsp;-&nbsp;'
247
            , $session_user_admin === '1' ? $LANG['god'] :
248
                (
249
                    $session_user_manager === '1' ? $LANG['gestionnaire'] :
250
                    (
251
                        $session_user_read_only === '1' ? $LANG['read_only_account'] :
252
                        ($session_user_human_resources === '1' ? $LANG['human_resources'] :$LANG['user'])
253
                    )
254
                ), '&nbsp;'.strtolower($LANG['index_login']).'</div>';
255
256
        echo '
257
        <div id="menu_top">
258
            <div style="margin-left:20px; margin-top:2px;width:710px;" id="main_menu">';
259
        if ($session_user_admin === '0' || $SETTINGS_EXT['admin_full_right'] == 0) {
260
            echo '
261
                <a class="btn btn-default" href="#"',
262
                ($session_nb_folders !== null && intval($session_nb_folders) === 0)
263
                || ($session_nb_roles !== null && intval($session_nb_roles) === 0) ? '' : ' onclick="MenuAction(\'items\')"',
264
                '>
265
                    <i class="fa fa-key fa-2x tip" title="'.$LANG['pw'].'"></i>
266
                </a>
267
268
                <a class="btn btn-default" href="#"',
269
                ($session_nb_folders !== null && intval($session_nb_folders) === 0)
270
                || ($session_nb_roles !== null && intval($session_nb_roles) === 0) ? '' : ' onclick="MenuAction(\'find\')"',
271
                '>
272
                    <i class="fa fa-binoculars fa-2x tip" title="'.$LANG['find'].'"></i>
273
                </a>';
274
        }
275
276
        // Favourites menu
277
        if (isset($SETTINGS['enable_favourites'])
278
            && $SETTINGS['enable_favourites'] == 1
279
            &&
280
            ($session_user_admin === '0' || ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false))
281
        ) {
282
            echo '
283
                    <a class="btn btn-default" href="#" onclick="MenuAction(\'favourites\')">
284
                        <i class="fa fa-star fa-2x tip" title="'.$LANG['my_favourites'].'"></i>
285
                    </a>';
286
        }
287
        // KB menu
288
        if (isset($SETTINGS['enable_kb']) && $SETTINGS['enable_kb'] == 1) {
289
            echo '
290
                    <a class="btn btn-default" href="#" onclick="MenuAction(\'kb\')">
291
                        <i class="fa fa-map-signs fa-2x tip" title="'.$LANG['kb_menu'].'"></i>
292
                    </a>';
293
        }
294
        echo '
295
        <span id="menu_suggestion_position">';
296
        // SUGGESTION menu
297
        if (isset($SETTINGS['enable_suggestion']) && $SETTINGS['enable_suggestion'] === '1'
298
            && ($session_user_read_only === '1' || $session_user_admin === '1' || $session_user_manager === '1')
299
        ) {
300
            echo '
301
                <a class="btn btn-default" href="#" onclick="MenuAction(\'suggestion\')">
302
                    <i class="fa fa-lightbulb-o fa-2x tip" id="menu_icon_suggestions" title="'.$LANG['suggestion_menu'].'"></i>
303
                </a>';
304
        }
305
        echo '
306
        </span>';
307
        // Admin menu
308
        if ($session_user_admin === '1') {
309
            echo '
310
                    &nbsp;
311
                    <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_main\')">
312
                        <i class="fa fa-info fa-2x tip" title="'.$LANG['admin_main'].'"></i>
313
                    </a>
314
                    <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_settings\')">
315
                        <i class="fa fa-wrench fa-2x tip" title="'.$LANG['admin_settings'].'"></i>
316
                    </a>';
317
        }
318
319
        if ($session_user_admin === '1' || $session_user_manager === '1' || $session_user_human_resources === '1') {
320
            echo '
321
                &nbsp;
322
                <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_folders\')">
323
                    <i class="fa fa-folder-open fa-2x tip" title="'.$LANG['admin_groups'].'"></i>
324
                </a>
325
                <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_roles\')">
326
                    <i class="fa fa-graduation-cap fa-2x tip" title="'.$LANG['admin_functions'].'"></i>
327
                </a>
328
                <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_users\')">
329
                    <i class="fa fa-users fa-2x tip" title="'.$LANG['admin_users'].'"></i>
330
                </a>
331
                <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_views\')">
332
                    <i class="fa fa-cubes fa-2x tip" title="'.$LANG['admin_views'].'"></i>
333
                </a>';
334
        }
335
336
        echo '
337
                <div style="float:right;">
338
                    <ul class="menu" style="">
339
                        <li class="" style="padding:4px;width:40px; text-align:center;"><i class="fa fa-dashboard fa-fw"></i>&nbsp;
340
                            <ul class="menu_200" style="text-align:left;">',
341
                                ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === true) ? '' : isset($SETTINGS['enable_pf_feature']) === true && $SETTINGS['enable_pf_feature'] == 1 ? '
342
                                <li onclick="$(\'#div_set_personal_saltkey\').dialog(\'open\')">
343
                                    <i class="fa fa-key fa-fw"></i> &nbsp;'.$LANG['home_personal_saltkey_button'].'
344
                                </li>' : '', '
345
                                <li onclick="$(\'#div_increase_session_time\').dialog(\'open\')">
346
                                    <i class="fa fa-clock-o fa-fw"></i> &nbsp;'.$LANG['index_add_one_hour'].'
347
                                </li>
348
                                <li onclick="loadProfileDialog()">
349
                                    <i class="fa fa-user fa-fw"></i> &nbsp;'.$LANG['my_profile'].'
350
                                </li>
351
                                <li onclick="MenuAction(\'deconnexion\', \''.$session_user_id.'\')">
352
                                    <i class="fa fa-sign-out fa-fw"></i> &nbsp;'.$LANG['disconnect'].'
353
                                </li>
354
                            </ul>
355
                        </li>
356
                    </ul>
357
                </div>';
358
359
        if ($session_user_admin !== '1' || ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false)) {
360
            echo '
361
                <div style="float:right; margin-right:10px;">
362
                    <ul class="menu" id="menu_last_seen_items">
363
                        <li class="" style="padding:4px;width:40px; text-align:center;"><i class="fa fa-map fa-fw"></i>&nbsp;&nbsp;
364
                            <ul class="menu_200" id="last_seen_items_list" style="text-align:left;">
365
                                <li>'.$LANG['please_wait'].'</li>
366
                            </ul>
367
                        </li>
368
                    </ul>
369
                </div>';
370
        }
371
372
        // show avatar
373
        if ($session_user_avatar_thumb !== null && empty($session_user_avatar_thumb) === false) {
374
            if (file_exists('includes/avatars/'.$session_user_avatar_thumb)) {
375
                $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$session_user_avatar_thumb;
376
            } else {
377
                $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
378
            }
379
        } else {
380
            $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
381
        }
382
        echo '
383
                <div style="float:right; margin-right:10px;">
384
                    <img src="'.$avatar.'" style="border-radius:10px; height:28px; cursor:pointer;" onclick="loadProfileDialog()" alt="photo" id="user_avatar_thumb" />
385
                </div>';
386
387
        echo '
388
            </div>';
389
390
        echo '
391
        </div>';
392
    }
393
394
    echo '
395
    </div>';
396
397
    echo '
398
<div id="main_info_box" style="display:none; z-index:99999; position:absolute; width:400px; height:40px;" class="ui-widget ui-state-active ui-color">
399
    <span class="closeButton" onclick="$(\'#main_info_box\').hide()">&#10006</span>
400
    <div id="main_info_box_text" style="text-align:center;margin-top:10px;"></div>
401
</div>';
402
403
/* MAIN PAGE */
404
    echo '
405
        <input type="hidden" id="temps_restant" value="', isset($_SESSION['fin_session']) ? $_SESSION['fin_session'] : '', '" />
406
        <input type="hidden" name="language" id="language" value="" />
407
        <input type="hidden" name="user_pw_complexity" id="user_pw_complexity" value="', isset($_SESSION['user_pw_complexity']) ? $_SESSION['user_pw_complexity'] : '', '" />
408
        <input type="hidden" name="user_session" id="user_session" value=""/>
409
        <input type="hidden" name="encryptClientServer" id="encryptClientServer" value="', isset($SETTINGS['encryptClientServer']) ? $SETTINGS['encryptClientServer'] : '1', '" />
410
        <input type="hidden" name="please_login" id="please_login" value="" />
411
        <input type="hidden" name="disabled_action_on_going" id="disabled_action_on_going" value="" />
412
        <input type="hidden" id="duo_sig_response" value="', null !== $post_sig_response ? $post_sig_response : '', '" />';
413
414
// SENDING STATISTICS?
415
    if (isset($SETTINGS['send_stats']) && $SETTINGS['send_stats'] === "1"
416
        && (!isset($_SESSION['temporary']['send_stats_done']) || $_SESSION['temporary']['send_stats_done'] !== "1")
417
    ) {
418
        echo '
419
            <input type="hidden" name="send_statistics" id="send_statistics" value="1" />';
420
    } else {
421
        echo '
422
        <input type="hidden" name="send_statistics" id="send_statistics" value="0" />';
423
    }
424
425
    echo '
426
    <div id="', (isset($_GET['page']) && filter_var($_GET['page'], FILTER_SANITIZE_STRING) === "items" && $session_user_id !== null) ? "main_simple" : "main", '">';
427
// MESSAGE BOX
428
    echo '
429
            <div style="" class="div_center">
430
                <div id="message_box" style="display:none;width:200px;padding:5px;text-align:center; z-index:999999;" class="ui-widget-content ui-state-error ui-corner-all"></div>
431
            </div>';
432
    // Main page
433
    if ($session_autoriser !== null && $session_autoriser === true) {
434
        // Show menu
435
        echo '
436
            <form method="post" name="main_form" action="">
437
                <input type="hidden" name="menu_action" id="menu_action" value="" />
438
                <input type="hidden" name="changer_pw" id="changer_pw" value="" />
439
                <input type="hidden" name="form_user_id" id="form_user_id" value="', $session_user_id !== null ? $session_user_id : '', '" />
440
                <input type="hidden" name="is_admin" id="is_admin" value="', $session_is_admin !== null ? $session_is_admin : '', '" />
441
                <input type="hidden" name="personal_saltkey_set" id="personal_saltkey_set" value="', isset($_SESSION['user_settings']['clear_psk']) ? true : false, '" />
442
            </form>';
443
    }
444
// ---------
445
// Display a help to admin
446
    $errorAdmin = "";
447
448
// error nb folders
449
    if ($session_nb_folders !== null && intval($session_nb_folders) === 0) {
450
        $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_no_folders'].'<br />';
451
    }
452
// error nb roles
453
    if ($session_nb_roles !== null && intval($session_nb_roles) === 0) {
454
        if (empty($errorAdmin)) {
455
            $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_no_roles'];
456
        } else {
457
            $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_no_roles'];
458
        }
459
    }
460
461
    if ($session_validite_pw !== null && empty($session_validite_pw) === false) {
462
        // error cpassman dir
463
        if (isset($SETTINGS['cpassman_dir']) && empty($SETTINGS['cpassman_dir']) || !isset($SETTINGS['cpassman_dir'])) {
464
            if (empty($errorAdmin)) {
465
                $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_cpassman_dir'];
466
            } else {
467
                $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_cpassman_dir'];
468
            }
469
        }
470
        // error cpassman url
471
        if ($session_validite_pw !== null && (isset($SETTINGS['cpassman_url']) && empty($SETTINGS['cpassman_url']) || !isset($SETTINGS['cpassman_url']))) {
472
            if (empty($errorAdmin)) {
473
                $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_cpassman_url'];
474
            } else {
475
                $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;">&nbsp;</span>'.$LANG['error_cpassman_url'];
476
            }
477
        }
478
    }
479
// Display help
480
    if (!empty($errorAdmin)) {
481
        echo '
482
                <div style="margin:10px;padding:10px;" class="ui-state-error ui-corner-all">
483
                '.$errorAdmin.'
484
                </div>';
485
    }
486
// -----------
487
// Display Maintenance mode information
488
    if (isset($SETTINGS['maintenance_mode']) === true && $SETTINGS['maintenance_mode'] === '1'
489
            && $session_user_admin !== null && $session_user_admin === '1'
490
        ) {
491
        echo '
492
            <div style="text-align:center;margin-bottom:5px;padding:10px;" class="ui-state-highlight ui-corner-all">
493
                <b>'.$LANG['index_maintenance_mode_admin'].'</b>
494
            </div>';
495
    }
496
// Display UPDATE NEEDED information
497
    if (isset($SETTINGS['update_needed']) && $SETTINGS['update_needed'] === true
498
            && $session_user_admin !== null && $session_user_admin === '1'
499
            && (($session_hide_maintenance !== null && $session_hide_maintenance === '0')
500
            || $session_hide_maintenance === null)
501
        ) {
502
        echo '
503
            <div style="text-align:center;margin-bottom:5px;padding:10px;"
504
                class="ui-state-highlight ui-corner-all" id="div_maintenance">
505
                <b>'.$LANG['update_needed_mode_admin'].'</b>
506
                <span style="float:right;cursor:pointer;">
507
                    <span class="fa fa-close mi-red" onclick="toggleDiv(\'div_maintenance\')"></span>
508
                </span>
509
            </div>';
510
    }
511
512
// display an item in the context of OTV link
513
    if (($session_validite_pw === null || empty($session_validite_pw) === true || empty($session_user_id) === true) &&
514
        isset($_GET['otv']) && filter_var($_GET['otv'], FILTER_SANITIZE_STRING) === 'true'
515
    ) {
516
        // case where one-shot viewer
517
        if (isset($_GET['code']) && !empty($_GET['code'])
518
            && isset($_GET['stamp']) && !empty($_GET['stamp'])
519
        ) {
520
            include 'otv.php';
521
        } else {
522
            $_SESSION['error']['code'] = ERR_VALID_SESSION;
523
            $superGlobal->put(
524
                "initial_url",
525
                filter_var(
526
                    substr($server_request_uri, strpos($server_request_uri, "index.php?")),
527
                    FILTER_SANITIZE_URL
528
                ),
529
                "SESSION"
530
            );
531
            include $SETTINGS['cpassman_dir'].'/error.php';
532
        }
533
        // Ask the user to change his password
534
    } elseif (($session_validite_pw === null || $session_validite_pw === false)
535
        && empty($session_user_id) === false
536
    ) {
537
        //Check if password is valid
538
        echo '
539
        <div style="margin:auto; padding:20px; width:500px;" class="ui-state-focus ui-corner-all">
540
            <h3>'.$LANG['index_change_pw'].'</h3>
541
            <div style="height:20px;text-align:center;margin:2px;display:none;" id="change_pwd_error" class=""></div>
542
            <div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all">'.
543
            $LANG['complex_asked'].' : '.$SETTINGS_EXT['pwComplexity'][$_SESSION['user_pw_complexity']][1].
544
            '</div>
545
            <div id="pw_strength" style="margin:0 0 10px 140px;"></div>
546
            <table>
547
                <tr>
548
                    <td>'.$LANG['index_new_pw'].' :</td><td><input type="password" size="15" name="new_pw" id="new_pw"/></td>
549
                </tr>
550
                <tr><td>'.$LANG['index_change_pw_confirmation'].' :</td><td><input type="password" size="15" name="new_pw2" id="new_pw2" onkeypress="if (event.keyCode == 13) ChangeMyPass();" /></td></tr>
551
            </table>
552
            <input type="hidden" id="pw_strength_value" />
553
            <div style="width:420px; text-align:center; margin:15px 0 10px 0;">
554
                <input type="button" onClick="ChangeMyPass()" onkeypress="if (event.keyCode == 13) ChangeMyPass();" class="ui-state-default ui-corner-all" style="padding:4px;width:150px;margin:10px 0 0 80px;" value="'.$LANG['index_change_pw_button'].'" />
555
            </div>
556
        </div>
557
        <script type="text/javascript">
558
            $("#new_pw").focus();
559
        </script>';
560
    // Display pages
561
    } elseif ($session_validite_pw !== null
562
        && $session_validite_pw === true
563
        && empty($_GET['page']) === false
564
        && empty($session_user_id) === false
565
    ) {
566
        if ($session_initial_url !== null && empty($session_initial_url) === false) {
567
            include $session_initial_url;
568
        } elseif ($_GET['page'] == "items") {
569
            // SHow page with Items
570
            if (($session_user_admin !== '1')
571
                ||
572
                ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false)
573
            ) {
574
                include 'items.php';
575
            } else {
576
                $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
577
                include $SETTINGS['cpassman_dir'].'/error.php';
578
            }
579
        } elseif ($_GET['page'] == "find") {
580
            // Show page for items findind
581
            include 'find.php';
582
        } elseif ($_GET['page'] == "favourites") {
583
            // Show page for user favourites
584
            include 'favorites.php';
585
        } elseif ($_GET['page'] == "kb") {
586
            // Show page KB
587
            if (isset($SETTINGS['enable_kb']) && $SETTINGS['enable_kb'] == 1) {
588
                include 'kb.php';
589
            } else {
590
                $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
591
                include $SETTINGS['cpassman_dir'].'/error.php';
592
            }
593
        } elseif ($_GET['page'] == "suggestion") {
594
            // Show page KB
595
            if (isset($SETTINGS['enable_suggestion']) && $SETTINGS['enable_suggestion'] == 1) {
596
                include 'suggestion.php';
597
            } else {
598
                $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
599
                include $SETTINGS['cpassman_dir'].'/error.php';
600
            }
601
        } elseif (in_array($_GET['page'], array_keys($mngPages))) {
602
            // Define if user is allowed to see management pages
603
            if ($session_user_admin === '1') {
604
                include($mngPages[$_GET['page']]);
605
            } elseif ($session_user_manager === '1' || $session_user_human_resources == '1') {
606
                if (($_GET['page'] != "manage_main" && $_GET['page'] != "manage_settings")) {
607
                    include($mngPages[$_GET['page']]);
608
                } else {
609
                    $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
610
                    include $SETTINGS['cpassman_dir'].'/error.php';
611
                }
612
            } else {
613
                $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
614
                include $SETTINGS['cpassman_dir'].'/error.php';
615
            }
616
        } else {
617
            $_SESSION['error']['code'] = ERR_NOT_EXIST; //page doesn't exist
618
            include $SETTINGS['cpassman_dir'].'/error.php';
619
        }
620
        // Case of password recovery
621
    } elseif (isset($_GET['action']) && $_GET['action'] === "password_recovery") {
622
        // Case where user has asked new PW
623
        echo '
624
            <div style="width:400px;margin:50px auto 50px auto;padding:25px;" class="ui-state-highlight ui-corner-all">
625
                <div style="text-align:center;font-weight:bold;margin-bottom:20px;">
626
                    '.$LANG['pw_recovery_asked'].'
627
                </div>
628
                <div id="generate_new_pw_error" style="color:red;display:none;text-align:center;margin:5px;"></div>
629
                <div style="margin-bottom:3px;">
630
                    '.$LANG['pw_recovery_info'].'
631
                </div>
632
                <div style="margin:15px; text-align:center;">
633
                    <input type="button" id="but_generate_new_password" onclick="GenerateNewPassword(\''.htmlspecialchars($_GET['key'], ENT_QUOTES).'\',\''.htmlspecialchars($_GET['login'], ENT_QUOTES).'\')" style="padding:3px;cursor:pointer;" class="ui-state-default ui-corner-all" value="'.$LANG['pw_recovery_button'].'" />
634
                    <br /><br />
635
                    <div id="ajax_loader_send_mail" style="display:none; margin: 20px;"><span class="fa fa-cog fa-spin fa-2x"></span></div>
636
                </div>
637
                <div style="margin-top:30px; text-align:center;">
638
                    <a href="index.php" class="tip" title="'.$LANG['home'].'"><span class="fa fa-home fa-lg"></span></a>
639
                </div>
640
            </div>';
641
    } elseif (empty($session_user_id) === false && $session_user_id !== null) {
642
        // Page doesn't exist
643
        $_SESSION['error']['code'] = ERR_NOT_EXIST;
644
        include $SETTINGS['cpassman_dir'].'/error.php';
645
    // When user is not identified
646
    } else {
647
        // Automatic redirection
648
        if (strpos($server_request_uri, "?") > 0) {
649
            $nextUrl = filter_var(substr($server_request_uri, strpos($server_request_uri, "?")), FILTER_SANITIZE_URL);
650
        } else {
651
            $nextUrl = "";
652
        }
653
        // MAINTENANCE MODE
654
        if (isset($SETTINGS['maintenance_mode']) === true && $SETTINGS['maintenance_mode'] === '1') {
655
            echo '
656
                <div style="text-align:center;margin-top:30px;margin-bottom:20px;padding:10px;"
657
                    class="ui-state-error ui-corner-all">
658
                    <b>'.addslashes($LANG['index_maintenance_mode']).'</b>
659
                </div>';
660
        } elseif (isset($_GET['session_over']) && $_GET['session_over'] === 'true') {
661
            // SESSION FINISHED => RECONNECTION ASKED
662
            echo '
663
                    <div style="text-align:center;margin-top:30px;margin-bottom:20px;padding:10px;"
664
                        class="ui-state-error ui-corner-all">
665
                        <b>'.addslashes($LANG['index_session_expired']).'</b>
666
                    </div>';
667
        }
668
669
        // case where user not logged and can't access a direct link
670
        if (empty($_GET['page']) === false) {
671
            $superGlobal->put(
672
                "initial_url",
673
                filter_var(
674
                    substr($server_request_uri, strpos($server_request_uri, "index.php?")),
675
                    FILTER_SANITIZE_URL
676
                ),
677
                "SESSION"
678
            );
679
            // REDIRECTION PAGE ERREUR
680
            echo '
681
            <script language="javascript" type="text/javascript">
682
            <!--
683
                sessionStorage.clear();
684
                window.location.href = "index.php";
685
            -->
686
            </script>';
687
            exit;
688
        } else {
689
            $superGlobal->put("initial_url", '', "SESSION");
690
        }
691
692
        // CONNECTION FORM
693
        echo '
694
                <form method="post" name="form_identify" id="form_identify" action="">
695
                    <div style="width:480px;margin:10px auto 10px auto;padding:25px;" class="ui-state-highlight ui-corner-all">
696
                        <div style="text-align:center;font-weight:bold;margin-bottom:20px;">',
697
        isset($SETTINGS['custom_logo']) && !empty($SETTINGS['custom_logo']) ? '<img src="'.(string) $SETTINGS['custom_logo'].'" alt="" style="margin-bottom:40px;" />' : '', '<br />
698
                            '.$LANG['index_get_identified'].'
699
                            <span id="ajax_loader_connexion" style="display:none;margin-left:10px;"><span class="fa fa-cog fa-spin fa-1x"></span></span>
700
                        </div>
701
                        <div id="connection_error" style="display:none;text-align:center;margin:5px; padding:3px;" class="ui-state-error ui-corner-all">&nbsp;<i class="fa fa-warning"></i>&nbsp;'.$LANG['index_bas_pw'].'</div>';
702
703
        if (isset($SETTINGS['enable_http_request_login']) === true
704
            && $SETTINGS['enable_http_request_login'] === '1'
705
            && isset($_SERVER['PHP_AUTH_USER']) === true
706
            && !(isset($SETTINGS['maintenance_mode']) === true
707
            && $SETTINGS['maintenance_mode'] === '1')
708
        ) {
709
            if (strpos($_SERVER['PHP_AUTH_USER'], '@') !== false) {
710
                $username = explode("@", $_SERVER['PHP_AUTH_USER'])[0];
711
            } elseif (strpos($_SERVER['PHP_AUTH_USER'], '\\') !== false) {
712
                $username = explode("\\", $_SERVER['PHP_AUTH_USER'])[1];
713
            } else {
714
                $username = $_SERVER['PHP_AUTH_USER'];
715
            }
716
            echo '
717
        				<div style="margin-bottom:3px;">
718
        			        <label for="login" class="form_label">', isset($SETTINGS['custom_login_text']) && !empty($SETTINGS['custom_login_text']) ? (string) $SETTINGS['custom_login_text'] : $LANG['index_login'], '</label>
719
        		            <input type="text" size="10" id="login" name="login" class="input_text text ui-widget-content ui-corner-all" value="' , $username , '" readonly />
0 ignored issues
show
Security Cross-Site Scripting introduced by
$username can contain request data and is used in output context(s) leading to a potential security vulnerability.

3 paths for user data to reach this point

  1. Path: Read tainted data from array, and $_SERVER['PHP_AUTH_USER'] is assigned to $username in index.php on line 714
  1. Read tainted data from array, and $_SERVER['PHP_AUTH_USER'] is assigned to $username
    in index.php on line 714
  2. Path: Read tainted data from array, and Data is passed through explode(), and explode('\', $_SERVER['PHP_AUTH_USER'])[1] is assigned to $username in index.php on line 712
  1. Read tainted data from array, and Data is passed through explode(), and explode('\', $_SERVER['PHP_AUTH_USER'])[1] is assigned to $username
    in index.php on line 712
  3. Path: Read tainted data from array, and Data is passed through explode(), and explode('@', $_SERVER['PHP_AUTH_USER'])[0] is assigned to $username in index.php on line 710
  1. Read tainted data from array, and Data is passed through explode(), and explode('@', $_SERVER['PHP_AUTH_USER'])[0] is assigned to $username
    in index.php on line 710

Preventing Cross-Site-Scripting Attacks

Cross-Site-Scripting allows an attacker to inject malicious code into your website - in particular Javascript code, and have that code executed with the privileges of a visiting user. This can be used to obtain data, or perform actions on behalf of that visiting user.

In order to prevent this, make sure to escape all user-provided data:

// for HTML
$sanitized = htmlentities($tainted, ENT_QUOTES);

// for URLs
$sanitized = urlencode($tainted);

General Strategies to prevent injection

In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:

if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
    throw new \InvalidArgumentException('This input is not allowed.');
}

For numeric data, we recommend to explicitly cast the data:

$sanitized = (integer) $tainted;
Loading history...
720
        		            <span id="login_check_wait" style="display:none; float:right;"><i class="fa fa-cog fa-spin fa-1x"></i></span>
721
                        </div>';
722
        } else {
723
            echo '
724
                    	    <div style="margin-bottom:3px;">
725
                    	        <label for="login" class="form_label">', isset($SETTINGS['custom_login_text']) && !empty($SETTINGS['custom_login_text']) ? (string) $SETTINGS['custom_login_text'] : $LANG['index_login'], '</label>
726
                                <input type="text" size="10" id="login" name="login" class="input_text text ui-widget-content ui-corner-all" value="', empty($post_login) === false ? $post_login : '', '" />
727
                                <span id="login_check_wait" style="display:none; float:right;"><i class="fa fa-cog fa-spin fa-1x"></i></span>
728
                           </div>';
729
        }
730
731
        // AGSES
732
        if (isset($SETTINGS['agses_authentication_enabled']) && $SETTINGS['agses_authentication_enabled'] == 1) {
733
            echo '
734
                        <div id="agses_cardid_div" style="text-align:center; display:none; padding:5px; width:454px; margin-bottom:5px;" class="ui-state-active ui-corner-all">
735
                            '.$LANG['user_profile_agses_card_id'].': &nbsp;
736
                            <input type="text" size="12" id="agses_cardid">
737
                        </div>
738
                        <div id="agses_flickercode_div" style="text-align:center; display:none;">
739
                            <canvas id="axs_canvas"></canvas>
740
                        </div>';
741
        }
742
743
        if (!(isset($SETTINGS['enable_http_request_login']) === true && $SETTINGS['enable_http_request_login'] === '1' && isset($_SERVER['PHP_AUTH_USER']) === true   && !(isset($SETTINGS['maintenance_mode']) === true && $SETTINGS['maintenance_mode'] === '1'))) {
744
            echo '
745
                        <div id="connect_pw" style="margin-bottom:3px;">
746
                            <label for="pw" class="form_label" id="user_pwd">'.$LANG['index_password'].'</label>
747
                            <input type="password" size="10" id="pw" name="pw" onkeypress="if (event.keyCode == 13) launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['google_authentication']) && $SETTINGS['google_authentication'] === "1" ? 1 : '', '\')" class="input_text text ui-widget-content ui-corner-all" value="', empty($post_pw) === false ? $post_pw : '', '" />
748
                        </div>';
749
        }
750
751
        // Personal salt key
752
        if (isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1") {
753
            echo '
754
                        <div id="connect_psk" style="margin-bottom:3px;">
755
                            <label for="personal_psk" class="form_label">'.$LANG['home_personal_saltkey'].'</label>
756
                            <input type="password" size="10" id="psk" name="psk" onkeypress="if (event.keyCode == 13) launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\')" class="input_text text ui-widget-content ui-corner-all" />
757
                        </div>
758
                        <div id="connect_psk_confirm" style="margin-bottom:3px; display:none;">
759
                            <label for="psk_confirm" class="form_label">'.$LANG['home_personal_saltkey_confirm'].'</label>
760
                            <input type="password" size="10" id="psk_confirm" name="psk_confirm" onkeypress="if (event.keyCode == 13) launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\')" class="input_text text ui-widget-content ui-corner-all" />
761
                        </div>';
762
        }
763
764
        // Google Authenticator code
765
        if (isset($SETTINGS['google_authentication']) === true && $SETTINGS['google_authentication'] === "1") {
766
            echo '
767
                        <div id="ga_code_div" style="margin-bottom:10px;">
768
                            '.$LANG['ga_identification_code'].'
769
                            <input type="text" size="4" id="ga_code" name="ga_code" style="margin:0px;" class="input_text text ui-widget-content ui-corner-all numeric_only" onkeypress="if (event.keyCode == 13) launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\')" />
770
                        <div id="2fa_new_code_div" style="text-align:center; display:none; margin-top:5px; padding:5px;" class="ui-state-default ui-corner-all"></div>
771
                        <div style="margin-top:2px; font-size:10px; text-align:center; cursor:pointer;" onclick="send_user_new_temporary_ga_code()">'.$LANG['i_need_to_generate_new_ga_code'].'</div>
772
                        </div>';
773
        }
774
775
        echo '
776
                        <div style="margin-bottom:3px;">
777
                            <label for="duree_session" class="">'.$LANG['index_session_duration'].'&nbsp;('.$LANG['minutes'].') </label>
778
                            <input type="text" size="4" id="duree_session" name="duree_session" value="', isset($SETTINGS['default_session_expiration_time']) ? $SETTINGS['default_session_expiration_time'] : "60", '" onkeypress="if (event.keyCode == 13) launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\')" class="input_text text ui-widget-content ui-corner-all numeric_only" />
779
                        </div>';
780
781
        // Google Authenticator code
782
        if (isset($SETTINGS['disable_show_forgot_pwd_link']) === true && $SETTINGS['google_authentication'] !== "1") {
783
            echo '
784
                        <div style="text-align:center;margin-top:5px;font-size:10pt;">
785
                            <span onclick="OpenDialog(\'div_forgot_pw\')" style="padding:3px;cursor:pointer;">'.$LANG['forgot_my_pw'].'</span>
786
                        </div>';
787
        }
788
789
        if (isset($SETTINGS['enable_http_request_login']) === true
790
            && $SETTINGS['enable_http_request_login'] === '1'
791
            && isset($_SERVER['PHP_AUTH_USER']) === true
792
            && (isset($SETTINGS['maintenance_mode']) === false
793
            && $SETTINGS['maintenance_mode'] === '1')
794
        ) {
795
            echo '
796
<script>
797
var seconds = 1;
798
function updateLogonButton(timeToGo){
799
    document.getElementById("but_identify_user").value = "' . $LANG['duration_login_attempt'] . ' " + timeToGo;
800
}
801
$( window ).on( "load", function() {
802
    updateLogonButton(seconds);
803
    setInterval(function() {
804
        seconds--;
805
        if (seconds >= 0) {
806
            updateLogonButton(seconds);
807
        } else if(seconds === 0) {
808
            launchIdentify(\'', isset($SETTINGS['duo']) == true && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\');
809
        }
810
        updateLogonButton(seconds);
811
    },
812
    1000
813
  );
814
});
815
</script>';
816
        }
817
818
        // Yubico authentication
819
        if (isset($SETTINGS['yubico_authentication']) === true && $SETTINGS['yubico_authentication'] === "1") {
820
            echo '
821
                        <div id="yubico_div" style="margin-top:5px; padding:5px; overflow: auto; width:95%;" class="ui-state-default ui-corner-all">
822
                            <div style="width: 18%; float:left; display:block;">
823
                                <img src="includes/images/yubico.png">
824
                            </div>
825
                            
826
                            <div style="width: 82%; float:right; display:block;">
827
                                <div id="yubico_credentials_div" class="hidden">
828
                                    <h4>'.addslashes($LANG['provide_yubico_identifiers']).'</h4>
829
                                    <label for="yubico_user_id">'.$LANG['yubico_user_id'].'</label>
830
                                    <input type="text" size="10" id="yubico_user_id" class="input_text text ui-widget-content ui-corner-all" />
831
832
                                    <label for="yubico_user_key">'.$LANG['yubico_user_key'].'</label>
833
                                    <input type="text" size="10" id="yubico_user_key" class="input_text text ui-widget-content ui-corner-all" />
834
                                </div>
835
                                <input autocomplete="off" type="text" name="yubiko_key" id="yubiko_key" class="input_text text ui-widget-content ui-corner-all" placeholder="'.addslashes($LANG['press_your_yubico_key']).'" style="margin-top:20px;" onchange="launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\')">
836
                                <div id="show_yubico_credentials" class="hidden"><a href="#" id="yubico_link">'.addslashes($LANG['show_yubico_info_form']).'</a></div>
837
                            </div>
838
                        </div>';
839
        } else {
840
            echo '
841
                        <div style="text-align:center;margin-top:15px;">
842
                            <input type="button" id="but_identify_user" onclick="launchIdentify(\'', isset($SETTINGS['duo']) && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\')" style="padding:3px;cursor:pointer;" class="ui-state-default ui-corner-all" value="'.$LANG['index_identify_button'].'" />
843
                        </div>';
844
        }
845
846
        echo '
847
                    </div>
848
                </form>
849
                <script type="text/javascript">
850
                    $("#login").focus();
851
                </script>';
852
        // DIV for forgotten password
853
        echo '
854
                <div id="div_forgot_pw" style="display:none;">
855
                    <div style="margin:5px auto 5px auto;" id="div_forgot_pw_alert"></div>
856
                    <div style="margin:5px auto 5px auto;">'.$LANG['forgot_my_pw_text'].'</div>
857
                    <label for="forgot_pw_email">'.$LANG['email'].'</label>
858
                    <input type="text" size="40" name="forgot_pw_email" id="forgot_pw_email" />
859
                    <br />
860
                    <label for="forgot_pw_login">'.$LANG['login'].'</label>
861
                    <input type="text" size="20" name="forgot_pw_login" id="forgot_pw_login" />
862
                    <div id="div_forgot_pw_status" style="text-align:center;margin-top:15px;display:none; padding:5px;" class="ui-corner-all">
863
                        <i class="fa fa-cog fa-spin fa-2x"></i>&nbsp;<b>'.$LANG['please_wait'].'</b>
864
                    </div>
865
                </div>';
866
    }
867
    echo '
868
    </div>';
869
// FOOTER
870
/* DON'T MODIFY THE FOOTER ... MANY THANKS TO YOU */
871
    echo '
872
    <div id="footer">
873
        <div style="float:left;width:32%;">
874
            <a href="https://teampass.net" target="_blank" style="color:#F0F0F0;">'.$SETTINGS_EXT['tool_name'].'&nbsp;'.$SETTINGS_EXT['version_full'].'&nbsp;<i class="fa fa-copyright"></i>&nbsp;'.$SETTINGS_EXT['copyright'].'</a>
875
            &nbsp;|&nbsp;
876
            <a href="https://teampass.readthedocs.io/en/latest/" target="_blank" style="color:#F0F0F0;" class="tip" title="'.addslashes($LANG['documentation_canal']).' ReadTheDocs"><i class="fa fa-book"></i></a>
877
            &nbsp;
878
            <a href="https://www.reddit.com/r/TeamPass/" target="_blank" style="color:#F0F0F0;" class="tip" title="'.addslashes($LANG['admin_help']).'"><i class="fa fa-reddit-alien"></i></a>
879
            &nbsp;
880
            ', ($session_user_id !== null && empty($session_user_id) === false) ? '
881
            <a href="#" style="color:#F0F0F0;" class="tip" title="'.addslashes($LANG['bugs_page']).'" onclick="generateBugReport()"><i class="fa fa-bug"></i></a>' : '' ,'
882
        </div>
883
        <div style="float:left;width:32%;text-align:center;">
884
            ', ($session_user_id !== null && empty($session_user_id) === false) ? '<i class="fa fa-users"></i>&nbsp;'.$session_nb_users_online.'&nbsp;'.$LANG['users_online'].'&nbsp;|&nbsp;<i class="fa fa-hourglass-end"></i>&nbsp;'.$LANG['index_expiration_in'].'&nbsp;<div style="display:inline;" id="countdown"></div>' : '', '
885
        </div><div id="countdown2"></div>
886
        <div style="float:right;text-align:right;">
887
            <i class="fa fa-clock-o"></i>&nbsp;'. $LANG['server_time']." : ".@date($SETTINGS['date_format'], (string) $_SERVER['REQUEST_TIME'])." - ".@date($SETTINGS['time_format'], (string) $_SERVER['REQUEST_TIME']).'
888
        </div>
889
    </div>';
890
// PAGE LOADING
891
    echo '
892
    <div id="div_loading" class="hidden">
893
        <div style="padding:5px; z-index:9999999;" class="ui-widget-content ui-state-focus ui-corner-all">
894
            <i class="fa fa-cog fa-spin fa-2x"></i>
895
        </div>
896
    </div>';
897
// Alert BOX
898
    echo '
899
    <div id="div_dialog_message" style="display:none;">
900
        <div id="div_dialog_message_text" style="text-align:center; padding:4px; font-size:12px; margin-top:10px;"></div>
901
    </div>';
902
903
// WARNING FOR QUERY ERROR
904
    echo '
905
    <div id="div_mysql_error" style="display:none;">
906
        <div style="padding:10px;text-align:center;" id="mysql_error_warning"></div>
907
    </div>';
908
909
910
//Personnal SALTKEY
911
    if (isset($SETTINGS['enable_pf_feature']) && $SETTINGS['enable_pf_feature'] === "1") {
912
        echo '
913
        <div id="div_set_personal_saltkey" style="display:none;padding:4px;">
914
            <div style="text-align:center;margin:5px;padding:3px;" id="expected_psk_complexPw" class="ui-widget ui-state-active ui-corner-all hidden">', isset($SETTINGS['personal_saltkey_security_level']) === true && empty($SETTINGS['personal_saltkey_security_level']) === false ? $LANG['complex_asked']." : ".$SETTINGS_EXT['pwComplexity'][$SETTINGS['personal_saltkey_security_level']][1] : '', '</div>
915
            <table border="0">
916
                <tr>
917
                    <td>
918
                        <i class="fa fa-key"></i> <b>'.$LANG['home_personal_saltkey'].'</b>
919
                    </td>
920
                    <td>
921
                        <input type="password" name="input_personal_saltkey" id="input_personal_saltkey" style="width:200px;padding:5px;margin-left:10px;" class="text ui-widget-content ui-corner-all text_without_symbols tip" value="', isset($_SESSION['user_settings']['clear_psk']) ? (string) $_SESSION['user_settings']['clear_psk'] : '', '" title="<i class=\'fa fa-bullhorn\'></i>&nbsp;'.$LANG['text_without_symbols'].'" />
922
                        <span id="set_personal_saltkey_last_letter" style="font-weight:bold;font-size:20px;"></span>
923
                    </td>
924
                </tr>
925
                <tr>
926
                    <td></td>
927
                    <td>
928
                        <div id="psk_strength" style="margin:3px 0 0 10px;"></div>
929
                        <input type="hidden" id="psk_strength_value" />
930
                    </td>
931
                </tr>
932
            </table>
933
            <div style="display:none;margin-top:5px;text-align:center;padding:4px;" id="set_personal_saltkey_warning" class="ui-widget-content ui-corner-all"></div>
934
        </div>';
935
    }
936
937
// user profile
938
    echo '
939
<div id="dialog_user_profil" style="display:none;padding:4px;">
940
    <div id="div_user_profil">
941
        <i class="fa fa-cog fa-spin fa-2x"></i>&nbsp;<b>'.$LANG['please_wait'].'</b>
942
    </div>
943
    <input type="hidden" id="force_show_dialog" value="',
944
        isset($_SESSION['unsuccessfull_login_attempts']) === true
945
        && $_SESSION['unsuccessfull_login_attempts']['nb'] !== 0
946
        && $_SESSION['unsuccessfull_login_attempts']['shown'] === false ?
947
        '1' : '0', '" />
948
</div>';
949
950
// DUO box
951
    echo '
952
<div id="dialog_duo" style="display:none;padding:4px;">
953
    <div id="div_duo"></div>
954
    '.$LANG['duo_loading_iframe'].'
955
    <form method="post" id="duo_form" action="">
956
        <input type="hidden" id="duo_login" name="duo_login" value="', null !== $post_duo_login ? $post_duo_login : '', '" />
957
        <input type="hidden" id="duo_pwd" name="duo_pwd" value="', null !== $post_duo_pwd ? $post_duo_pwd : '', '" />
958
        <input type="hidden" id="duo_data" name="duo_data" value="', null !== $post_duo_data ? htmlentities(base64_decode($post_duo_data)) : '', '" />
959
    </form>
960
</div>';
961
962
// INCREASE session time
963
    echo '
964
<div id="div_increase_session_time" style="display:none;padding:4px;">
965
    <b>'.$LANG['index_session_duration'].':</b>
966
    <input type="text" id="input_session_duration" style="width:50px;padding:5px;margin:0 10px 0 10px;" class="text ui-widget-content ui-corner-all" value="', isset($_SESSION['user_settings']['session_duration']) ? (int) $_SESSION['user_settings']['session_duration'] / 60 : 60, '" />
967
    <b>'.$LANG['minutes'].'</b>
968
    <div style="display:none;margin-top:5px;text-align:center;padding:4px;" id="input_session_duration_warning" class="ui-widget-content ui-state-error ui-corner-all"></div>
969
</div>';
970
971
    closelog();
972
973
?>
974
<script type="text/javascript">NProgress.start();</script>
975
    </body>
976
</html>
977