get_Passwd(); // check if password was entered // if not: load login page if (! $passwd) { $_SESSION['conf_message'] = _("No password was entered!"); /** go back to login if password is empty */ require('conflogin.php'); exit; } if (!isset($_SESSION['conf_config']) && isset($_POST['filename'])) { $_SESSION['conf_config'] = new Config($_POST['filename']); } $conf = &$_SESSION['conf_config']; // check if password is valid // if not: load login page if (!(($conf->get_Passwd()) == $passwd)) { $sessionKeys = array_keys($_SESSION); for ($i = 0; $i < sizeof($sessionKeys); $i++) { if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]); } $_SESSION['conf_message'] = _("The password is invalid! Please try again."); /** go back to login if password is invalid */ require('conflogin.php'); exit; } // check if button was pressed and if we have to save the setting or go back to login if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules']) || isset($_POST['edittypes'])){ // go to final page if ($_POST['submitconf']){ saveSettings(); } // go to modules page elseif ($_POST['editmodules']){ metaRefresh("confmodules.php"); exit; } // go to types page elseif ($_POST['edittypes']){ metaRefresh("conftypes.php"); exit; } // back to login else if ($_POST['back']){ metaRefresh("../login.php"); exit; } } // check if user comes from types page if (isset($_GET["typesback"])) { // check if a new account type was added if (isset($_GET["typeschanged"])) { metaRefresh("confmodules.php"); exit; } } // type information if (!isset($_SESSION['conf_accountTypes'])) $_SESSION['conf_accountTypes'] = $conf->get_ActiveTypes(); if (!isset($_SESSION['conf_accountTypesOld'])) $_SESSION['conf_accountTypesOld'] = $conf->get_ActiveTypes(); if (!isset($_SESSION['conf_typeSettings'])) $_SESSION['conf_typeSettings'] = $conf->get_typeSettings(); // index for tab order $tabindex = 1; $tabindexLink = 1000; echo $_SESSION['header']; echo ("" . _("LDAP Account Manager Configuration") . "\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("

". "\"LDAP

\n
\n

\n"); // display error messages if (isset($_SESSION['conf_errors'])) { for ($i = 0; $i < sizeof($_SESSION['conf_errors']); $i++) { call_user_func_array('StatusMessage', $_SESSION['conf_errors'][$i]); } echo "
"; } // display formular echo ("
\n"); echo ("
" . _("Server settings") . ""); echo (""); // serverURL echo ("". "\n"); echo "\n"; $tabindex++; // new line echo (""); // tree suffix echo ("". "\n"); echo "\n"; $tabindex++; // new line echo (""); // LDAP cache timeout echo ("". "\n"); $tabindex++; echo "\n"; echo ("
" . _("Server address") . " *: ". "get_ServerURL() . "\">". ""; echo ""; echo "\"""; echo "\n"; echo "
 
". _("Tree suffix") . ": get_Suffix('tree') . "\">"; echo ""; echo "\"""; echo "\n"; echo "
 
