better error handling
This commit is contained in:
parent
5ad9b1629f
commit
2840779c23
|
@ -82,18 +82,26 @@ if ($_POST['submit']) {
|
||||||
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['addprofile']) && !in_array($_POST['addprofile'], getConfigProfiles())) {
|
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['addprofile']) && !in_array($_POST['addprofile'], getConfigProfiles())) {
|
||||||
// check profile password
|
// check profile password
|
||||||
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
|
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
|
||||||
// create new profile file
|
// check if lam.conf_sample exists
|
||||||
@copy("../../config/lam.conf_sample", "../../config/" . $_POST['addprofile'] . ".conf");
|
if (!is_file("../../config/lam.conf_sample")) {
|
||||||
@chmod ("../../config/" . $_POST['addprofile'] . ".conf", 0600);
|
$error = _("The file config/lam.conf_sample was not found. Please restore it.");
|
||||||
$file = is_file("../../config/" . $_POST['addprofile'] . ".conf");
|
}
|
||||||
if ($file) {
|
else {
|
||||||
// load as config and write new password
|
// create new profile file
|
||||||
$conf = new LAMConfig($_POST['addprofile']);
|
@copy("../../config/lam.conf_sample", "../../config/" . $_POST['addprofile'] . ".conf");
|
||||||
$conf->set_Passwd($_POST['addpassword']);
|
@chmod ("../../config/" . $_POST['addprofile'] . ".conf", 0600);
|
||||||
$conf->save();
|
$file = is_file("../../config/" . $_POST['addprofile'] . ".conf");
|
||||||
$msg = _("Created new profile.");
|
if ($file) {
|
||||||
|
// load as config and write new password
|
||||||
|
$conf = new LAMConfig($_POST['addprofile']);
|
||||||
|
$conf->set_Passwd($_POST['addpassword']);
|
||||||
|
$conf->save();
|
||||||
|
$msg = _("Created new profile.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error = _("Unable to create new profile!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else $error = _("Unable to create new profile!");
|
|
||||||
}
|
}
|
||||||
else $error = _("Profile passwords are different or empty!");
|
else $error = _("Profile passwords are different or empty!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue