LDAPAccountManager/lam/templates/config/confsave.php

97 lines
2.9 KiB
PHP
Raw Normal View History

2009-07-10 20:22:59 +00:00
<?php
2017-03-06 18:12:02 +00:00
namespace LAM\CONFIG;
use \LAMConfig;
2017-11-04 09:49:28 +00:00
use \htmlStatusMessage;
2009-07-10 20:22:59 +00:00
/*
$Id$
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
2018-03-10 17:48:11 +00:00
Copyright (C) 2009 - 2018 Roland Gruber
2009-07-10 20:22:59 +00:00
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* End page of configuration.
*
* @package configuration
* @author Roland Gruber
*/
/** Access to config functions */
2018-12-23 16:52:56 +00:00
include_once(__DIR__ . "/../../lib/config.inc");
2009-07-10 20:22:59 +00:00
/** access to module settings */
2018-12-23 16:52:56 +00:00
include_once(__DIR__ . "/../../lib/modules.inc");
2009-07-10 20:22:59 +00:00
// start session
if (strtolower(session_module_name()) == 'files') {
session_save_path("../../sess");
}
2018-03-10 17:48:11 +00:00
lam_start_session();
2009-07-10 20:22:59 +00:00
setlanguage();
// get password
if (isset($_POST['passwd'])) $passwd = $_POST['passwd'];
// check if password was entered
// if not: load login page
if (!isset($passwd) && !isset($_SESSION['conf_isAuthenticated'])) {
2017-11-04 09:49:28 +00:00
$_SESSION['conf_message'] = new htmlStatusMessage('ERROR', _("No password was entered!"));
2009-07-10 20:22:59 +00:00
/** go back to login if password is empty */
require('conflogin.php');
exit;
}
if (!isset($_SESSION['conf_config']) && isset($_POST['filename'])) {
$_SESSION['conf_config'] = new LAMConfig($_POST['filename']);
}
$conf = &$_SESSION['conf_config'];
// check if password is valid
// if not: load login page
if ((!isset($_SESSION['conf_isAuthenticated']) || !($_SESSION['conf_isAuthenticated'] === $conf->getName())) && !$conf->check_Passwd($passwd)) {
$sessionKeys = array_keys($_SESSION);
for ($i = 0; $i < sizeof($sessionKeys); $i++) {
if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]);
}
2017-11-04 09:49:28 +00:00
$_SESSION['conf_message'] = new htmlStatusMessage('ERROR', _("The password is invalid! Please try again."));
2009-07-10 20:22:59 +00:00
/** go back to login if password is invalid */
require('conflogin.php');
exit;
}
$_SESSION['conf_isAuthenticated'] = $conf->getName();
2010-05-28 13:45:34 +00:00
$result = $conf->save();
2009-07-10 20:22:59 +00:00
// remove settings from session
$sessionKeys = array_keys($_SESSION);
for ($i = 0; $i < sizeof($sessionKeys); $i++) {
if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]);
}
2010-05-28 13:45:34 +00:00
if ($result === LAMConfig::SAVE_OK) {
2018-11-25 09:51:39 +00:00
metaRefresh('../login.php?configSaveOk=1&configSaveFile=' . $conf->getName());
2010-05-28 13:45:34 +00:00
}
else {
2018-11-25 09:51:39 +00:00
metaRefresh('../login.php?configSaveFailed=1&configSaveFile=' . $conf->getName());
2010-05-28 13:45:34 +00:00
}
2009-07-10 20:22:59 +00:00
?>