X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/0502435b8ece6ef814199b354696407d188151aa..56252c8d2e764a9c6dacb35e61a730b54ac97723:/login/edit.php diff --git a/login/edit.php b/login/edit.php index 7ebe7b9..f99c999 100644 --- a/login/edit.php +++ b/login/edit.php @@ -1,29 +1,56 @@ ['label' => 'e-mailadres', 'type' => 'email'], +]; -if ($_POST and isset($_POST['email'])) { - if ($error = setmailform($_POST)) { - print "

$error

\n\n"; +foreach ($cols as $col => &$colconf) { + $colpath = "$userdir/$col.txt"; + if (file_exists($colpath)) { + $colconf['value'] = file_get_contents($colpath); } - else { - print "

Het e-mailadres is ingesteld.

\n\n"; + if (!is_writable($userdir)) { + continue; # locked parent directory + } + if (isset($colconf['value']) and !is_writable($colpath)) { + continue; # locked column file } + $colconf['target'] = $colpath; # editing allowed } -function setmailform($input = []) -{ - global $User; - $setfile = "{$User['dir']}/email.txt"; - if (!is_writable(file_exists($setfile) ? $setfile : dirname($setfile))) { - return "Het e-mailadres kan niet worden aangepast voor deze gebruiker."; +$colwarn = []; +if ($_POST) { + foreach ($_POST as $col => $val) { + if (!isset($cols[$col])) { + continue; # unknown + } + if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) { + continue; # unaltered + } + $cols[$col]['value'] = $val; # update form value + if (empty($cols[$col]['target'])) { + $colwarn[$col] = "Kan niet worden aangepast."; + continue; + } + if (!file_put_contents($cols[$col]['target'], $val)) { + $colwarn[$col] = "Fout bij opslaan."; + } } - if (!file_put_contents($setfile, @$_POST['email'])) { - return "Het e-mailadres kon niet worden opgeslagen. Probeer het later nog eens."; + + if ($colwarn) { + print "

Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.

\n\n"; + } + else { + print "

Alle instellingen zijn opgeslagen.

\n\n"; } - return; } -$usermail = @file_get_contents("{$User['dir']}/email.txt"); ?>

@@ -31,7 +58,23 @@ $usermail = @file_get_contents("{$User['dir']}/email.txt"); Wij zullen dit adres nooit vrij- of doorgeven.

- + &$colconf) { + print "\t\n"; + + if ($error = @$colwarn[$col]) { + print "$error\n"; + } +} +?>