7 $userdir = $User['dir'];
10 'email' => ['label' => 'e-mailadres', 'type' => 'email'],
13 foreach ($cols as $col => &$colconf) {
14 $colpath = "$userdir/$col.txt";
15 if (file_exists($colpath)) {
16 $colconf['value'] = file_get_contents($colpath);
18 if (!is_writable($userdir)) {
19 continue; # locked parent directory
21 if (isset($colconf['value']) and !is_writable($colpath)) {
22 continue; # locked column file
24 $colconf['target'] = $colpath; # editing allowed
29 foreach ($_POST as $col => $val) {
30 if (!isset($cols[$col])) {
33 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
36 $cols[$col]['value'] = $val; # update form value
37 if (empty($cols[$col]['target'])) {
38 $colwarn[$col] = "Kan niet worden aangepast.";
41 if (!file_put_contents($cols[$col]['target'], $val)) {
42 $colwarn[$col] = "Fout bij opslaan.";
47 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
50 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
55 <form method="post" class="inline">
57 Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
58 Wij zullen dit adres nooit vrij- of doorgeven.
62 foreach ($cols as $col => &$colconf) {
64 if (empty($colconf['target'])) print ' readonly';
65 printf(' type="%s" name="%s" id="%1$s" value="%s"',
66 @$colconf['type'] ?: 'text',
68 htmlspecialchars(@$colconf['value'])
70 print ' placeholder="Geen '.$colconf['label'].' ingesteld"';
73 if ($error = @$colwarn[$col]) {
74 print "<span class=warn>$error</span>\n";
78 <input type="submit" value="Opslaan" />