forked from glpi-project/glpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
121 lines (107 loc) · 4.29 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2021 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
// Check PHP version not to have trouble
// Need to be the very fist step before any include
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
die('PHP >= 7.4.0 required');
}
use Glpi\Application\View\TemplateRenderer;
use Glpi\Plugin\Hooks;
//Load GLPI constants
define('GLPI_ROOT', __DIR__);
include (GLPI_ROOT . "/inc/based_config.php");
define('DO_NOT_CHECK_HTTP_REFERER', 1);
// If config_db doesn't exist -> start installation
if (!file_exists(GLPI_CONFIG_DIR . "/config_db.php")) {
Html::redirect("install/install.php");
die();
} else {
include (GLPI_ROOT . "/inc/includes.php");
$_SESSION["glpicookietest"] = 'testcookie';
// For compatibility reason
if (isset($_GET["noCAS"])) {
$_GET["noAUTO"] = $_GET["noCAS"];
}
if (!isset($_GET["noAUTO"])) {
Auth::redirectIfAuthenticated();
}
Auth::checkAlternateAuthSystems(true, isset($_GET["redirect"])?$_GET["redirect"]:"");
$theme = $_SESSION['glpipalette'] ?? 'auror';
$errors = "";
if (isset($_GET['error']) && isset($_GET['redirect'])) {
switch ($_GET['error']) {
case 1 : // cookie error
$errors.= __('You must accept cookies to reach this application');
break;
case 2 : // GLPI_SESSION_DIR not writable
$errors.= __('Checking write permissions for session files');
break;
case 3 :
$errors.= __('Invalid use of session ID');
break;
}
}
TemplateRenderer::getInstance()->display('pages/login.html.twig', [
'card_bg_width' => true,
'lang' => $CFG_GLPI["languages"][$_SESSION['glpilanguage']][3],
'title' => __('Authentication'),
'noAuto' => $_GET["noAUTO"] ?? 0,
'redirect' => Html::entities_deep($_GET['redirect'] ?? ""),
'text_login' => $CFG_GLPI['text_login'],
'namfield' => ($_SESSION['namfield'] = uniqid('fielda')),
'pwdfield' => ($_SESSION['pwdfield'] = uniqid('fieldb')),
'rmbfield' => ($_SESSION['rmbfield'] = uniqid('fieldc')),
'show_lost_password' => $CFG_GLPI["notifications_mailing"]
&& countElementsInTable('glpi_notifications', [
'itemtype' => 'User',
'event' => 'passwordforget',
'is_active' => 1
]),
'languages_dropdown' => Dropdown::showLanguages('language', [
'display' => false,
'display_emptychoice' => true,
'emptylabel' => __('Default (from user profile)'),
'width' => '100%'
]),
'right_panel' => strlen($CFG_GLPI['text_login']) > 0
|| count($PLUGIN_HOOKS[Hooks::DISPLAY_LOGIN] ?? []) > 0
|| $CFG_GLPI["use_public_faq"],
'auth_dropdown_login' => Auth::dropdownLogin(false),
'copyright_message' => Html::getCopyrightMessage(false),
'errors' => $errors
]);
}
// call cron
if (!GLPI_DEMO_MODE) {
CronTask::callCronForce();
}
echo "</body></html>";