nilsteampassnet /
TeamPass
| 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'].' <b>'.$session_name.' '.$session_lastname |
||
| 246 | .' ['.$session_login.']</b> - ' |
||
| 247 | , $session_user_admin === '1' ? $LANG['god'] : |
||
| 248 | ($session_user_manager === '1' ? $LANG['gestionnaire'] : |
||
| 249 | ($session_user_read_only === '1' ? $LANG['read_only_account'] : |
||
| 250 | ($session_user_human_resources === '1' ? $LANG['human_resources'] :$LANG['user']) |
||
| 251 | ) |
||
| 252 | ), ' '.strtolower($LANG['index_login']).'</div>'; |
||
| 253 | |||
| 254 | echo ' |
||
| 255 | <div id="menu_top"> |
||
| 256 | <div style="margin-left:20px; margin-top:2px;width:710px;" id="main_menu">'; |
||
| 257 | if ($session_user_admin === '0' || $SETTINGS_EXT['admin_full_right'] == 0) { |
||
| 258 | echo ' |
||
| 259 | <a class="btn btn-default" href="#"', |
||
| 260 | ($session_nb_folders !== null && intval($session_nb_folders) === 0) |
||
| 261 | || ($session_nb_roles !== null && intval($session_nb_roles) === 0) ? '' : ' onclick="MenuAction(\'items\')"', |
||
| 262 | '> |
||
| 263 | <i class="fa fa-key fa-2x tip" title="'.$LANG['pw'].'"></i> |
||
| 264 | </a> |
||
| 265 | |||
| 266 | <a class="btn btn-default" href="#"', |
||
| 267 | ($session_nb_folders !== null && intval($session_nb_folders) === 0) |
||
| 268 | || ($session_nb_roles !== null && intval($session_nb_roles) === 0) ? '' : ' onclick="MenuAction(\'find\')"', |
||
| 269 | '> |
||
| 270 | <i class="fa fa-binoculars fa-2x tip" title="'.$LANG['find'].'"></i> |
||
| 271 | </a>'; |
||
| 272 | } |
||
| 273 | |||
| 274 | // Favourites menu |
||
| 275 | if (isset($SETTINGS['enable_favourites']) |
||
| 276 | && $SETTINGS['enable_favourites'] == 1 |
||
| 277 | && |
||
| 278 | ($session_user_admin === '0' || ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false)) |
||
| 279 | ) { |
||
| 280 | echo ' |
||
| 281 | <a class="btn btn-default" href="#" onclick="MenuAction(\'favourites\')"> |
||
| 282 | <i class="fa fa-star fa-2x tip" title="'.$LANG['my_favourites'].'"></i> |
||
| 283 | </a>'; |
||
| 284 | } |
||
| 285 | // KB menu |
||
| 286 | if (isset($SETTINGS['enable_kb']) && $SETTINGS['enable_kb'] == 1) { |
||
| 287 | echo ' |
||
| 288 | <a class="btn btn-default" href="#" onclick="MenuAction(\'kb\')"> |
||
| 289 | <i class="fa fa-map-signs fa-2x tip" title="'.$LANG['kb_menu'].'"></i> |
||
| 290 | </a>'; |
||
| 291 | } |
||
| 292 | echo ' |
||
| 293 | <span id="menu_suggestion_position">'; |
||
| 294 | // SUGGESTION menu |
||
| 295 | if (isset($SETTINGS['enable_suggestion']) && $SETTINGS['enable_suggestion'] === '1' |
||
| 296 | && ($session_user_read_only === '1' || $session_user_admin === '1' || $session_user_manager === '1') |
||
| 297 | ) { |
||
| 298 | echo ' |
||
| 299 | <a class="btn btn-default" href="#" onclick="MenuAction(\'suggestion\')"> |
||
| 300 | <i class="fa fa-lightbulb-o fa-2x tip" id="menu_icon_suggestions" title="'.$LANG['suggestion_menu'].'"></i> |
||
| 301 | </a>'; |
||
| 302 | } |
||
| 303 | echo ' |
||
| 304 | </span>'; |
||
| 305 | // Admin menu |
||
| 306 | if ($session_user_admin === '1') { |
||
| 307 | echo ' |
||
| 308 | |
||
| 309 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_main\')"> |
||
| 310 | <i class="fa fa-info fa-2x tip" title="'.$LANG['admin_main'].'"></i> |
||
| 311 | </a> |
||
| 312 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_settings\')"> |
||
| 313 | <i class="fa fa-wrench fa-2x tip" title="'.$LANG['admin_settings'].'"></i> |
||
| 314 | </a>'; |
||
| 315 | } |
||
| 316 | |||
| 317 | if ($session_user_admin === '1' || $session_user_manager === '1' || $session_user_human_resources === '1') { |
||
| 318 | echo ' |
||
| 319 | |
||
| 320 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_folders\')"> |
||
| 321 | <i class="fa fa-folder-open fa-2x tip" title="'.$LANG['admin_groups'].'"></i> |
||
| 322 | </a> |
||
| 323 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_roles\')"> |
||
| 324 | <i class="fa fa-graduation-cap fa-2x tip" title="'.$LANG['admin_functions'].'"></i> |
||
| 325 | </a> |
||
| 326 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_users\')"> |
||
| 327 | <i class="fa fa-users fa-2x tip" title="'.$LANG['admin_users'].'"></i> |
||
| 328 | </a> |
||
| 329 | <a class="btn btn-default" href="#" onclick="MenuAction(\'manage_views\')"> |
||
| 330 | <i class="fa fa-cubes fa-2x tip" title="'.$LANG['admin_views'].'"></i> |
||
| 331 | </a>'; |
||
| 332 | } |
||
| 333 | |||
| 334 | echo ' |
||
| 335 | <div style="float:right;"> |
||
| 336 | <ul class="menu" style=""> |
||
| 337 | <li class="" style="padding:4px;width:40px; text-align:center;"><i class="fa fa-dashboard fa-fw"></i> |
||
| 338 | <ul class="menu_200" style="text-align:left;">', |
||
| 339 | ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === true) ? '' : isset($SETTINGS['enable_pf_feature']) === true && $SETTINGS['enable_pf_feature'] == 1 ? ' |
||
| 340 | <li onclick="$(\'#div_set_personal_saltkey\').dialog(\'open\')"> |
||
| 341 | <i class="fa fa-key fa-fw"></i> '.$LANG['home_personal_saltkey_button'].' |
||
| 342 | </li>' : '', ' |
||
| 343 | <li onclick="$(\'#div_increase_session_time\').dialog(\'open\')"> |
||
| 344 | <i class="fa fa-clock-o fa-fw"></i> '.$LANG['index_add_one_hour'].' |
||
| 345 | </li> |
||
| 346 | <li onclick="loadProfileDialog()"> |
||
| 347 | <i class="fa fa-user fa-fw"></i> '.$LANG['my_profile'].' |
||
| 348 | </li> |
||
| 349 | <li onclick="MenuAction(\'deconnexion\', \''.$session_user_id.'\')"> |
||
| 350 | <i class="fa fa-sign-out fa-fw"></i> '.$LANG['disconnect'].' |
||
| 351 | </li> |
||
| 352 | </ul> |
||
| 353 | </li> |
||
| 354 | </ul> |
||
| 355 | </div>'; |
||
| 356 | |||
| 357 | if ($session_user_admin !== '1' || ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false)) { |
||
| 358 | echo ' |
||
| 359 | <div style="float:right; margin-right:10px;"> |
||
| 360 | <ul class="menu" id="menu_last_seen_items"> |
||
| 361 | <li class="" style="padding:4px;width:40px; text-align:center;"><i class="fa fa-map fa-fw"></i> |
||
| 362 | <ul class="menu_200" id="last_seen_items_list" style="text-align:left;"> |
||
| 363 | <li>'.$LANG['please_wait'].'</li> |
||
| 364 | </ul> |
||
| 365 | </li> |
||
| 366 | </ul> |
||
| 367 | </div>'; |
||
| 368 | } |
||
| 369 | |||
| 370 | // show avatar |
||
| 371 | if ($session_user_avatar_thumb !== null && empty($session_user_avatar_thumb) === false) { |
||
| 372 | if (file_exists('includes/avatars/'.$session_user_avatar_thumb)) { |
||
| 373 | $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$session_user_avatar_thumb; |
||
| 374 | } else { |
||
| 375 | $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg'; |
||
| 376 | } |
||
| 377 | } else { |
||
| 378 | $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg'; |
||
| 379 | } |
||
| 380 | echo ' |
||
| 381 | <div style="float:right; margin-right:10px;"> |
||
| 382 | <img src="'.$avatar.'" style="border-radius:10px; height:28px; cursor:pointer;" onclick="loadProfileDialog()" alt="photo" id="user_avatar_thumb" /> |
||
| 383 | </div>'; |
||
| 384 | |||
| 385 | echo ' |
||
| 386 | </div>'; |
||
| 387 | |||
| 388 | echo ' |
||
| 389 | </div>'; |
||
| 390 | } |
||
| 391 | |||
| 392 | echo ' |
||
| 393 | </div>'; |
||
| 394 | |||
| 395 | echo ' |
||
| 396 | <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"> |
||
| 397 | <span class="closeButton" onclick="$(\'#main_info_box\').hide()">✖</span> |
||
| 398 | <div id="main_info_box_text" style="text-align:center;margin-top:10px;"></div> |
||
| 399 | </div>'; |
||
| 400 | |||
| 401 | /* MAIN PAGE */ |
||
| 402 | echo ' |
||
| 403 | <input type="hidden" id="temps_restant" value="', isset($_SESSION['fin_session']) ? $_SESSION['fin_session'] : '', '" /> |
||
| 404 | <input type="hidden" name="language" id="language" value="" /> |
||
| 405 | <input type="hidden" name="user_pw_complexity" id="user_pw_complexity" value="', isset($_SESSION['user_pw_complexity']) ? $_SESSION['user_pw_complexity'] : '', '" /> |
||
| 406 | <input type="hidden" name="user_session" id="user_session" value=""/> |
||
| 407 | <input type="hidden" name="encryptClientServer" id="encryptClientServer" value="', isset($SETTINGS['encryptClientServer']) ? $SETTINGS['encryptClientServer'] : '1', '" /> |
||
| 408 | <input type="hidden" name="please_login" id="please_login" value="" /> |
||
| 409 | <input type="hidden" name="disabled_action_on_going" id="disabled_action_on_going" value="" /> |
||
| 410 | <input type="hidden" id="duo_sig_response" value="', null !== $post_sig_response ? $post_sig_response : '', '" />'; |
||
| 411 | |||
| 412 | // SENDING STATISTICS? |
||
| 413 | if (isset($SETTINGS['send_stats']) && $SETTINGS['send_stats'] === "1" |
||
| 414 | && (!isset($_SESSION['temporary']['send_stats_done']) || $_SESSION['temporary']['send_stats_done'] !== "1") |
||
| 415 | ) { |
||
| 416 | echo ' |
||
| 417 | <input type="hidden" name="send_statistics" id="send_statistics" value="1" />'; |
||
| 418 | } else { |
||
| 419 | echo ' |
||
| 420 | <input type="hidden" name="send_statistics" id="send_statistics" value="0" />'; |
||
| 421 | } |
||
| 422 | |||
| 423 | echo ' |
||
| 424 | <div id="', (isset($_GET['page']) && filter_var($_GET['page'], FILTER_SANITIZE_STRING) === "items" && $session_user_id !== null) ? "main_simple" : "main", '">'; |
||
| 425 | // MESSAGE BOX |
||
| 426 | echo ' |
||
| 427 | <div style="" class="div_center"> |
||
| 428 | <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> |
||
| 429 | </div>'; |
||
| 430 | // Main page |
||
| 431 | if ($session_autoriser !== null && $session_autoriser === true) { |
||
| 432 | // Show menu |
||
| 433 | echo ' |
||
| 434 | <form method="post" name="main_form" action=""> |
||
| 435 | <input type="hidden" name="menu_action" id="menu_action" value="" /> |
||
| 436 | <input type="hidden" name="changer_pw" id="changer_pw" value="" /> |
||
| 437 | <input type="hidden" name="form_user_id" id="form_user_id" value="', $session_user_id !== null ? $session_user_id : '', '" /> |
||
| 438 | <input type="hidden" name="is_admin" id="is_admin" value="', $session_is_admin !== null ? $session_is_admin : '', '" /> |
||
| 439 | <input type="hidden" name="personal_saltkey_set" id="personal_saltkey_set" value="', isset($_SESSION['user_settings']['clear_psk']) ? true : false, '" /> |
||
| 440 | </form>'; |
||
| 441 | } |
||
| 442 | // --------- |
||
| 443 | // Display a help to admin |
||
| 444 | $errorAdmin = ""; |
||
| 445 | |||
| 446 | // error nb folders |
||
| 447 | if ($session_nb_folders !== null && intval($session_nb_folders) === 0) { |
||
| 448 | $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_no_folders'].'<br />'; |
||
| 449 | } |
||
| 450 | // error nb roles |
||
| 451 | if ($session_nb_roles !== null && intval($session_nb_roles) === 0) { |
||
| 452 | if (empty($errorAdmin)) { |
||
| 453 | $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_no_roles']; |
||
| 454 | } else { |
||
| 455 | $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_no_roles']; |
||
| 456 | } |
||
| 457 | } |
||
| 458 | |||
| 459 | if ($session_validite_pw !== null && empty($session_validite_pw) === false) { |
||
| 460 | // error cpassman dir |
||
| 461 | if (isset($SETTINGS['cpassman_dir']) && empty($SETTINGS['cpassman_dir']) || !isset($SETTINGS['cpassman_dir'])) { |
||
| 462 | if (empty($errorAdmin)) { |
||
| 463 | $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_cpassman_dir']; |
||
| 464 | } else { |
||
| 465 | $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_cpassman_dir']; |
||
| 466 | } |
||
| 467 | } |
||
| 468 | // error cpassman url |
||
| 469 | if ($session_validite_pw !== null && (isset($SETTINGS['cpassman_url']) && empty($SETTINGS['cpassman_url']) || !isset($SETTINGS['cpassman_url']))) { |
||
| 470 | if (empty($errorAdmin)) { |
||
| 471 | $errorAdmin = '<span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_cpassman_url']; |
||
| 472 | } else { |
||
| 473 | $errorAdmin .= '<br /><span class="ui-icon ui-icon-lightbulb" style="float: left; margin-right: .3em;"> </span>'.$LANG['error_cpassman_url']; |
||
| 474 | } |
||
| 475 | } |
||
| 476 | } |
||
| 477 | // Display help |
||
| 478 | if (!empty($errorAdmin)) { |
||
| 479 | echo ' |
||
| 480 | <div style="margin:10px;padding:10px;" class="ui-state-error ui-corner-all"> |
||
| 481 | '.$errorAdmin.' |
||
| 482 | </div>'; |
||
| 483 | } |
||
| 484 | // ----------- |
||
| 485 | // Display Maintenance mode information |
||
| 486 | if (isset($SETTINGS['maintenance_mode']) === true && $SETTINGS['maintenance_mode'] === '1' |
||
| 487 | && $session_user_admin !== null && $session_user_admin === '1' |
||
| 488 | ) { |
||
| 489 | echo ' |
||
| 490 | <div style="text-align:center;margin-bottom:5px;padding:10px;" class="ui-state-highlight ui-corner-all"> |
||
| 491 | <b>'.$LANG['index_maintenance_mode_admin'].'</b> |
||
| 492 | </div>'; |
||
| 493 | } |
||
| 494 | // Display UPDATE NEEDED information |
||
| 495 | if (isset($SETTINGS['update_needed']) && $SETTINGS['update_needed'] === true |
||
| 496 | && $session_user_admin !== null && $session_user_admin === '1' |
||
| 497 | && (($session_hide_maintenance !== null && $session_hide_maintenance === '0') |
||
| 498 | || $session_hide_maintenance === null) |
||
| 499 | ) { |
||
| 500 | echo ' |
||
| 501 | <div style="text-align:center;margin-bottom:5px;padding:10px;" |
||
| 502 | class="ui-state-highlight ui-corner-all" id="div_maintenance"> |
||
| 503 | <b>'.$LANG['update_needed_mode_admin'].'</b> |
||
| 504 | <span style="float:right;cursor:pointer;"> |
||
| 505 | <span class="fa fa-close mi-red" onclick="toggleDiv(\'div_maintenance\')"></span> |
||
| 506 | </span> |
||
| 507 | </div>'; |
||
| 508 | } |
||
| 509 | |||
| 510 | // display an item in the context of OTV link |
||
| 511 | if (($session_validite_pw === null || empty($session_validite_pw) === true || empty($session_user_id) === true) && |
||
| 512 | isset($_GET['otv']) && filter_var($_GET['otv'], FILTER_SANITIZE_STRING) === 'true' |
||
| 513 | ) { |
||
| 514 | // case where one-shot viewer |
||
| 515 | if (isset($_GET['code']) && !empty($_GET['code']) |
||
| 516 | && isset($_GET['stamp']) && !empty($_GET['stamp']) |
||
| 517 | ) { |
||
| 518 | include 'otv.php'; |
||
| 519 | } else { |
||
| 520 | $_SESSION['error']['code'] = ERR_VALID_SESSION; |
||
| 521 | $superGlobal->put( |
||
| 522 | "initial_url", |
||
| 523 | filter_var( |
||
| 524 | substr($server_request_uri, strpos($server_request_uri, "index.php?")), |
||
| 525 | FILTER_SANITIZE_URL |
||
| 526 | ), |
||
| 527 | "SESSION" |
||
| 528 | ); |
||
| 529 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 530 | } |
||
| 531 | // Ask the user to change his password |
||
| 532 | } elseif (($session_validite_pw === null || $session_validite_pw === false) |
||
| 533 | && empty($session_user_id) === false |
||
| 534 | ) { |
||
| 535 | //Check if password is valid |
||
| 536 | echo ' |
||
| 537 | <div style="margin:auto; padding:20px; width:500px;" class="ui-state-focus ui-corner-all"> |
||
| 538 | <h3>'.$LANG['index_change_pw'].'</h3> |
||
| 539 | <div style="height:20px;text-align:center;margin:2px;display:none;" id="change_pwd_error" class=""></div> |
||
| 540 | <div style="text-align:center;margin:5px;padding:3px;" id="change_pwd_complexPw" class="ui-widget ui-state-active ui-corner-all">'. |
||
| 541 | $LANG['complex_asked'].' : '.$SETTINGS_EXT['pwComplexity'][$_SESSION['user_pw_complexity']][1]. |
||
| 542 | '</div> |
||
| 543 | <div id="pw_strength" style="margin:0 0 10px 140px;"></div> |
||
| 544 | <table> |
||
| 545 | <tr> |
||
| 546 | <td>'.$LANG['index_new_pw'].' :</td><td><input type="password" size="15" name="new_pw" id="new_pw"/></td> |
||
| 547 | </tr> |
||
| 548 | <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> |
||
| 549 | </table> |
||
| 550 | <input type="hidden" id="pw_strength_value" /> |
||
| 551 | <div style="width:420px; text-align:center; margin:15px 0 10px 0;"> |
||
| 552 | <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'].'" /> |
||
| 553 | </div> |
||
| 554 | </div> |
||
| 555 | <script type="text/javascript"> |
||
| 556 | $("#new_pw").focus(); |
||
| 557 | </script>'; |
||
| 558 | // Display pages |
||
| 559 | } elseif ($session_validite_pw !== null |
||
| 560 | && $session_validite_pw === true |
||
| 561 | && empty($_GET['page']) === false |
||
| 562 | && empty($session_user_id) === false |
||
| 563 | ) { |
||
| 564 | if ($session_initial_url !== null && empty($session_initial_url) === false) { |
||
| 565 | include $session_initial_url; |
||
| 566 | } elseif ($_GET['page'] == "items") { |
||
| 567 | // SHow page with Items |
||
| 568 | if (($session_user_admin !== '1') |
||
| 569 | || |
||
| 570 | ($session_user_admin === '1' && $SETTINGS_EXT['admin_full_right'] === false) |
||
| 571 | ) { |
||
| 572 | include 'items.php'; |
||
| 573 | } else { |
||
| 574 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 575 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 576 | } |
||
| 577 | } elseif ($_GET['page'] == "find") { |
||
| 578 | // Show page for items findind |
||
| 579 | include 'find.php'; |
||
| 580 | } elseif ($_GET['page'] == "favourites") { |
||
| 581 | // Show page for user favourites |
||
| 582 | include 'favorites.php'; |
||
| 583 | } elseif ($_GET['page'] == "kb") { |
||
| 584 | // Show page KB |
||
| 585 | if (isset($SETTINGS['enable_kb']) && $SETTINGS['enable_kb'] == 1) { |
||
| 586 | include 'kb.php'; |
||
| 587 | } else { |
||
| 588 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 589 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 590 | } |
||
| 591 | } elseif ($_GET['page'] == "suggestion") { |
||
| 592 | // Show page KB |
||
| 593 | if (isset($SETTINGS['enable_suggestion']) && $SETTINGS['enable_suggestion'] == 1) { |
||
| 594 | include 'suggestion.php'; |
||
| 595 | } else { |
||
| 596 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 597 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 598 | } |
||
| 599 | } elseif (in_array($_GET['page'], array_keys($mngPages))) { |
||
| 600 | // Define if user is allowed to see management pages |
||
| 601 | if ($session_user_admin === '1') { |
||
| 602 | include($mngPages[$_GET['page']]); |
||
| 603 | } elseif ($session_user_manager === '1' || $session_user_human_resources == '1') { |
||
| 604 | if (($_GET['page'] != "manage_main" && $_GET['page'] != "manage_settings")) { |
||
| 605 | include($mngPages[$_GET['page']]); |
||
| 606 | } else { |
||
| 607 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 608 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 609 | } |
||
| 610 | } else { |
||
| 611 | $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page |
||
| 612 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 613 | } |
||
| 614 | } else { |
||
| 615 | $_SESSION['error']['code'] = ERR_NOT_EXIST; //page doesn't exist |
||
| 616 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 617 | } |
||
| 618 | // Case of password recovery |
||
| 619 | } elseif (isset($_GET['action']) && $_GET['action'] === "password_recovery") { |
||
| 620 | // Case where user has asked new PW |
||
| 621 | echo ' |
||
| 622 | <div style="width:400px;margin:50px auto 50px auto;padding:25px;" class="ui-state-highlight ui-corner-all"> |
||
| 623 | <div style="text-align:center;font-weight:bold;margin-bottom:20px;"> |
||
| 624 | '.$LANG['pw_recovery_asked'].' |
||
| 625 | </div> |
||
| 626 | <div id="generate_new_pw_error" style="color:red;display:none;text-align:center;margin:5px;"></div> |
||
| 627 | <div style="margin-bottom:3px;"> |
||
| 628 | '.$LANG['pw_recovery_info'].' |
||
| 629 | </div> |
||
| 630 | <div style="margin:15px; text-align:center;"> |
||
| 631 | <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'].'" /> |
||
| 632 | <br /><br /> |
||
| 633 | <div id="ajax_loader_send_mail" style="display:none; margin: 20px;"><span class="fa fa-cog fa-spin fa-2x"></span></div> |
||
| 634 | </div> |
||
| 635 | <div style="margin-top:30px; text-align:center;"> |
||
| 636 | <a href="index.php" class="tip" title="'.$LANG['home'].'"><span class="fa fa-home fa-lg"></span></a> |
||
| 637 | </div> |
||
| 638 | </div>'; |
||
| 639 | } elseif (empty($session_user_id) === false && $session_user_id !== null) { |
||
| 640 | // Page doesn't exist |
||
| 641 | $_SESSION['error']['code'] = ERR_NOT_EXIST; |
||
| 642 | include $SETTINGS['cpassman_dir'].'/error.php'; |
||
| 643 | // When user is not identified |
||
| 644 | } else { |
||
| 645 | // Automatic redirection |
||
| 646 | if (strpos($server_request_uri, "?") > 0) { |
||
| 647 | $nextUrl = filter_var(substr($server_request_uri, strpos($server_request_uri, "?")), FILTER_SANITIZE_URL); |
||
| 648 | } else { |
||
| 649 | $nextUrl = ""; |
||
| 650 | } |
||
| 651 | // MAINTENANCE MODE |
||
| 652 | if (isset($SETTINGS['maintenance_mode']) === true && $SETTINGS['maintenance_mode'] === '1') { |
||
| 653 | echo ' |
||
| 654 | <div style="text-align:center;margin-top:30px;margin-bottom:20px;padding:10px;" |
||
| 655 | class="ui-state-error ui-corner-all"> |
||
| 656 | <b>'.addslashes($LANG['index_maintenance_mode']).'</b> |
||
| 657 | </div>'; |
||
| 658 | } elseif (isset($_GET['session_over']) && $_GET['session_over'] === 'true') { |
||
| 659 | // SESSION FINISHED => RECONNECTION ASKED |
||
| 660 | echo ' |
||
| 661 | <div style="text-align:center;margin-top:30px;margin-bottom:20px;padding:10px;" |
||
| 662 | class="ui-state-error ui-corner-all"> |
||
| 663 | <b>'.addslashes($LANG['index_session_expired']).'</b> |
||
| 664 | </div>'; |
||
| 665 | } |
||
| 666 | |||
| 667 | // case where user not logged and can't access a direct link |
||
| 668 | if (empty($_GET['page']) === false) { |
||
| 669 | $superGlobal->put( |
||
| 670 | "initial_url", |
||
| 671 | filter_var( |
||
| 672 | substr($server_request_uri, strpos($server_request_uri, "index.php?")), |
||
| 673 | FILTER_SANITIZE_URL |
||
| 674 | ), |
||
| 675 | "SESSION" |
||
| 676 | ); |
||
| 677 | // REDIRECTION PAGE ERREUR |
||
| 678 | echo ' |
||
| 679 | <script language="javascript" type="text/javascript"> |
||
| 680 | <!-- |
||
| 681 | sessionStorage.clear(); |
||
| 682 | window.location.href = "index.php"; |
||
| 683 | --> |
||
| 684 | </script>'; |
||
| 685 | exit; |
||
| 686 | } else { |
||
| 687 | $superGlobal->put("initial_url", '', "SESSION"); |
||
| 688 | } |
||
| 689 | |||
| 690 | // CONNECTION FORM |
||
| 691 | echo ' |
||
| 692 | <form method="post" name="form_identify" id="form_identify" action=""> |
||
| 693 | <div style="width:480px;margin:10px auto 10px auto;padding:25px;" class="ui-state-highlight ui-corner-all"> |
||
| 694 | <div style="text-align:center;font-weight:bold;margin-bottom:20px;">', |
||
| 695 | isset($SETTINGS['custom_logo']) && !empty($SETTINGS['custom_logo']) ? '<img src="'.(string) $SETTINGS['custom_logo'].'" alt="" style="margin-bottom:40px;" />' : '', '<br /> |
||
| 696 | '.$LANG['index_get_identified'].' |
||
| 697 | <span id="ajax_loader_connexion" style="display:none;margin-left:10px;"><span class="fa fa-cog fa-spin fa-1x"></span></span> |
||
| 698 | </div> |
||
| 699 | <div id="connection_error" style="display:none;text-align:center;margin:5px; padding:3px;" class="ui-state-error ui-corner-all"> <i class="fa fa-warning"></i> '.$LANG['index_bas_pw'].'</div>'; |
||
| 700 | |||
| 701 | if (isset($SETTINGS['enable_http_request_login']) === true |
||
| 702 | && $SETTINGS['enable_http_request_login'] === '1' |
||
| 703 | && isset($_SERVER['PHP_AUTH_USER']) === true |
||
| 704 | && !(isset($SETTINGS['maintenance_mode']) === true |
||
| 705 | && $SETTINGS['maintenance_mode'] === '1') |
||
| 706 | ) { |
||
| 707 | if (strpos($_SERVER['PHP_AUTH_USER'], '@') !== false) { |
||
| 708 | $username = explode("@", $_SERVER['PHP_AUTH_USER'])[0]; |
||
| 709 | } elseif (strpos($_SERVER['PHP_AUTH_USER'], '\\') !== false) { |
||
| 710 | $username = explode("\\", $_SERVER['PHP_AUTH_USER'])[1]; |
||
| 711 | } else { |
||
| 712 | $username = $_SERVER['PHP_AUTH_USER']; |
||
| 713 | } |
||
| 714 | echo ' |
||
| 715 | <div style="margin-bottom:3px;"> |
||
| 716 | <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> |
||
| 717 | <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
|
|||
| 718 | <span id="login_check_wait" style="display:none; float:right;"><i class="fa fa-cog fa-spin fa-1x"></i></span> |
||
| 719 | </div>'; |
||
| 720 | } else { |
||
| 721 | echo ' |
||
| 722 | <div style="margin-bottom:3px;"> |
||
| 723 | <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> |
||
| 724 | <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 : '', '" /> |
||
| 725 | <span id="login_check_wait" style="display:none; float:right;"><i class="fa fa-cog fa-spin fa-1x"></i></span> |
||
| 726 | </div>'; |
||
| 727 | } |
||
| 728 | |||
| 729 | // AGSES |
||
| 730 | if (isset($SETTINGS['agses_authentication_enabled']) && $SETTINGS['agses_authentication_enabled'] == 1) { |
||
| 731 | echo ' |
||
| 732 | <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"> |
||
| 733 | '.$LANG['user_profile_agses_card_id'].': |
||
| 734 | <input type="text" size="12" id="agses_cardid"> |
||
| 735 | </div> |
||
| 736 | <div id="agses_flickercode_div" style="text-align:center; display:none;"> |
||
| 737 | <canvas id="axs_canvas"></canvas> |
||
| 738 | </div>'; |
||
| 739 | } |
||
| 740 | |||
| 741 | 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')) ) { |
||
| 742 | echo ' |
||
| 743 | <div id="connect_pw" style="margin-bottom:3px;"> |
||
| 744 | <label for="pw" class="form_label" id="user_pwd">'.$LANG['index_password'].'</label> |
||
| 745 | <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 : '', '" /> |
||
| 746 | </div>'; |
||
| 747 | } |
||
| 748 | |||
| 749 | // Personal salt key |
||
| 750 | if (isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1") { |
||
| 751 | echo ' |
||
| 752 | <div id="connect_psk" style="margin-bottom:3px;"> |
||
| 753 | <label for="personal_psk" class="form_label">'.$LANG['home_personal_saltkey'].'</label> |
||
| 754 | <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" /> |
||
| 755 | </div> |
||
| 756 | <div id="connect_psk_confirm" style="margin-bottom:3px; display:none;"> |
||
| 757 | <label for="psk_confirm" class="form_label">'.$LANG['home_personal_saltkey_confirm'].'</label> |
||
| 758 | <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" /> |
||
| 759 | </div>'; |
||
| 760 | } |
||
| 761 | |||
| 762 | // Google Authenticator code |
||
| 763 | if (isset($SETTINGS['google_authentication']) === true && $SETTINGS['google_authentication'] === "1") { |
||
| 764 | echo ' |
||
| 765 | <div id="ga_code_div" style="margin-bottom:10px;"> |
||
| 766 | '.$LANG['ga_identification_code'].' |
||
| 767 | <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.'\')" /> |
||
| 768 | <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> |
||
| 769 | <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> |
||
| 770 | </div>'; |
||
| 771 | } |
||
| 772 | |||
| 773 | echo ' |
||
| 774 | <div style="margin-bottom:3px;"> |
||
| 775 | <label for="duree_session" class="">'.$LANG['index_session_duration'].' ('.$LANG['minutes'].') </label> |
||
| 776 | <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" /> |
||
| 777 | </div>'; |
||
| 778 | |||
| 779 | // Google Authenticator code |
||
| 780 | if (isset($SETTINGS['disable_show_forgot_pwd_link']) === true && $SETTINGS['google_authentication'] !== "1") { |
||
| 781 | echo ' |
||
| 782 | <div style="text-align:center;margin-top:5px;font-size:10pt;"> |
||
| 783 | <span onclick="OpenDialog(\'div_forgot_pw\')" style="padding:3px;cursor:pointer;">'.$LANG['forgot_my_pw'].'</span> |
||
| 784 | </div>'; |
||
| 785 | } |
||
| 786 | |||
| 787 | if (isset($SETTINGS['enable_http_request_login']) === true |
||
| 788 | && $SETTINGS['enable_http_request_login'] === '1' |
||
| 789 | && isset($_SERVER['PHP_AUTH_USER']) === true |
||
| 790 | && (isset($SETTINGS['maintenance_mode']) === false |
||
| 791 | && $SETTINGS['maintenance_mode'] === '1') |
||
| 792 | ) { |
||
| 793 | echo ' |
||
| 794 | <script> |
||
| 795 | var seconds = 1; |
||
| 796 | function updateLogonButton(timeToGo){ |
||
| 797 | document.getElementById("but_identify_user").value = "' . $LANG['duration_login_attempt'] . ' " + timeToGo; |
||
| 798 | } |
||
| 799 | $( window ).on( "load", function() { |
||
| 800 | updateLogonButton(seconds); |
||
| 801 | setInterval(function() { |
||
| 802 | seconds--; |
||
| 803 | if (seconds >= 0) { |
||
| 804 | updateLogonButton(seconds); |
||
| 805 | } else if(seconds === 0) { |
||
| 806 | launchIdentify(\'', isset($SETTINGS['duo']) == true && $SETTINGS['duo'] === "1" ? 1 : '', '\', \''.$nextUrl.'\', \'', isset($SETTINGS['psk_authentication']) && $SETTINGS['psk_authentication'] === "1" ? 1 : '', '\'); |
||
| 807 | } |
||
| 808 | updateLogonButton(seconds); |
||
| 809 | }, |
||
| 810 | 1000 |
||
| 811 | ); |
||
| 812 | }); |
||
| 813 | </script>'; |
||
| 814 | } |
||
| 815 | |||
| 816 | // Yubico authentication |
||
| 817 | if (isset($SETTINGS['yubico_authentication']) === true && $SETTINGS['yubico_authentication'] === "1") { |
||
| 818 | echo ' |
||
| 819 | <div id="yubico_div" style="margin-top:5px; padding:5px; overflow: auto; width:95%;" class="ui-state-default ui-corner-all"> |
||
| 820 | <div style="width: 18%; float:left; display:block;"> |
||
| 821 | <img src="includes/images/yubico.png"> |
||
| 822 | </div> |
||
| 823 | |||
| 824 | <div style="width: 82%; float:right; display:block;"> |
||
| 825 | <div id="yubico_credentials_div" class="hidden"> |
||
| 826 | <h4>'.addslashes($LANG['provide_yubico_identifiers']).'</h4> |
||
| 827 | <label for="yubico_user_id">'.$LANG['yubico_user_id'].'</label> |
||
| 828 | <input type="text" size="10" id="yubico_user_id" class="input_text text ui-widget-content ui-corner-all" /> |
||
| 829 | |||
| 830 | <label for="yubico_user_key">'.$LANG['yubico_user_key'].'</label> |
||
| 831 | <input type="text" size="10" id="yubico_user_key" class="input_text text ui-widget-content ui-corner-all" /> |
||
| 832 | </div> |
||
| 833 | <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 : '', '\')"> |
||
| 834 | <div id="show_yubico_credentials" class="hidden"><a href="#" id="yubico_link">'.addslashes($LANG['show_yubico_info_form']).'</a></div> |
||
| 835 | </div> |
||
| 836 | </div>'; |
||
| 837 | } else { |
||
| 838 | echo ' |
||
| 839 | <div style="text-align:center;margin-top:15px;"> |
||
| 840 | <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'].'" /> |
||
| 841 | </div>'; |
||
| 842 | } |
||
| 843 | |||
| 844 | echo ' |
||
| 845 | </div> |
||
| 846 | </form> |
||
| 847 | <script type="text/javascript"> |
||
| 848 | $("#login").focus(); |
||
| 849 | </script>'; |
||
| 850 | // DIV for forgotten password |
||
| 851 | echo ' |
||
| 852 | <div id="div_forgot_pw" style="display:none;"> |
||
| 853 | <div style="margin:5px auto 5px auto;" id="div_forgot_pw_alert"></div> |
||
| 854 | <div style="margin:5px auto 5px auto;">'.$LANG['forgot_my_pw_text'].'</div> |
||
| 855 | <label for="forgot_pw_email">'.$LANG['email'].'</label> |
||
| 856 | <input type="text" size="40" name="forgot_pw_email" id="forgot_pw_email" /> |
||
| 857 | <br /> |
||
| 858 | <label for="forgot_pw_login">'.$LANG['login'].'</label> |
||
| 859 | <input type="text" size="20" name="forgot_pw_login" id="forgot_pw_login" /> |
||
| 860 | <div id="div_forgot_pw_status" style="text-align:center;margin-top:15px;display:none; padding:5px;" class="ui-corner-all"> |
||
| 861 | <i class="fa fa-cog fa-spin fa-2x"></i> <b>'.$LANG['please_wait'].'</b> |
||
| 862 | </div> |
||
| 863 | </div>'; |
||
| 864 | } |
||
| 865 | echo ' |
||
| 866 | </div>'; |
||
| 867 | // FOOTER |
||
| 868 | /* DON'T MODIFY THE FOOTER ... MANY THANKS TO YOU */ |
||
| 869 | echo ' |
||
| 870 | <div id="footer"> |
||
| 871 | <div style="float:left;width:32%;"> |
||
| 872 | <a href="https://teampass.net" target="_blank" style="color:#F0F0F0;">'.$SETTINGS_EXT['tool_name'].' '.$SETTINGS_EXT['version_full'].' <i class="fa fa-copyright"></i> '.$SETTINGS_EXT['copyright'].'</a> |
||
| 873 | | |
||
| 874 | <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> |
||
| 875 | |
||
| 876 | <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> |
||
| 877 | |
||
| 878 | ', ($session_user_id !== null && empty($session_user_id) === false) ? ' |
||
| 879 | <a href="#" style="color:#F0F0F0;" class="tip" title="'.addslashes($LANG['bugs_page']).'" onclick="generateBugReport()"><i class="fa fa-bug"></i></a>' : '' ,' |
||
| 880 | </div> |
||
| 881 | <div style="float:left;width:32%;text-align:center;"> |
||
| 882 | ', ($session_user_id !== null && empty($session_user_id) === false) ? '<i class="fa fa-users"></i> '.$session_nb_users_online.' '.$LANG['users_online'].' | <i class="fa fa-hourglass-end"></i> '.$LANG['index_expiration_in'].' <div style="display:inline;" id="countdown"></div>' : '', ' |
||
| 883 | </div><div id="countdown2"></div> |
||
| 884 | <div style="float:right;text-align:right;"> |
||
| 885 | <i class="fa fa-clock-o"></i> '. $LANG['server_time']." : ".@date($SETTINGS['date_format'], (string) $_SERVER['REQUEST_TIME'])." - ".@date($SETTINGS['time_format'], (string) $_SERVER['REQUEST_TIME']).' |
||
| 886 | </div> |
||
| 887 | </div>'; |
||
| 888 | // PAGE LOADING |
||
| 889 | echo ' |
||
| 890 | <div id="div_loading" class="hidden"> |
||
| 891 | <div style="padding:5px; z-index:9999999;" class="ui-widget-content ui-state-focus ui-corner-all"> |
||
| 892 | <i class="fa fa-cog fa-spin fa-2x"></i> |
||
| 893 | </div> |
||
| 894 | </div>'; |
||
| 895 | // Alert BOX |
||
| 896 | echo ' |
||
| 897 | <div id="div_dialog_message" style="display:none;"> |
||
| 898 | <div id="div_dialog_message_text" style="text-align:center; padding:4px; font-size:12px; margin-top:10px;"></div> |
||
| 899 | </div>'; |
||
| 900 | |||
| 901 | // WARNING FOR QUERY ERROR |
||
| 902 | echo ' |
||
| 903 | <div id="div_mysql_error" style="display:none;"> |
||
| 904 | <div style="padding:10px;text-align:center;" id="mysql_error_warning"></div> |
||
| 905 | </div>'; |
||
| 906 | |||
| 907 | |||
| 908 | //Personnal SALTKEY |
||
| 909 | if (isset($SETTINGS['enable_pf_feature']) && $SETTINGS['enable_pf_feature'] === "1") { |
||
| 910 | echo ' |
||
| 911 | <div id="div_set_personal_saltkey" style="display:none;padding:4px;"> |
||
| 912 | <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> |
||
| 913 | <table border="0"> |
||
| 914 | <tr> |
||
| 915 | <td> |
||
| 916 | <i class="fa fa-key"></i> <b>'.$LANG['home_personal_saltkey'].'</b> |
||
| 917 | </td> |
||
| 918 | <td> |
||
| 919 | <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> '.$LANG['text_without_symbols'].'" /> |
||
| 920 | <span id="set_personal_saltkey_last_letter" style="font-weight:bold;font-size:20px;"></span> |
||
| 921 | </td> |
||
| 922 | </tr> |
||
| 923 | <tr> |
||
| 924 | <td></td> |
||
| 925 | <td> |
||
| 926 | <div id="psk_strength" style="margin:3px 0 0 10px;"></div> |
||
| 927 | <input type="hidden" id="psk_strength_value" /> |
||
| 928 | </td> |
||
| 929 | </tr> |
||
| 930 | </table> |
||
| 931 | <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> |
||
| 932 | </div>'; |
||
| 933 | } |
||
| 934 | |||
| 935 | // user profile |
||
| 936 | echo ' |
||
| 937 | <div id="dialog_user_profil" style="display:none;padding:4px;"> |
||
| 938 | <div id="div_user_profil"> |
||
| 939 | <i class="fa fa-cog fa-spin fa-2x"></i> <b>'.$LANG['please_wait'].'</b> |
||
| 940 | </div> |
||
| 941 | <input type="hidden" id="force_show_dialog" value="', |
||
| 942 | isset($_SESSION['unsuccessfull_login_attempts']) === true |
||
| 943 | && $_SESSION['unsuccessfull_login_attempts']['nb'] !== 0 |
||
| 944 | && $_SESSION['unsuccessfull_login_attempts']['shown'] === false ? |
||
| 945 | '1' : '0', '" /> |
||
| 946 | </div>'; |
||
| 947 | |||
| 948 | // DUO box |
||
| 949 | echo ' |
||
| 950 | <div id="dialog_duo" style="display:none;padding:4px;"> |
||
| 951 | <div id="div_duo"></div> |
||
| 952 | '.$LANG['duo_loading_iframe'].' |
||
| 953 | <form method="post" id="duo_form" action=""> |
||
| 954 | <input type="hidden" id="duo_login" name="duo_login" value="', null !== $post_duo_login ? $post_duo_login : '', '" /> |
||
| 955 | <input type="hidden" id="duo_pwd" name="duo_pwd" value="', null !== $post_duo_pwd ? $post_duo_pwd : '', '" /> |
||
| 956 | <input type="hidden" id="duo_data" name="duo_data" value="', null !== $post_duo_data ? htmlentities(base64_decode($post_duo_data)) : '', '" /> |
||
| 957 | </form> |
||
| 958 | </div>'; |
||
| 959 | |||
| 960 | // INCREASE session time |
||
| 961 | echo ' |
||
| 962 | <div id="div_increase_session_time" style="display:none;padding:4px;"> |
||
| 963 | <b>'.$LANG['index_session_duration'].':</b> |
||
| 964 | <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, '" /> |
||
| 965 | <b>'.$LANG['minutes'].'</b> |
||
| 966 | <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> |
||
| 967 | </div>'; |
||
| 968 | |||
| 969 | closelog(); |
||
| 970 | |||
| 971 | ?> |
||
| 972 | <script type="text/javascript">NProgress.start();</script> |
||
| 973 | </body> |
||
| 974 | </html> |
||
| 975 |
$usernamecan 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
$_SERVER['PHP_AUTH_USER']is assigned to$usernamein index.php on line 712$_SERVER['PHP_AUTH_USER']is assigned to$usernamein index.php on line 712
explode(), andexplode('@', $_SERVER['PHP_AUTH_USER'])[0]is assigned to$usernamein index.php on line 708explode(), andexplode('@', $_SERVER['PHP_AUTH_USER'])[0]is assigned to$usernamein index.php on line 708
explode(), andexplode('\', $_SERVER['PHP_AUTH_USER'])[1]is assigned to$usernamein index.php on line 710explode(), andexplode('\', $_SERVER['PHP_AUTH_USER'])[1]is assigned to$usernamein 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:
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: