Debian Codegraph @

templates/config/confsave.php

raw
1 <?php
2 namespace LAM\CONFIG;
3 use htmlJavaScript;
4 use \htmlStatusMessage;
5 use LAMException;
6 use ServerProfilePersistenceManager;
7
8 /*
9
10 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
11 Copyright (C) 2009 - 2026 Roland Gruber
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 */
28
29
30 /**
31 * End page of configuration.
32 *
33 * @package configuration
34 * @author Roland Gruber
35 */
36
37
38 /** Access to config functions */
39 include_once(__DIR__ . "/../../lib/config.inc");
40 /** access to module settings */
41 include_once(__DIR__ . "/../../lib/modules.inc");
42 /** common functions */
43 include_once __DIR__ . '/../../lib/configPages.inc';
44
45 // start session
46 if (isFileBasedSession()) {
47 session_save_path("../../sess");
48 }
49 lam_start_session();
50
51 setlanguage();
52
53 // check if password was entered
54 // if not: load login page
55 if (!isset($_SESSION['conf_isAuthenticated']) || ($_SESSION['conf_config']->getName() !== $_SESSION['conf_isAuthenticated'])) {
56 $_SESSION['conf_message'] = new htmlStatusMessage('ERROR', _("No password was entered!"));
57 /** go back to login if password is empty */
58 require(__DIR__ . '/conflogin.php');
59 exit;
60 }
61
62 $conf = &$_SESSION['conf_config'];
63 $confName = $_SESSION['conf_isAuthenticated'];
64
65 echo $_SESSION['header'];
66 printHeaderContents(_("LDAP Account Manager Configuration"), '../..');
67 echo "<body>\n";
68 // include all JavaScript files
69 printJsIncludes('../..');
70 printConfigurationPageHeaderBar($conf);
71
72 $serverProfilePersistenceManager = new ServerProfilePersistenceManager();
73 try {
74 $serverProfilePersistenceManager->saveProfile($conf, $confName);
75 $scriptTag = new htmlJavaScript('window.lam.dialog.showSuccessMessageAndRedirect("' . _("Your settings were successfully saved.") . '", "' . htmlspecialchars($confName) . '", "' . _('Ok') . '", "../login.php")');
76 parseHtml(null, $scriptTag, [], false, null);
77 }
78 catch (LAMException $e) {
79 $scriptTag = new htmlJavaScript('window.lam.dialog.showErrorMessageAndRedirect("' . htmlspecialchars($e->getTitle()) . '", "' . htmlspecialchars($e->getMessage()) . '", "' . _('Ok') . '", "../login.php")');
80 parseHtml(null, $scriptTag, [], false, null);
81 }
82 finally {
83 // remove settings from the session
84 $sessionKeys = array_keys($_SESSION);
85 foreach ($sessionKeys as $sessionKey) {
86 if (str_starts_with($sessionKey, "conf_")) {
87 unset($_SESSION[$sessionKey]);
88 }
89 }
90 }
91
92 ?>
93 </body>
94 </html>