2003-07-06 10:22:23 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
$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.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2004-06-02 12:48:54 +00:00
|
|
|
*/
|
2003-07-06 10:22:23 +00:00
|
|
|
|
2004-06-02 12:48:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration profile management.
|
|
|
|
*
|
|
|
|
* @package configuration
|
|
|
|
* @author Roland Gruber
|
2003-07-06 10:22:23 +00:00
|
|
|
*/
|
|
|
|
|
2004-06-02 12:48:54 +00:00
|
|
|
|
|
|
|
/** Access to config functions */
|
2003-07-06 10:22:23 +00:00
|
|
|
include_once('../../lib/config.inc');
|
2004-06-02 12:48:54 +00:00
|
|
|
/** Used to print status messages */
|
2003-07-06 10:22:23 +00:00
|
|
|
include_once('../../lib/status.inc');
|
|
|
|
|
|
|
|
// start session
|
|
|
|
session_save_path("../../sess");
|
|
|
|
@session_start();
|
|
|
|
|
2003-07-06 17:54:11 +00:00
|
|
|
setlanguage();
|
|
|
|
|
2003-07-29 11:52:26 +00:00
|
|
|
echo $_SESSION['header'];
|
2003-07-06 10:22:23 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<title>
|
|
|
|
<?php
|
|
|
|
echo _("Profile management");
|
|
|
|
?>
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../style/layout.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
2005-12-05 19:09:04 +00:00
|
|
|
<p align="center"><a href="http://lam.sourceforge.net" target="_blank">
|
2003-07-06 10:22:23 +00:00
|
|
|
<img src="../../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
|
|
|
|
</p>
|
|
|
|
<hr><br>
|
|
|
|
|
2003-09-01 21:28:26 +00:00
|
|
|
<?php
|
2003-07-06 10:22:23 +00:00
|
|
|
|
2004-10-07 10:16:53 +00:00
|
|
|
$cfg = new CfgMain();
|
2003-07-06 10:22:23 +00:00
|
|
|
// check if submit button was pressed
|
|
|
|
if ($_POST['submit']) {
|
|
|
|
// check master password
|
|
|
|
if ($cfg->password != $_POST['passwd']) {
|
|
|
|
$error = _("Master password is wrong!");
|
|
|
|
}
|
|
|
|
// add new profile
|
|
|
|
elseif ($_POST['action'] == "add") {
|
|
|
|
if (eregi("^[a-z0-9\-_]+$", $_POST['addprofile']) && !in_array($_POST['addprofile'], getConfigProfiles())) {
|
|
|
|
// check profile password
|
|
|
|
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
|
|
|
|
// create new profile file
|
2003-07-28 14:37:21 +00:00
|
|
|
@copy("../../config/lam.conf_sample", "../../config/" . $_POST['addprofile'] . ".conf");
|
2003-07-06 10:22:23 +00:00
|
|
|
@chmod ("../../config/" . $_POST['addprofile'] . ".conf", 0600);
|
2003-07-28 14:37:21 +00:00
|
|
|
$file = is_file("../../config/" . $_POST['addprofile'] . ".conf");
|
2003-07-06 10:22:23 +00:00
|
|
|
if ($file) {
|
2003-07-28 14:37:21 +00:00
|
|
|
// load as config and write new password
|
|
|
|
$conf = new Config($_POST['addprofile']);
|
|
|
|
$conf->Passwd = $_POST['addpassword'];
|
|
|
|
$conf->save();
|
2003-07-06 10:22:23 +00:00
|
|
|
$msg = _("Created new profile.");
|
|
|
|
}
|
|
|
|
else $error = _("Unable to create new profile!");
|
|
|
|
}
|
|
|
|
else $error = _("Profile passwords are different or empty!");
|
|
|
|
}
|
|
|
|
else $error = _("Profile name is invalid!");
|
|
|
|
}
|
|
|
|
// rename profile
|
|
|
|
elseif ($_POST['action'] == "rename") {
|
|
|
|
if (eregi("^[a-z0-9\-_]+$", $_POST['renfilename']) && !in_array($_POST['renprofile'], getConfigProfiles())) {
|
|
|
|
if (rename("../../config/" . $_POST['oldfilename'] . ".conf",
|
|
|
|
"../../config/" . $_POST['renfilename'] . ".conf")) {
|
|
|
|
$msg = _("Renamed profile.");
|
|
|
|
}
|
|
|
|
else $error = _("Could not rename file!");
|
|
|
|
}
|
|
|
|
else $error = _("Profile name is invalid!");
|
|
|
|
}
|
|
|
|
// delete profile
|
|
|
|
elseif ($_POST['action'] == "delete") {
|
|
|
|
if (@unlink("../../config/" . $_POST['delfilename'] . ".conf")) {
|
|
|
|
$msg = _("Profile deleted.");
|
|
|
|
}
|
|
|
|
else $error = _("Unable to delete profile!");
|
|
|
|
}
|
|
|
|
// set new profile password
|
|
|
|
elseif ($_POST['action'] == "setpass") {
|
|
|
|
if ($_POST['setpassword'] && $_POST['setpassword2'] && ($_POST['setpassword'] == $_POST['setpassword2'])) {
|
|
|
|
$config = new Config($_POST['setprofile']);
|
|
|
|
$config->set_Passwd($_POST['setpassword']);
|
|
|
|
$config->save();
|
|
|
|
$msg = _("New password set successfully.");
|
|
|
|
}
|
|
|
|
else $error = _("Profile passwords are different or empty!");
|
|
|
|
}
|
|
|
|
// set master password
|
|
|
|
elseif ($_POST['action'] == "setmasterpass") {
|
|
|
|
if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) {
|
|
|
|
$config = new CfgMain();
|
|
|
|
$config->password = $_POST['masterpassword'];
|
|
|
|
$config->save();
|
|
|
|
$msg = _("New master password set successfully.");
|
|
|
|
}
|
|
|
|
else $error = _("Master passwords are different or empty!");
|
|
|
|
}
|
|
|
|
// set default profile
|
|
|
|
elseif ($_POST['action'] == "setdefault") {
|
|
|
|
$config = new CfgMain();
|
|
|
|
$config->default = $_POST['defaultfilename'];
|
|
|
|
$config->save();
|
|
|
|
$msg = _("New default profile set successfully.");
|
|
|
|
}
|
|
|
|
// print messages
|
|
|
|
if ($error || $msg) {
|
|
|
|
if ($error) StatusMessage("ERROR", "", $error);
|
|
|
|
if ($msg) StatusMessage("INFO", "", $msg);
|
|
|
|
}
|
|
|
|
else exit;
|
|
|
|
}
|
|
|
|
|
2004-10-07 10:16:53 +00:00
|
|
|
|
|
|
|
// check if config.cfg is valid
|
|
|
|
if (!isset($cfg->default) && !isset($cfg->password)) {
|
|
|
|
StatusMessage("ERROR", _("Please set up your master configuration file (config/config.cfg) first!"), "");
|
|
|
|
echo "</body>\n</html>\n";
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2003-07-06 10:22:23 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
<br>
|
|
|
|
<!-- form for adding/renaming/deleting profiles -->
|
|
|
|
<form action="profmanage.php" method="post">
|
2003-09-24 20:28:23 +00:00
|
|
|
<table>
|
|
|
|
<tr><td>
|
2003-07-06 10:22:23 +00:00
|
|
|
<fieldset>
|
2003-08-02 09:05:47 +00:00
|
|
|
<legend><b> <?php echo _("Profile management"); ?> </b></legend>
|
2003-07-06 10:22:23 +00:00
|
|
|
<p>
|
2003-09-24 20:28:23 +00:00
|
|
|
<table cellspacing=0 border=0>
|
2003-07-06 10:22:23 +00:00
|
|
|
|
|
|
|
<!-- add profile -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="add" checked>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<b>
|
2003-09-22 19:18:16 +00:00
|
|
|
<?php echo _("Add profile") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</b>
|
2003-09-24 20:28:23 +00:00
|
|
|
</td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Profile name") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="text" name="addprofile">
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=230\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-09-24 20:28:23 +00:00
|
|
|
<td> </td>
|
|
|
|
<td> </td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Profile password") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="password" name="addpassword">
|
2003-09-24 20:28:23 +00:00
|
|
|
</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-09-24 20:28:23 +00:00
|
|
|
<td> </td>
|
|
|
|
<td> </td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Reenter profile password") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="password" name="addpassword2">
|
|
|
|
</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<!-- rename profile -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="rename">
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<select size=1 name="oldfilename">
|
|
|
|
<?php
|
|
|
|
$files = getConfigProfiles();
|
|
|
|
for ($i = 0; $i < sizeof($files); $i++) echo ("<option>" . $files[$i] . "</option>\n");
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<b>
|
2003-09-24 20:28:23 +00:00
|
|
|
<?php echo _("Rename profile"); ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</b>
|
2003-09-24 20:28:23 +00:00
|
|
|
</td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Profile name") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="text" name="renfilename">
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=231\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<!-- delete profile -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="delete">
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=2>
|
2003-07-06 10:22:23 +00:00
|
|
|
<select size=1 name="delfilename">
|
|
|
|
<?php
|
|
|
|
$files = getConfigProfiles();
|
|
|
|
for ($i = 0; $i < sizeof($files); $i++) echo ("<option>" . $files[$i] . "</option>\n");
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<b>
|
|
|
|
<?php echo _("Delete profile"); ?>
|
|
|
|
</b>
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=232\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<!-- set profile password -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="setpass">
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<select size=1 name="setprofile">
|
|
|
|
<?php
|
|
|
|
$files = getConfigProfiles();
|
|
|
|
for ($i = 0; $i < sizeof($files); $i++) echo ("<option>" . $files[$i] . "</option>\n");
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<b>
|
|
|
|
<?php echo _("Set profile password"); ?>
|
|
|
|
</b>
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Profile password") . ":"; ?>
|
|
|
|
<input type="password" name="setpassword">
|
|
|
|
</td>
|
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=233\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-09-24 20:28:23 +00:00
|
|
|
<td> </td>
|
|
|
|
<td> </td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Reenter profile password") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="password" name="setpassword2">
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
2003-07-06 10:22:23 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<!-- change default profile -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="setdefault">
|
|
|
|
</td>
|
2003-10-13 17:35:49 +00:00
|
|
|
<td>
|
2003-07-06 10:22:23 +00:00
|
|
|
<select size=1 name="defaultfilename">
|
|
|
|
<?php
|
|
|
|
$files = getConfigProfiles();
|
|
|
|
$conf = new CfgMain();
|
|
|
|
$defaultprofile = $conf->default;
|
|
|
|
for ($i = 0; $i < sizeof($files); $i++) {
|
|
|
|
if ($files[$i] == $defaultprofile) echo ("<option selected>" . $files[$i] . "</option>\n");
|
|
|
|
else echo ("<option>" . $files[$i] . "</option>\n");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<b>
|
|
|
|
<?php echo _("Change default profile"); ?>
|
|
|
|
</b>
|
|
|
|
</td>
|
2003-10-13 17:35:49 +00:00
|
|
|
<td> </td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=234\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td colspan=4> </td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<!-- set master password -->
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-07-06 10:22:23 +00:00
|
|
|
<td>
|
|
|
|
<input type="radio" name="action" value="setmasterpass">
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<b>
|
|
|
|
<?php echo _("Change master password"); ?>
|
|
|
|
</b>
|
2003-09-24 20:28:23 +00:00
|
|
|
</td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("New master password") . ":"; ?>
|
2003-07-06 10:22:23 +00:00
|
|
|
<input type="password" name="masterpassword">
|
|
|
|
</td>
|
2003-09-24 20:28:23 +00:00
|
|
|
<td>
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=235\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2003-10-13 17:35:49 +00:00
|
|
|
<tr bgcolor="#dbdbff">
|
2003-09-24 20:28:23 +00:00
|
|
|
<td> </td>
|
|
|
|
<td> </td>
|
|
|
|
<td align="right">
|
|
|
|
<?php echo _("Reenter new master password") . ":"; ?>
|
|
|
|
<input type="password" name="masterpassword2">
|
|
|
|
</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
2003-07-06 10:22:23 +00:00
|
|
|
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
2003-09-24 20:28:23 +00:00
|
|
|
</td></tr>
|
|
|
|
</table>
|
2003-07-06 10:22:23 +00:00
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<!-- password field and submit button -->
|
|
|
|
<b>
|
|
|
|
<?php echo _("Master Password:"); ?>
|
|
|
|
</b>
|
|
|
|
 
|
|
|
|
<input type="password" name="passwd">
|
|
|
|
 
|
|
|
|
<input type="submit" name="submit" value=" <?php echo _("Submit"); ?> ">
|
2003-09-22 19:18:16 +00:00
|
|
|
 
|
2005-04-24 19:41:39 +00:00
|
|
|
<?PHP
|
|
|
|
// help link
|
|
|
|
echo "<a href=\"../help.php?HelpNumber=236\" target=\"lamhelp\">";
|
|
|
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
|
|
|
echo "</a>\n";
|
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
|
|
|
|
</form>
|
|
|
|
<p><br></p>
|
|
|
|
|
|
|
|
<!-- back to login page -->
|
|
|
|
<p>
|
|
|
|
<a href="conflogin.php"> <?php echo _("Back to profile login"); ?> </a>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|