"profile/$username", 'name' => $username, ]; if (!is_writable($user['dir'])) { print "
Het is niet mogelijk om de gebruiker {$user['name']} aan te passen.
\n\n"; return; } } $cols = [ 'name' => ['label' => 'volledige naam'], 'email' => ['label' => 'e-mailadres', 'type' => 'email'], ]; foreach ($cols as $col => &$colconf) { $colpath = "{$user['dir']}/$col.txt"; if (file_exists($colpath)) { $colconf['value'] = file_get_contents($colpath); } if (!is_writable($user['dir'])) { continue; # locked parent directory } if (isset($colconf['value']) and !is_writable($colpath)) { continue; # locked column file } $colconf['target'] = $colpath; # editing allowed } $cols = [ 'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL], ] + $cols; $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 (!empty($_POST['newpass'])) { require_once('login/pass.inc.php'); if ($error = passform($user, $_POST)) { $colwarn['pass'] = $error; } } if ($colwarn) { print "Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.
\n\n"; } else { print "Alle instellingen zijn opgeslagen.
\n\n"; } } ?>