show login if settings were saved

This commit is contained in:
Roland Gruber 2010-05-28 08:48:57 +00:00
parent 6c80edaec1
commit 2af31b832b
2 changed files with 45 additions and 39 deletions

View File

@ -51,33 +51,13 @@ if (!isset($_SESSION["mainconf_password"]) || (!$cfg->checkPassword($_SESSION["m
exit(); exit();
} }
echo $_SESSION['header']; if (isset($_POST['cancel'])) {
// back to login
?> metaRefresh('../login.php');
exit();
<title>
<?php
echo _("Edit general settings");
?>
</title>
<link rel="stylesheet" type="text/css" href="../../style/layout.css">
<link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico">
</head>
<body>
<p align="center"><a href="http://www.ldap-account-manager.org/" target="_blank">
<img src="../../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
</p>
<hr><br>
<?php
// include all JavaScript files
$jsDirName = dirname(__FILE__) . '/../lib';
$jsDir = dir($jsDirName);
while ($jsEntry = $jsDir->read()) {
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
} }
$errors = array();
// check if submit button was pressed // check if submit button was pressed
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
// remove double slashes if magic quotes are on // remove double slashes if magic quotes are on
@ -87,7 +67,6 @@ if (isset($_POST['submit'])) {
if (is_string($_POST[$postKeys[$i]])) $_POST[$postKeys[$i]] = stripslashes($_POST[$postKeys[$i]]); if (is_string($_POST[$postKeys[$i]])) $_POST[$postKeys[$i]] = stripslashes($_POST[$postKeys[$i]]);
} }
} }
$errors = array();
// set master password // set master password
if (isset($_POST['masterpassword']) && ($_POST['masterpassword'] != "")) { if (isset($_POST['masterpassword']) && ($_POST['masterpassword'] != "")) {
if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) { if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) {
@ -140,18 +119,44 @@ if (isset($_POST['submit'])) {
$cfg->passwordMinClasses = $_POST['passwordMinClasses']; $cfg->passwordMinClasses = $_POST['passwordMinClasses'];
// save settings // save settings
$cfg->save(); $cfg->save();
// print messages if (sizeof($errors) == 0) {
if (sizeof($errors) > 0) { metaRefresh('../login.php?confMainSavedOk=1');
for ($i = 0; $i < sizeof($errors); $i++) StatusMessage("ERROR", $errors[$i]);
}
else {
StatusMessage("INFO", _("Your settings were successfully saved."));
// back to login page
echo "<p><a href=\"../login.php\">" . _("Back to login") . "</a></p>";
exit(); exit();
} }
} }
echo $_SESSION['header'];
?>
<title>
<?php
echo _("Edit general settings");
?>
</title>
<link rel="stylesheet" type="text/css" href="../../style/layout.css">
<link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico">
</head>
<body>
<p align="center"><a href="http://www.ldap-account-manager.org/" target="_blank">
<img src="../../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
</p>
<hr><br>
<?php
// include all JavaScript files
$jsDirName = dirname(__FILE__) . '/../lib';
$jsDir = dir($jsDirName);
while ($jsEntry = $jsDir->read()) {
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
}
// print messages
for ($i = 0; $i < sizeof($errors); $i++) {
StatusMessage("ERROR", $errors[$i]);
}
// check if config file is writable // check if config file is writable
if (!$cfg->isWritable()) { if (!$cfg->isWritable()) {
StatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'); StatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.');
@ -370,6 +375,7 @@ if (!$cfg->isWritable()) {
<?php if ($cfg->isWritable()) { ?> <?php if ($cfg->isWritable()) { ?>
<input type="submit" name="submit" value=" <?php echo _("Ok"); ?> "> <input type="submit" name="submit" value=" <?php echo _("Ok"); ?> ">
<?php } ?> <?php } ?>
<input type="submit" name="cancel" value=" <?php echo _("Cancel"); ?> ">
</TD> </TD>
</TR> </TR>
</table> </table>
@ -377,11 +383,6 @@ if (!$cfg->isWritable()) {
</form> </form>
<p><br></p> <p><br></p>
<!-- back to login page -->
<p>
<a href="../login.php"> <?php echo _("Back to login"); ?> </a>
</p>
</body> </body>
</html> </html>

View File

@ -206,6 +206,11 @@ function display_LoginPage($config_object) {
StatusMessage("ERROR", _("Your session expired, please log in again.")); StatusMessage("ERROR", _("Your session expired, please log in again."));
echo "<br>"; echo "<br>";
} }
// check if main config was saved
if (isset($_GET['confMainSavedOk'])) {
StatusMessage("INFO", _("Your settings were successfully saved."));
echo "<br>";
}
?> ?>
<div style="position:relative; z-index:5;"> <div style="position:relative; z-index:5;">
<table width="650" align="center" border="2" rules="none" bgcolor="white"> <table width="650" align="center" border="2" rules="none" bgcolor="white">