Debian Codegraph @

templates/config/mainlogin.php

raw
1 <?php
2 /*
3
4 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
5 Copyright (C) 2003 - 2026 Roland Gruber
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 */
22
23
24 /**
25 * Login page to change the main preferences.
26 *
27 * @package configuration
28 * @author Roland Gruber
29 */
30
31
32 /** Access to config functions */
33 include_once(__DIR__ . '/../../lib/config.inc');
34 /** Used to print status messages */
35 include_once(__DIR__ . '/../../lib/status.inc');
36 if (isLAMProVersion()) {
37 include_once(__DIR__ . "/../../lib/env.inc");
38 }
39
40 // start session
41 if (isFileBasedSession()) {
42 session_save_path(__DIR__ . '/../../sess');
43 }
44 lam_start_session();
45 session_regenerate_id(true);
46
47 setlanguage();
48
49 // remove settings from session
50 if (isset($_SESSION["mainconf_password"])) {
51 unset($_SESSION["mainconf_password"]);
52 }
53 if (isset($_SESSION['cfgMain'])) {
54 unset($_SESSION['cfgMain']);
55 }
56 $cfgMain = new LAMCfgMain();
57 // check if user entered a password
58 if (isset($_POST['passwd'])) {
59 if ($cfgMain->checkPassword($_POST['passwd'])) {
60 $_SESSION["mainconf_password"] = $_POST['passwd'];
61 metaRefresh("mainmanage.php");
62 exit();
63 }
64 else {
65 $message = _("The password is invalid! Please try again.");
66 }
67 }
68
69 if (isset($_SESSION['header'])) {
70 echo $_SESSION['header'];
71 }
72 printHeaderContents(_("Login"), '../..');
73 ?>
74 </head>
75 <body>
76 <?php
77 // include all JavaScript files
78 printJsIncludes('../..');
79 ?>
80 <div id="lam-topnav" class="lam-header">
81 <div class="lam-header-left lam-menu-stay">
82 <a href="https://www.ldap-account-manager.org/" target="new_window">
83 <img class="align-middle" width="24" height="24" alt="help" src="../../graphics/logo.svg">
84 <span class="hide-on-mobile">
85 <?php
86 echo getLAMVersionText();
87 ?>
88 </span>
89 </a>
90 </div>
91 <?php
92 if (is_dir(__DIR__ . '/../../docs/manual')) {
93 ?>
94 <a class="lam-header-right lam-menu-icon hide-on-tablet" href="javascript:void(0);" class="icon"
95 onclick="window.lam.topmenu.toggle();">
96 <img class="align-middle" width="16" height="16" alt="menu" src="../../graphics/menu.svg">
97 <span class="padding0">&nbsp;</span>
98 </a>
99 <a class="lam-header-right lam-menu-entry" target="_blank" href="../../docs/manual/index.html">
100 <span class="padding0"><?php echo _("Help") ?></span>
101 </a>
102 <?php
103 }
104 ?>
105 </div>
106 <br>
107 <?php
108 // check if config file is writable
109 if (!$cfgMain->isWritable()) {
110 StatusMessage('WARN', _('The config file is not writable.'), _('Your changes cannot be saved until you make the file writable for the webserver user.'));
111 }
112 if (!empty($_GET['invalidLicense']) && ($_GET['invalidLicense'] == '1')) {
113 StatusMessage('WARN', _('Invalid licence'), _('Please setup your licence data.'));
114 }
115 if (!empty($_GET['invalidLicense']) && ($_GET['invalidLicense'] == '2')) {
116 StatusMessage('WARN', _('Expired licence'), _('Please setup your licence data.'));
117 }
118 ?>
119 <br>
120 <!-- form to change main options -->
121 <form action="mainlogin.php" method="post" autocomplete="off">
122 <table align="center">
123 <tr>
124 <td>
125 <table align="center" border="0" rules="none" bgcolor="white" class="roundedShadowBox"
126 style="padding: 20px;">
127 <tr>
128 <td>
129 <?php
130 $spacer = new htmlSpacer('20px', '20px');
131 $group = new htmlGroup();
132 $row = new htmlResponsiveRow();
133 $row->add(new htmlOutputText(_("Please enter the master password to change the general preferences:")), 12);
134 $group->addElement($row);
135 // print message if login was incorrect or no config profiles are present
136 if (isset($message)) {
137 $messageField = new htmlStatusMessage('ERROR', $message);
138 $row = new htmlResponsiveRow();
139 $row->add($messageField, 12);
140 $group->addElement($spacer);
141 $group->addElement($row);
142 }
143 $group->addElement($spacer);
144 // password input
145 $label = new htmlOutputText(_('Master password'));
146 $passwordGroup = new htmlGroup();
147 $passwordField = new htmlInputField('passwd');
148 $passwordField->setFieldSize(15);
149 $passwordField->setIsPassword(true);
150 $passwordField->setCSSClasses(['lam-initial-focus']);
151 $passwordGroup->addElement($passwordField);
152 $passwordGroup->addElement(new htmlHelpLink('236'));
153 $passwordDiv = new htmlDiv(null, $passwordGroup);
154 $passwordDiv->setCSSClasses(['nowrap']);
155 $row = new htmlResponsiveRow($label, $passwordDiv);
156 $group->addElement($row);
157 // button
158 $group->addElement($spacer);
159 $okButton = new htmlButton('submit', _("Ok"));
160 $okButton->setCSSClasses(['lam-primary']);
161 $row = new htmlResponsiveRow();
162 $row->add($okButton, 12);
163 $row->setCSSClasses(['']);
164 $group->addElement($row);
165
166 $div = new htmlDiv(null, $group);
167 $div->setCSSClasses(['centeredTable']);
168
169 parseHtml(null, $div, [], false, 'user');
170 ?>
171 </td>
172 </tr>
173 </table>
174 </td>
175 </tr>
176 <tr>
177 <td align="left">
178 <br><a href="../login.php"><?php echo _("Back to login"); ?></a>
179 </td>
180 </tr>
181 </table>
182 </form>
183
184 <p><br><br></p>
185
186 </body>
187 </html>