better error handling

This commit is contained in:
Roland Gruber 2010-07-23 11:12:59 +00:00
parent 5ad9b1629f
commit 2840779c23
1 changed files with 19 additions and 11 deletions

View File

@ -82,6 +82,11 @@ if ($_POST['submit']) {
if (preg_match("/^[a-z0-9_-]+$/i", $_POST['addprofile']) && !in_array($_POST['addprofile'], getConfigProfiles())) {
// check profile password
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
// check if lam.conf_sample exists
if (!is_file("../../config/lam.conf_sample")) {
$error = _("The file config/lam.conf_sample was not found. Please restore it.");
}
else {
// create new profile file
@copy("../../config/lam.conf_sample", "../../config/" . $_POST['addprofile'] . ".conf");
@chmod ("../../config/" . $_POST['addprofile'] . ".conf", 0600);
@ -93,7 +98,10 @@ if ($_POST['submit']) {
$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!");
}