LDAPAccountManager/lam/templates/config/confsave.php

270 lines
10 KiB
PHP
Raw Normal View History

<?php
2003-02-25 21:28:17 +00:00
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Roland Gruber
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.
2003-05-02 16:52:19 +00:00
2003-02-25 21:28:17 +00:00
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.
2003-05-02 16:52:19 +00:00
2003-02-25 21:28:17 +00:00
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
2004-06-02 12:48:54 +00:00
*/
2003-05-02 16:52:19 +00:00
2004-06-02 12:48:54 +00:00
/**
* confsave saves the new preferences to lam.conf
*
* @package configuration
* @author Roland Gruber
2003-02-25 21:28:17 +00:00
*/
2004-06-02 12:48:54 +00:00
/** Access to config functions */
2003-07-06 17:54:11 +00:00
include_once ('../../lib/config.inc');
2003-02-25 21:28:17 +00:00
2003-03-23 18:38:47 +00:00
// start session
2003-04-23 19:13:55 +00:00
session_save_path("../../sess");
2003-07-06 17:54:11 +00:00
@session_start();
setlanguage();
$conf = new Config($_SESSION['conf_filename']);
2003-02-25 21:28:17 +00:00
2003-06-24 15:50:38 +00:00
// get data from session
$passwd = $_SESSION['conf_passwd'];
$passwd1 = $_SESSION['conf_passwd1'];
$passwd2 = $_SESSION['conf_passwd2'];
$serverurl = $_SESSION['conf_serverurl'];
$cachetimeout = $_SESSION['conf_cachetimeout'];
$admins = $_SESSION['conf_admins'];
$suffusers = $_SESSION['conf_suffusers'];
$suffgroups = $_SESSION['conf_suffgroups'];
$suffhosts = $_SESSION['conf_suffhosts'];
$suffdomains = $_SESSION['conf_suffdomains'];
$minUID = $_SESSION['conf_minUID'];
$maxUID = $_SESSION['conf_maxUID'];
$minGID = $_SESSION['conf_minGID'];
$maxGID = $_SESSION['conf_maxGID'];
$minMach = $_SESSION['conf_minMach'];
$maxMach = $_SESSION['conf_maxMach'];
$usrlstattr = $_SESSION['conf_usrlstattr'];
$grplstattr = $_SESSION['conf_grplstattr'];
$hstlstattr = $_SESSION['conf_hstlstattr'];
$maxlistentries = $_SESSION['conf_maxlistentries'];
$lang = $_SESSION['conf_lang'];
$scriptpath = $_SESSION['conf_scriptpath'];
$scriptserver = $_SESSION['conf_scriptserver'];
$pwdhash = $_SESSION['conf_pwdhash'];
$filename = $_SESSION['conf_filename'];
2003-05-02 16:52:19 +00:00
// check if password is correct
2003-03-08 10:10:19 +00:00
// if not: load login page
2003-02-25 21:28:17 +00:00
if ($passwd != $conf->get_Passwd()) {
2004-06-02 12:48:54 +00:00
/** go back to login if password is invalid */
2003-03-08 10:10:19 +00:00
require('conflogin.php');
2003-02-25 21:28:17 +00:00
exit;
}
2003-07-29 11:52:26 +00:00
echo $_SESSION['header'];
2003-05-28 21:44:41 +00:00
2004-01-02 12:42:46 +00:00
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
2003-05-09 16:22:46 +00:00
echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\">".
2003-05-28 21:44:41 +00:00
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>");
2003-03-18 21:39:52 +00:00
2003-02-25 21:28:17 +00:00
// check new preferences
if (!$conf->set_ServerURL($serverurl)) {
2003-07-04 16:25:05 +00:00
echo ("<font color=\"red\"><b>" . _("Server Address is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
2003-02-25 21:28:17 +00:00
exit;
}
if (!$conf->set_cacheTimeout($cachetimeout)) {
2003-12-12 15:42:21 +00:00
echo ("<font color=\"red\"><b>" . _("Cache timeout is invalid!") . "</b></font>");
2003-08-18 15:21:27 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Adminstring($admins)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("List of admin users is empty or invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
2003-02-25 21:28:17 +00:00
exit;
}
if (!$conf->set_UserSuffix($suffusers)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_GroupSuffix($suffgroups)) {
echo ("<font color=\"red\"><b>" . _("GroupSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
2003-05-02 17:47:35 +00:00
exit;
}
if (!$conf->set_HostSuffix($suffhosts)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("HostSuffix is invalid!") . "</b></font>");
2003-05-02 17:47:35 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_DomainSuffix($suffdomains)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("DomainSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minUID($minUID)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Minimum UID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxUID($maxUID)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Maximum UID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minGID($minGID)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Minimum GID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxGID($maxGID)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Maximum GID number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minMachine($minMach)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Minimum Machine number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxMachine($maxMach)) {
2003-12-27 10:27:38 +00:00
echo ("<font color=\"red\"><b>" . _("Maximum Machine number is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_userlistAttributes($usrlstattr)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("User list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_grouplistAttributes($grplstattr)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("Group list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_hostlistAttributes($hstlstattr)) {
2003-07-30 14:34:33 +00:00
echo ("<font color=\"red\"><b>" . _("Host list attributes are invalid!") . "</b></font>");
2003-07-25 15:41:51 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_MaxListEntries($maxlistentries)) {
2003-07-25 15:41:51 +00:00
echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
2003-02-25 21:28:17 +00:00
if (!$conf->set_defaultLanguage($lang)) {
2003-07-04 16:25:05 +00:00
echo ("<font color=\"red\"><b>" . _("Language is not defined!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_scriptpath($scriptpath)) {
echo ("<font color=\"red\"><b>" . _("Script path is invalid!") . "</b></font>");
2003-05-28 15:37:48 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_scriptserver($scriptserver)) {
echo ("<font color=\"red\"><b>" . _("Script server is invalid!") . "</b></font>");
2003-07-25 15:41:51 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_pwdhash($pwdhash)) {
echo ("<font color=\"red\"><b>" . _("Password hash is invalid!") . "</b></font>");
2003-06-19 19:01:00 +00:00
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
2004-02-01 12:33:21 +00:00
if (! $conf->set_UserModules($_SESSION['conf_usermodules'])) {
echo ("<font color=\"red\"><b>" . _("Saving user modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (! $conf->set_GroupModules($_SESSION['conf_groupmodules'])) {
echo ("<font color=\"red\"><b>" . _("Saving group modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (! $conf->set_HostModules($_SESSION['conf_hostmodules'])) {
echo ("<font color=\"red\"><b>" . _("Saving host modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
2003-02-25 21:28:17 +00:00
// check if password was changed
if ($passwd1) {
if ($passwd1 != $passwd2) {
echo ("<b>" . _("Passwords are different!") . "</b>");
exit;
}
// set new password
if ($passwd1 != "") {
$conf->set_Passwd($passwd1);
echo ("<b>" . _("Password changed!") . "</b><br><br>");
}
2003-02-25 21:28:17 +00:00
}
2003-03-08 10:10:19 +00:00
// save settings and display new settings
2003-03-01 16:57:54 +00:00
$conf->save();
2003-07-06 10:24:41 +00:00
echo ("<b>" . _("The following settings were saved to profile:") . " </b>" . $filename . "<br><br>");
2003-02-25 21:28:17 +00:00
$conf->printconf();
2003-04-23 19:13:55 +00:00
echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>");
echo("</body></html>");
2003-05-09 16:22:46 +00:00
// remove settings from session
unset($_SESSION['conf_passwd']);
unset($_SESSION['conf_passwd1']);
unset($_SESSION['conf_passwd2']);
unset($_SESSION['conf_serverurl']);
unset($_SESSION['conf_cachetimeout']);
unset($_SESSION['conf_admins']);
unset($_SESSION['conf_suffusers']);
unset($_SESSION['conf_suffgroups']);
unset($_SESSION['conf_suffhosts']);
unset($_SESSION['conf_suffdomains']);
unset($_SESSION['conf_minUID']);
unset($_SESSION['conf_maxUID']);
unset($_SESSION['conf_minGID']);
unset($_SESSION['conf_maxGID']);
unset($_SESSION['conf_minMach']);
unset($_SESSION['conf_maxMach']);
unset($_SESSION['conf_usrlstattr']);
unset($_SESSION['conf_grplstattr']);
unset($_SESSION['conf_hstlstattr']);
unset($_SESSION['conf_maxlistentries']);
unset($_SESSION['conf_lang']);
unset($_SESSION['conf_scriptpath']);
unset($_SESSION['conf_scriptserver']);
2003-10-04 12:34:19 +00:00
unset($_SESSION['conf_pwdhash']);
unset($_SESSION['conf_filename']);
2004-02-01 12:33:21 +00:00
unset($_SESSION['conf_usermodules']);
unset($_SESSION['conf_groupmodules']);
unset($_SESSION['conf_hostmodules']);
2003-03-08 10:10:19 +00:00
?>