config fixes

This commit is contained in:
Roland Gruber 2016-01-02 14:28:03 +00:00
parent 7c0cada014
commit c677a10b6d
2 changed files with 16 additions and 11 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2015 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -177,13 +177,14 @@ function createConfigProfile($name, $password, $template) {
if (!preg_match("/^[a-z0-9_-]+$/i", $name) || !preg_match("/^[a-z0-9\\._-]+$/i", $template) || in_array($name, getConfigProfiles())) { if (!preg_match("/^[a-z0-9_-]+$/i", $name) || !preg_match("/^[a-z0-9\\._-]+$/i", $template) || in_array($name, getConfigProfiles())) {
return _("Profile name is invalid!"); return _("Profile name is invalid!");
} }
$dir = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/";
// check if template exists // check if template exists
if (!is_file("../../config/" . $template)) { if (!is_file($dir . $template)) {
return "The file config/$template was not found. Please restore it."; return "The file config/$template was not found. Please restore it.";
} }
// create new profile file // create new profile file
$path = "../../config/" . $name . ".conf"; $path = $dir . $name . ".conf";
@copy("../../config/$template", $path); @copy($dir . $template, $path);
@chmod ($path, 0600); @chmod ($path, 0600);
$file = is_file($path); $file = is_file($path);
if ($file) { if ($file) {

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2015 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -89,6 +89,8 @@ if (isset($_POST['action'])) {
$cfg->default = $_POST['renfilename']; $cfg->default = $_POST['renfilename'];
$cfg->save(); $cfg->save();
} }
// reread profile list
$files = getConfigProfiles();
} }
else $error = _("Profile name is invalid!"); else $error = _("Profile name is invalid!");
} }
@ -105,6 +107,8 @@ if (isset($_POST['action'])) {
$cfg->save(); $cfg->save();
} }
} }
// reread profile list
$files = getConfigProfiles();
} }
else $error = _("Unable to delete profile!"); else $error = _("Unable to delete profile!");
} }