checkPassword($_POST['passwd'])) { $error = _("Master password is wrong!"); } // add new profile elseif ($_POST['action'] == "add") { // check profile password if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) { $result = createConfigProfile($_POST['addprofile'], $_POST['addpassword'], $_POST['addTemplate']); 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; } else { $error = $result; } } else { $error = _("Profile passwords are different or empty!"); } } // rename profile elseif ($_POST['action'] == "rename") { 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")) { // rename pdf and profiles folder rename("../../config/profiles/" . $_POST['oldfilename'], "../../config/profiles/" . $_POST['renfilename']); rename("../../config/pdf/" . $_POST['oldfilename'], "../../config/pdf/" . $_POST['renfilename']); // rename sqlite database if any if (file_exists("../../config/" . $_POST['oldfilename'] . ".sqlite")) { rename("../../config/" . $_POST['oldfilename'] . ".sqlite", "../../config/" . $_POST['renfilename'] . ".sqlite"); } $msg = _("Renamed profile."); } else $error = _("Could not rename file!"); // update default profile setting if needed if ($cfg->default == $_POST['oldfilename']) { $cfg->default = $_POST['renfilename']; $cfg->save(); } // reread profile list $files = getConfigProfiles(); } else $error = _("Profile name is invalid!"); } // delete profile elseif ($_POST['action'] == "delete") { if (deleteConfigProfile($_POST['delfilename']) == null) { $msg = _("Profile deleted."); // 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(); } } // reread profile list $files = getConfigProfiles(); } else $error = _("Unable to delete profile!"); } // set new profile password elseif ($_POST['action'] == "setpass") { 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!"); } else $error = _("Profile name is invalid!"); } // set default profile elseif ($_POST['action'] == "setdefault") { 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!"); } } echo $_SESSION['header']; printHeaderContents(_("Profile management"), '../..'); ?>
LDAP Account Manager |