forked from glpi-project/glpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
238 lines (200 loc) · 7.57 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2018 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, '5.6') < 0) {
die('PHP >= 5.6 required');
}
use Glpi\Event;
//Load GLPI constants
define('GLPI_ROOT', __DIR__);
include (GLPI_ROOT . "/inc/based_config.php");
include_once (GLPI_ROOT . "/inc/define.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")) {
include_once (GLPI_ROOT . "/inc/autoload.function.php");
Html::redirect("install/install.php");
die();
} else {
$TRY_OLD_CONFIG_FIRST = true;
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"]:"");
// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
// Start the page
echo "<!DOCTYPE html>\n";
echo "<html lang=\"{$CFG_GLPI["languages"][$_SESSION['glpilanguage']][3]}\" class='loginpage'>";
echo '<head><title>'.__('GLPI - Authentication').'</title>'."\n";
echo '<meta charset="utf-8"/>'."\n";
echo "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n";
echo '<link rel="shortcut icon" type="images/x-icon" href="'.$CFG_GLPI["root_doc"].
'/pics/favicon.ico" />';
// auto desktop / mobile viewport
echo "<meta name='viewport' content='width=device-width, initial-scale=1'/>";
// Appel CSS
echo Html::scss('css/styles');
if (isset($_SESSION['glpihighcontrast_css']) && $_SESSION['glpihighcontrast_css']) {
echo Html::scss('css/highcontrast');
}
$theme = isset($_SESSION['glpipalette']) ? $_SESSION['glpipalette'] : 'auror';
echo Html::scss('css/palettes/' . $theme);
// font awesome icons
echo Html::css('lib/font-awesome/css/all.css');
// CFG
echo Html::scriptBlock("
var CFG_GLPI = {
'url_base': '".(isset($CFG_GLPI['url_base']) ? $CFG_GLPI["url_base"] : '')."',
'root_doc': '".$CFG_GLPI["root_doc"]."',
};
");
echo Html::script('lib/jquery/js/jquery.js');
echo Html::script('lib/jqueryplugins/select2/js/select2.full.js');
echo Html::script("lib/fuzzy/fuzzy-min.js");
echo Html::css('lib/jqueryplugins/select2/css/select2.css');
echo Html::script('js/common.js');
echo "</head>";
echo "<body>";
echo "<div id='firstboxlogin'>";
echo "<div id='logo_login'></div>";
echo "<div id='text-login'>";
echo nl2br(Toolbox::unclean_html_cross_side_scripting_deep($CFG_GLPI['text_login']));
echo "</div>";
echo "<div id='boxlogin'>";
echo "<form action='".$CFG_GLPI["root_doc"]."/front/login.php' method='post'>";
$_SESSION['namfield'] = $namfield = uniqid('fielda');
$_SESSION['pwdfield'] = $pwdfield = uniqid('fieldb');
$_SESSION['rmbfield'] = $rmbfield = uniqid('fieldc');
// Other CAS
if (isset($_GET["noAUTO"])) {
echo "<input type='hidden' name='noAUTO' value='1' />";
}
// redirect to ticket
if (isset($_GET["redirect"])) {
Toolbox::manageRedirect($_GET["redirect"]);
echo '<input type="hidden" name="redirect" value="'.Html::entities_deep($_GET['redirect']).'"/>';
}
echo '<p class="login_input" id="login_input_name">
<input type="text" name="'.$namfield.'" id="login_name" required="required"
placeholder="'.__('Login').'" autofocus="autofocus" />
</p>';
echo '<p class="login_input" id="login_input_password">
<input type="password" name="'.$pwdfield.'" id="login_password" required="required"
placeholder="'.__('Password').'" />
</p>';
if (GLPI_DEMO_MODE) {
//lang selector
echo '<p class="login_input" id="login_lang">';
Dropdown::showLanguages(
'language', [
'display_emptychoice' => true,
'emptylabel' => __('Default (from user profile)'),
'width' => '100%'
]
);
echo '</p>';
}
// Add dropdown for auth (local, LDAPxxx, LDAPyyy, imap...)
if ($CFG_GLPI['display_login_source']) {
Auth::dropdownLogin();
}
if ($CFG_GLPI["login_remember_time"]) {
echo '<p class="login_input">
<label for="login_remember">
<input type="checkbox" name="'.$rmbfield.'" id="login_remember"
'.($CFG_GLPI['login_remember_default']?'checked="checked"':'').' />
'.__('Remember me').'</label>
</p>';
}
echo '<p class="login_input">
<input type="submit" name="submit" value="'._sx('button', 'Post').'" class="submit" />
</p>';
if ($CFG_GLPI["notifications_mailing"]
&& countElementsInTable(
'glpi_notifications', [
'itemtype' => 'User',
'event' => 'passwordforget',
'is_active' => 1
])
) {
echo '<a id="forget" href="front/lostpassword.php?lostpassword=1">'.
__('Forgotten password?').'</a>';
}
Html::closeForm();
$js = "$(function() {
$('#login_name').focus();
});";
echo Html::scriptBlock($js);
echo "</div>"; // end login box
echo "<div class='error'>";
echo "<noscript><p>";
echo __('You must activate the JavaScript function of your browser');
echo "</p></noscript>";
if (isset($_GET['error']) && isset($_GET['redirect'])) {
switch ($_GET['error']) {
case 1 : // cookie error
echo __('You must accept cookies to reach this application');
break;
case 2 : // GLPI_SESSION_DIR not writable
echo __('Checking write permissions for session files');
break;
case 3 :
echo __('Invalid use of session ID');
break;
}
}
echo "</div>";
// Display FAQ is enable
if ($CFG_GLPI["use_public_faq"]) {
echo '<div id="box-faq">'.
'<a href="front/helpdesk.faq.php">[ '.__('Access to the Frequently Asked Questions').' ]';
echo '</a></div>';
}
echo "<div id='display-login'>";
Plugin::doHook('display_login');
echo "</div>";
echo "</div>"; // end contenu login
echo "<div id='footer-login' class='home'>" . Html::getCopyrightMessage(false) . "</div>";
}
// call cron
if (!GLPI_DEMO_MODE) {
CronTask::callCronForce();
}
echo "</body></html>";