2003-07-06 10:22:23 +00:00
|
|
|
<?php
|
2017-11-05 09:49:33 +00:00
|
|
|
namespace LAM\CONFIG;
|
|
|
|
use \LAMCfgMain;
|
|
|
|
use \LAMConfig;
|
|
|
|
use \htmlStatusMessage;
|
|
|
|
use \htmlResponsiveRow;
|
|
|
|
use \htmlTitle;
|
|
|
|
use \htmlSubTitle;
|
|
|
|
use \htmlResponsiveInputField;
|
|
|
|
use \htmlResponsiveSelect;
|
|
|
|
use \htmlButton;
|
|
|
|
use \htmlOutputText;
|
|
|
|
use \htmlHiddenInput;
|
|
|
|
use \htmlDiv;
|
|
|
|
use \htmlLink;
|
2003-07-06 10:22:23 +00:00
|
|
|
/*
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2019-05-12 07:50:23 +00:00
|
|
|
Copyright (C) 2003 - 2019 Roland Gruber
|
2003-07-06 10:22:23 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2006-09-24 14:19:50 +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
|
2009-07-08 18:03:28 +00:00
|
|
|
if (strtolower(session_module_name()) == 'files') {
|
|
|
|
session_save_path("../../sess");
|
|
|
|
}
|
2018-03-10 17:48:11 +00:00
|
|
|
lam_start_session();
|
2003-07-06 10:22:23 +00:00
|
|
|
|
2003-07-06 17:54:11 +00:00
|
|
|
setlanguage();
|
|
|
|
|
2003-07-06 10:22:23 +00:00
|
|
|
|
2006-09-24 14:19:50 +00:00
|
|
|
$cfg = new LAMCfgMain();
|
2013-01-12 11:28:43 +00:00
|
|
|
$files = getConfigProfiles();
|
|
|
|
|
2003-07-06 10:22:23 +00:00
|
|
|
// check if submit button was pressed
|
2012-01-14 13:24:57 +00:00
|
|
|
if (isset($_POST['action'])) {
|
2003-07-06 10:22:23 +00:00
|
|
|
// check master password
|
2007-11-07 21:02:13 +00:00
|
|
|
if (!$cfg->checkPassword($_POST['passwd'])) {
|
2003-07-06 10:22:23 +00:00
|
|
|
$error = _("Master password is wrong!");
|
|
|
|
}
|
|
|
|
// add new profile
|
|
|
|
elseif ($_POST['action'] == "add") {
|
2014-12-22 20:21:54 +00:00
|
|
|
// check profile password
|
|
|
|
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
|
2014-12-25 07:31:04 +00:00
|
|
|
$result = createConfigProfile($_POST['addprofile'], $_POST['addpassword'], $_POST['addTemplate']);
|
2014-12-22 20:21:54 +00:00
|
|
|
if ($result === true) {
|
|
|
|
$_SESSION['conf_isAuthenticated'] = $_POST['addprofile'];
|
|
|
|
$_SESSION['conf_config'] = new LAMConfig($_POST['addprofile']);
|
|
|
|
$_SESSION['conf_messages'][] = array('INFO', _("Created new profile."), $_POST['addprofile']);
|
|
|
|
metaRefresh('confmain.php');
|
|
|
|
exit;
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
2014-12-22 20:21:54 +00:00
|
|
|
else {
|
|
|
|
$error = $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$error = _("Profile passwords are different or empty!");
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// rename profile
|
|
|
|
elseif ($_POST['action'] == "rename") {
|
2011-02-18 19:15:43 +00:00
|
|
|
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['oldfilename']) && preg_match("/^[a-z0-9_-]+$/i", $_POST['renfilename']) && !in_array($_POST['renfilename'], getConfigProfiles())) {
|
|
|
|
if (rename("../../config/" . $_POST['oldfilename'] . ".conf", "../../config/" . $_POST['renfilename'] . ".conf")) {
|
2012-10-28 14:37:54 +00:00
|
|
|
// rename pdf and profiles folder
|
|
|
|
rename("../../config/profiles/" . $_POST['oldfilename'], "../../config/profiles/" . $_POST['renfilename']);
|
|
|
|
rename("../../config/pdf/" . $_POST['oldfilename'], "../../config/pdf/" . $_POST['renfilename']);
|
2016-03-28 07:25:21 +00:00
|
|
|
// rename sqlite database if any
|
|
|
|
if (file_exists("../../config/" . $_POST['oldfilename'] . ".sqlite")) {
|
|
|
|
rename("../../config/" . $_POST['oldfilename'] . ".sqlite", "../../config/" . $_POST['renfilename'] . ".sqlite");
|
|
|
|
}
|
2003-07-06 10:22:23 +00:00
|
|
|
$msg = _("Renamed profile.");
|
|
|
|
}
|
|
|
|
else $error = _("Could not rename file!");
|
2011-02-18 19:15:43 +00:00
|
|
|
// update default profile setting if needed
|
|
|
|
if ($cfg->default == $_POST['oldfilename']) {
|
|
|
|
$cfg->default = $_POST['renfilename'];
|
|
|
|
$cfg->save();
|
|
|
|
}
|
2016-01-02 14:28:03 +00:00
|
|
|
// reread profile list
|
|
|
|
$files = getConfigProfiles();
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
|
|
|
else $error = _("Profile name is invalid!");
|
|
|
|
}
|
|
|
|
// delete profile
|
|
|
|
elseif ($_POST['action'] == "delete") {
|
2012-10-28 14:37:54 +00:00
|
|
|
if (deleteConfigProfile($_POST['delfilename']) == null) {
|
2003-07-06 10:22:23 +00:00
|
|
|
$msg = _("Profile deleted.");
|
2013-01-12 11:28:43 +00:00
|
|
|
// update default profile setting if needed
|
|
|
|
if ($cfg->default == $_POST['delfilename']) {
|
|
|
|
$filesNew = array_delete(array($_POST['delfilename']), $files);
|
|
|
|
if (sizeof($filesNew) > 0) {
|
|
|
|
sort($filesNew);
|
|
|
|
$cfg->default = $filesNew[0];
|
|
|
|
$cfg->save();
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 14:28:03 +00:00
|
|
|
// reread profile list
|
|
|
|
$files = getConfigProfiles();
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
|
|
|
else $error = _("Unable to delete profile!");
|
|
|
|
}
|
|
|
|
// set new profile password
|
|
|
|
elseif ($_POST['action'] == "setpass") {
|
2012-03-13 21:02:37 +00:00
|
|
|
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['setprofile'])) {
|
|
|
|
if ($_POST['setpassword'] && $_POST['setpassword2'] && ($_POST['setpassword'] == $_POST['setpassword2'])) {
|
|
|
|
$config = new LAMConfig($_POST['setprofile']);
|
|
|
|
$config->set_Passwd($_POST['setpassword']);
|
|
|
|
$config->save();
|
|
|
|
$config = null;
|
|
|
|
$msg = _("New password set successfully.");
|
|
|
|
}
|
|
|
|
else $error = _("Profile passwords are different or empty!");
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
2012-03-13 21:02:37 +00:00
|
|
|
else $error = _("Profile name is invalid!");
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
|
|
|
// set default profile
|
|
|
|
elseif ($_POST['action'] == "setdefault") {
|
2012-03-13 21:02:37 +00:00
|
|
|
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['defaultfilename'])) {
|
|
|
|
$configMain = new LAMCfgMain();
|
|
|
|
$configMain->default = $_POST['defaultfilename'];
|
|
|
|
$configMain->save();
|
|
|
|
$configMain = null;
|
|
|
|
$msg = _("New default profile set successfully.");
|
|
|
|
}
|
|
|
|
else $error = _("Profile name is invalid!");
|
2003-07-06 10:22:23 +00:00
|
|
|
}
|
2011-12-10 09:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo $_SESSION['header'];
|
2017-11-05 09:49:33 +00:00
|
|
|
printHeaderContents(_("Profile management"), '../..');
|
2011-12-10 09:08:27 +00:00
|
|
|
?>
|
|
|
|
</head>
|
2017-11-05 09:49:33 +00:00
|
|
|
<body class="admin">
|
2011-12-10 09:08:27 +00:00
|
|
|
<table border=0 width="100%" class="lamHeader ui-corner-all">
|
|
|
|
<tr>
|
|
|
|
<td align="left" height="30">
|
2019-05-12 07:50:23 +00:00
|
|
|
<a class="lamLogo" href="http://www.ldap-account-manager.org/" target="new_window">
|
|
|
|
<?php echo getLAMVersionText(); ?>
|
|
|
|
</a>
|
2011-12-10 09:08:27 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// include all JavaScript files
|
2017-11-05 09:49:33 +00:00
|
|
|
printJsIncludes('../..');
|
2004-10-07 10:16:53 +00:00
|
|
|
|
2003-07-06 10:22:23 +00:00
|
|
|
?>
|
|
|
|
<br>
|
|
|
|
<!-- form for adding/renaming/deleting profiles -->
|
2012-01-14 13:24:57 +00:00
|
|
|
<form id="profileForm" name="profileForm" action="profmanage.php" method="post">
|
|
|
|
<?php
|
|
|
|
$tabindex = 1;
|
|
|
|
|
2017-11-05 09:49:33 +00:00
|
|
|
$row = new htmlResponsiveRow();
|
|
|
|
|
|
|
|
// print messages
|
|
|
|
if (isset($error)) {
|
|
|
|
$row->add(new htmlStatusMessage('ERROR', $error), 12);
|
|
|
|
$row->addVerticalSpacer('1rem');
|
|
|
|
}
|
|
|
|
if (isset($msg)) {
|
|
|
|
$row->add(new htmlStatusMessage('INFO', $msg), 12);
|
|
|
|
$row->addVerticalSpacer('1rem');
|
|
|
|
}
|
|
|
|
|
|
|
|
$box = new htmlResponsiveRow();
|
|
|
|
$box->add(new htmlTitle(_("Profile management")), 12);
|
2012-01-14 13:24:57 +00:00
|
|
|
|
|
|
|
// new profile
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add(new htmlSubTitle(_("Add profile")), 12);
|
|
|
|
$newProfileInput = new htmlResponsiveInputField(_("Profile name"), 'addprofile', null, '230');
|
|
|
|
$box->add($newProfileInput, 12);
|
|
|
|
$profileNewPwd1 = new htmlResponsiveInputField(_("Profile password"), 'addpassword');
|
2012-01-14 13:24:57 +00:00
|
|
|
$profileNewPwd1->setIsPassword(true);
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add($profileNewPwd1, 12);
|
|
|
|
$profileNewPwd2 = new htmlResponsiveInputField(_("Reenter password"), 'addpassword2');
|
2012-01-14 13:24:57 +00:00
|
|
|
$profileNewPwd2->setIsPassword(true);
|
2014-05-25 14:37:05 +00:00
|
|
|
$profileNewPwd2->setSameValueFieldID('addpassword');
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add($profileNewPwd2, 12);
|
2014-12-25 07:31:04 +00:00
|
|
|
$existing = array();
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$existing[$file] = $file . '.conf';
|
|
|
|
}
|
|
|
|
$builtIn = array();
|
|
|
|
foreach (getConfigTemplates() as $file) {
|
|
|
|
$builtIn[$file] = $file . '.conf.sample';
|
|
|
|
}
|
|
|
|
$templates = array(
|
2015-01-01 16:34:04 +00:00
|
|
|
_('Built-in templates') => $builtIn,
|
2014-12-25 07:31:04 +00:00
|
|
|
_('Existing server profiles') => $existing,
|
|
|
|
);
|
2017-11-05 09:49:33 +00:00
|
|
|
$addTemplateSelect = new htmlResponsiveSelect('addTemplate', $templates, array('unix.conf.sample'), _('Template'), '267');
|
2014-12-25 07:31:04 +00:00
|
|
|
$addTemplateSelect->setContainsOptgroups(true);
|
|
|
|
$addTemplateSelect->setHasDescriptiveElements(true);
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add($addTemplateSelect, 12);
|
|
|
|
$box->addVerticalSpacer('0.5rem');
|
2012-01-14 13:24:57 +00:00
|
|
|
$newProfileButton = new htmlButton('btnAddProfile', _('Add'));
|
2016-01-02 14:28:03 +00:00
|
|
|
$newProfileButton->setOnClick("jQuery('#action').val('add');showConfirmationDialog('" . _("Add profile") . "', '" .
|
2013-01-15 18:42:00 +00:00
|
|
|
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->addLabel($newProfileButton);
|
|
|
|
$box->add(new htmlOutputText(''), 0, 6);
|
2012-01-14 13:24:57 +00:00
|
|
|
|
|
|
|
// rename profile
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add(new htmlSubTitle(_("Rename profile")), 12);
|
|
|
|
$box->add(new htmlResponsiveSelect('oldfilename', $files, array(), _('Profile name'), '231'), 12);
|
|
|
|
$oldProfileInput = new htmlResponsiveInputField(_('New profile name'), 'renfilename');
|
|
|
|
$box->add($oldProfileInput, 12);
|
|
|
|
$box->addVerticalSpacer('0.5rem');
|
2012-01-14 13:24:57 +00:00
|
|
|
$renameProfileButton = new htmlButton('btnRenameProfile', _('Rename'));
|
2016-01-02 14:28:03 +00:00
|
|
|
$renameProfileButton->setOnClick("jQuery('#action').val('rename');showConfirmationDialog('" . _("Rename profile") . "', '" .
|
2013-01-15 18:42:00 +00:00
|
|
|
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->addLabel($renameProfileButton);
|
|
|
|
$box->add(new htmlOutputText(''), 0, 6);
|
2012-01-14 13:24:57 +00:00
|
|
|
|
|
|
|
// delete profile
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add(new htmlSubTitle(_("Delete profile")), 12);
|
|
|
|
$box->add(new htmlResponsiveSelect('delfilename', $files, array(), _('Profile name'), '232'), 12);
|
|
|
|
$box->addVerticalSpacer('0.5rem');
|
2012-01-14 13:24:57 +00:00
|
|
|
$deleteProfileButton = new htmlButton('btnDeleteProfile', _('Delete'));
|
2016-01-02 14:28:03 +00:00
|
|
|
$deleteProfileButton->setOnClick("jQuery('#action').val('delete');showConfirmationDialog('" . _("Delete profile") . "', '" .
|
2013-01-15 18:42:00 +00:00
|
|
|
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->addLabel($deleteProfileButton);
|
|
|
|
$box->add(new htmlOutputText(''), 0, 6);
|
2012-01-14 13:24:57 +00:00
|
|
|
|
|
|
|
// set password
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add(new htmlSubTitle(_("Set profile password")), 12);
|
|
|
|
$box->add(new htmlResponsiveSelect('setprofile', $files, array(), _('Profile name'), '233'), 12);
|
|
|
|
$profileSetPwd1 = new htmlResponsiveInputField(_("Profile password"), 'setpassword');
|
2012-01-14 13:24:57 +00:00
|
|
|
$profileSetPwd1->setIsPassword(true);
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add($profileSetPwd1, 12);
|
|
|
|
$profileSetPwd2 = new htmlResponsiveInputField(_("Reenter password"), 'setpassword2');
|
2012-01-14 13:24:57 +00:00
|
|
|
$profileSetPwd2->setIsPassword(true);
|
2014-05-25 14:37:05 +00:00
|
|
|
$profileSetPwd2->setSameValueFieldID('setpassword');
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add($profileSetPwd2, 12);
|
|
|
|
$box->addVerticalSpacer('0.5rem');
|
2012-01-14 13:24:57 +00:00
|
|
|
$setPasswordProfileButton = new htmlButton('btnSetPasswordProfile', _('Set profile password'));
|
2016-01-02 14:28:03 +00:00
|
|
|
$setPasswordProfileButton->setOnClick("jQuery('#action').val('setpass');showConfirmationDialog('" . _("Set profile password") . "', '" .
|
2017-11-05 09:49:33 +00:00
|
|
|
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");
|
|
|
|
$box->addLabel($setPasswordProfileButton, 12);
|
|
|
|
$box->add(new htmlOutputText(''), 0, 6);
|
|
|
|
|
2012-01-14 13:24:57 +00:00
|
|
|
|
|
|
|
// set default profile
|
|
|
|
$conf = new LAMCfgMain();
|
|
|
|
$defaultprofile = $conf->default;
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->add(new htmlSubTitle(_("Change default profile")), 12);
|
|
|
|
$box->add(new htmlResponsiveSelect('defaultfilename', $files, array($defaultprofile), _('Profile name'), '234'), 12);
|
|
|
|
$box->addVerticalSpacer('0.5rem');
|
2012-01-14 13:24:57 +00:00
|
|
|
$defaultProfileButton = new htmlButton('btnDefaultProfile', _('Ok'));
|
2016-01-02 14:28:03 +00:00
|
|
|
$defaultProfileButton->setOnClick("jQuery('#action').val('setdefault');showConfirmationDialog('" . _("Change default profile") . "', '" .
|
2013-01-15 18:42:00 +00:00
|
|
|
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");
|
2017-11-05 09:49:33 +00:00
|
|
|
$box->addLabel($defaultProfileButton);
|
|
|
|
$box->add(new htmlOutputText(''), 0, 6);
|
|
|
|
|
|
|
|
$boxDiv = new htmlDiv(null, $box);
|
|
|
|
$boxDiv->setCSSClasses(array('ui-corner-all', 'roundedShadowBox', 'limitWidth'));
|
|
|
|
$row->add($boxDiv, 12);
|
2012-01-14 13:24:57 +00:00
|
|
|
|
2017-11-05 09:49:33 +00:00
|
|
|
$row->add(new htmlHiddenInput('action', 'none'), 12);
|
2013-01-12 16:33:42 +00:00
|
|
|
|
2017-11-05 09:49:33 +00:00
|
|
|
// dialog
|
|
|
|
$dialogDivContent = new htmlResponsiveRow();
|
|
|
|
$masterPassword = new htmlResponsiveInputField(_("Master password"), 'passwd', '', '236');
|
2013-01-12 16:33:42 +00:00
|
|
|
$masterPassword->setIsPassword(true);
|
2017-11-05 09:49:33 +00:00
|
|
|
$dialogDivContent->add($masterPassword, 12);
|
2013-01-12 16:33:42 +00:00
|
|
|
$dialogDiv = new htmlDiv('passwordDialogDiv', $dialogDivContent);
|
|
|
|
$dialogDiv->setCSSClasses(array('hidden'));
|
2017-11-05 09:49:33 +00:00
|
|
|
$row->add($dialogDiv, 12);
|
2013-01-12 16:33:42 +00:00
|
|
|
|
2017-11-05 09:49:33 +00:00
|
|
|
$row->addVerticalSpacer('2rem');
|
|
|
|
$backLink = new htmlLink(_("Back to profile login"), 'conflogin.php', '../../graphics/undo.png');
|
|
|
|
$row->add($backLink, 12, 12, 12, 'text-left');
|
2013-01-15 18:58:33 +00:00
|
|
|
|
2017-11-05 09:49:33 +00:00
|
|
|
parseHtml('', new htmlDiv(null, $row, array('centeredTable')), array(), false, $tabindex, 'user');
|
2003-07-06 10:22:23 +00:00
|
|
|
|
2012-01-14 13:24:57 +00:00
|
|
|
?>
|
2003-07-06 10:22:23 +00:00
|
|
|
</form>
|
|
|
|
<p><br></p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|