get_Passwd()) {
	/** go back to login if password is invalid */
	require('conflogin.php');
	exit;
}
echo $_SESSION['header'];
echo "
" . _("LDAP Account Manager Configuration") . "\n";
echo "\n";
echo "\n";
echo ("".
	"
");
// remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) {
	$sufftree = stripslashes($sufftree);
}
// check new preferences
if (!$conf->set_ServerURL($serverurl)) {
	echo ("" . _("Server Address is empty!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_cacheTimeout($cachetimeout)) {
	echo ("" . _("Cache timeout is invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_Adminstring($admins)) {
	echo ("" . _("List of admin users is empty or invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_Suffix("tree", $sufftree)) {
	echo ("" . _("TreeSuffix is invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_MaxListEntries($maxlistentries)) {
	echo ("" . _("Max list entries is invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_defaultLanguage($lang)) {
	echo ("" . _("Language is not defined!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_scriptpath($scriptpath)) {
	echo ("" . _("Script path is invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
if (!$conf->set_scriptserver($scriptserver)) {
	echo ("" . _("Script server is invalid!") . "");
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
$conf->set_typeSettings($_SESSION['conf_typeSettings']);
$conf->set_ActiveTypes($_SESSION['conf_accountTypes']);
// check module options
// create option array to check and save
$options = array();
$opt_keys = array_keys($_SESSION['config_types']);
foreach ($opt_keys as $element) {
	// text fields
	if ($_SESSION['config_types'][$element] == "text") {
		$options[$element] = array($_SESSION['config_moduleSettings'][$element]);
	}
	// checkboxes
	elseif ($_SESSION['config_types'][$element] == "checkbox") {
		if ($_SESSION['config_moduleSettings'][$element] == "on") $options[$element] = array('true');
		else $options[$element] = array('false');
	}
	// dropdownbox
	elseif ($_SESSION['config_types'][$element] == "select") {
		$options[$element] = array($_SESSION['config_moduleSettings'][$element]);
	}
	// multiselect
	elseif ($_SESSION['config_types'][$element] == "multiselect") {
		$options[$element] = $_SESSION['config_moduleSettings'][$element];  // value is already an array
	}
}
// remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) {
	foreach ($opt_keys as $element) {
		if (is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]);
	}
}
// check options
$errors = checkConfigOptions($_SESSION['config_scopes'], $options);
// print error messages if any
if (sizeof($errors) > 0) {
	for ($i = 0; $i < sizeof($errors); $i++) {
		if (sizeof($errors[$i]) > 3) {  // messages with additional variables
			StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2], $errors[$i][3]);
		}
		else {
			StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]);
		}
	}
	echo ("\n
" . _("Back to preferences...") . "");
	exit;
}
// save module setting
$conf->set_moduleSettings($options);
// check if password was changed
if ($passwd1) {
	if ($passwd1 != $passwd2) {
		echo ("" . _("Passwords are different!") . "");
		exit;
	}
	// set new password
	if ($passwd1 != "") {
		$conf->set_Passwd($passwd1);
		echo ("" . _("Password changed!") . "
");
	}
}
// save settings and display new settings
$conf->save();
echo ("
" . _("Back to Login") . "");
echo("