". _("Cache timeout") . ": "; echo ""; echo "\"""; echo "\n"; echo "
"); echo ("
"); echo ("

"); echo ("
" . _("Account types and modules") . ""); // Account modules $types = $conf->get_ActiveTypes(); for ($i = 0; $i < sizeof($types); $i++) { echo "" . getTypeAlias($types[$i]) . ": " . implode(", ", $conf->get_AccountModules($types[$i])) . "
\n"; } echo "
\n"; echo "  "; $tabindex++; echo "  "; echo ""; echo "\"""; echo "\n"; $tabindex++; echo ("
"); echo ("

"); // module settings // get list of scopes of modules $scopes = array(); for ($m = 0; $m < sizeof($types); $m++) { $mods = $conf->get_AccountModules($types[$m]); for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; } // get module options $options = getConfigOptions($scopes); // get current setting $old_options = $conf->get_moduleSettings(); // get module descriptions $moduleDescriptions = getConfigDescriptions(); // display module boxes $modules = array_keys($options); $_SESSION['conf_types'] = array(); for ($i = 0; $i < sizeof($modules); $i++) { if (sizeof($options[$modules[$i]]) < 1) continue; echo "
\n"; echo "" . $moduleDescriptions['legend'][$modules[$i]] . "\n"; $configTypes = parseHtml($modules[$i], $options[$modules[$i]], $old_options, true, $tabindex, $tabindexLink, 'config'); $_SESSION['conf_types'] = array_merge($configTypes, $_SESSION['conf_types']); echo "
\n"; echo "
"; } echo ("
" . _("List settings") . "\n"); echo ("\n"); // maximum list entries echo ("". "\n"); $tabindex++; echo "\n"; echo ("
". _("Maximum list entries") . " : "; echo ""; echo "\"""; echo "\n"; echo "
\n"); echo ("
\n"); echo ("

\n"); echo ("
" . _("Language settings") . "\n"); echo ("\n"); // language echo (""); echo ("\n"); echo "\n"; echo ("
" . _("Default language") . ":\n"); // read available languages $languagefile = "../../config/language"; if(is_file($languagefile)) { $file = fopen($languagefile, "r"); $i = 0; while(!feof($file)) { $line = fgets($file, 1024); if($line == "\n" || $line[0] == "#" || $line == "") continue; // ignore comment and empty lines $languages[$i] = chop($line); $i++; } fclose($file); // generate language list echo ("\n"); $tabindex++; } else { echo _("Unable to load available languages. Setting English as default language. For further instructions please contact the Admin of this site."); } echo (""; echo ""; echo "\"""; echo "\n"; echo "
\n"); echo ("
\n"); echo ("

\n"); // script settings echo ("
" . _("Script settings") . "\n"); echo ("\n"); echo ("". "\n"); $tabindex++; echo "\n"; echo ("". "\n"); $tabindex++; echo "\n"; echo ("
". _("Server of external script") . ": get_scriptServer() . "\">"; echo ""; echo "\"""; echo "\n"; echo "
". _("Path to external script") . ": get_scriptPath() . "\">"; echo ""; echo "\"""; echo "\n"; echo "
\n"); echo ("
\n"); echo ("

\n"); // security setings echo ("
" . _("Security settings") . "\n"); echo ("\n"); // admin list echo ("". "\n"); echo "\n"; $tabindex++; echo ("\n"); // new password echo ("". "\n"); $tabindex++; echo "\n"; // reenter password echo ("". "\n"); $tabindex++; echo ("
". _("List of valid users") . " *: get_Adminstring() . "\">"; echo ""; echo "\"""; echo "\n"; echo "
 
". _("New Password") . ": "; echo ""; echo "\"""; echo "\n"; echo "
". _("Reenter Password") . ":
\n"); echo ("
\n"); echo ("

\n"); // buttons echo ("\n"); echo ""; echo "\n"); echo ("
";
	echo "";
	$tabindex++;
	echo " ";
	echo "
\n"); echo ("

"); echo ("

* = ". _("required") . "

"); echo ("

** = ". _("required for Samba 3 accounts") . "

"); // password for configuration echo ("

\n"); echo ("
\n"); echo ("\n"); echo ("\n"); /** * Saves the entered settings. * */ function saveSettings() { $conf = &$_SESSION['conf_config']; $types = $conf->get_ActiveTypes(); // remove double slashes if magic quotes are on if (get_magic_quotes_gpc() == 1) { $postKeys = array_keys($_POST); for ($i = 0; $i < sizeof($postKeys); $i++) { if (is_string($_POST[$postKeys[$i]])) $_POST[$postKeys[$i]] = stripslashes($_POST[$postKeys[$i]]); } } // check new preferences $errors = array(); if (!$conf->set_ServerURL($_POST['serverurl'])) { $errors[] = array("ERROR", _("Server address is invalid!")); } if (!$conf->set_cacheTimeout($_POST['cachetimeout'])) { $errors[] = array("ERROR", _("Cache timeout is invalid!")); } if (!$conf->set_Adminstring($_POST['admins'])) { $errors[] = array("ERROR", _("List of admin users is empty or invalid!")); } if (!$conf->set_Suffix("tree", $_POST['sufftree'])) { $errors[] = array("ERROR", _("TreeSuffix is invalid!")); } if (!$conf->set_MaxListEntries($_POST['maxlistentries'])) { $errors[] = array("ERROR", _("Max list entries is invalid!")); } if (!$conf->set_defaultLanguage($_POST['lang'])) { $errors[] = array("ERROR", _("Language is not defined!")); } if (!$conf->set_scriptpath($_POST['scriptpath'])) { $errors[] = array("ERROR", _("Script path is invalid!")); } if (!$conf->set_scriptserver($_POST['scriptserver'])) { $errors[] = array("ERROR", _("Script server is invalid!")); } // check if password was changed if (isset($_POST['passwd1']) && ($_POST['passwd1'] != '')) { if ($_POST['passwd1'] != $_POST['passwd2']) { $errors[] = array("ERROR", _("Passwords are different!")); } else { // set new password $conf->set_Passwd($_POST['passwd1']); } } // check module options // create option array to check and save $options = array(); $opt_keys = array_keys($_SESSION['conf_types']); for ($i = 0; $i < sizeof($opt_keys); $i++) { $element = $opt_keys[$i]; // text fields if ($_SESSION['conf_types'][$element] == "text") { $options[$element] = array($_POST[$element]); } // checkboxes elseif ($_SESSION['conf_types'][$element] == "checkbox") { if ($_POST[$element] == "on") $options[$element] = array('true'); else $options[$element] = array('false'); } // dropdownbox elseif ($_SESSION['conf_types'][$element] == "select") { $options[$element] = array($_POST[$element]); } // multiselect elseif ($_SESSION['conf_types'][$element] == "multiselect") { $options[$element] = $_POST[$element]; // value is already an array } } // get list of scopes of modules $scopes = array(); for ($m = 0; $m < sizeof($types); $m++) { $mods = $conf->get_AccountModules($types[$m]); for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; } // check options $errors = array_merge($errors, checkConfigOptions($scopes, $options)); // print error messages if any if (sizeof($errors) > 0) { $_SESSION['conf_errors'] = $errors; $conf->set_moduleSettings($options); } // save settings if no errors occured else { // page head echo $_SESSION['header']; echo "" . _("LDAP Account Manager Configuration") . "\n"; echo "\n"; echo "\n"; echo ("

". "\"LDAP




"); $conf->set_moduleSettings($options); $conf->save(); echo ("




" . _("Back to Login") . ""); echo(""); // 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]]); } exit(); } } ?>