3 if (empty($user = &$User)) {
7 if (!empty($User['admin']) and $Page == 'login/edit' and $Args) {
8 $username = strtolower(ltrim($Args, '/'));
10 'dir' => "profile/$username",
17 'label' => 'volledige naam',
18 'explain' => "Alleen zichtbaar voor andere leden.",
21 'label' => 'e-mailadres',
23 'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
26 'label' => 'portretfoto',
31 foreach ($cols as $col => &$colconf) {
32 $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
33 $colpath = "{$user['dir']}/$col.$filetype";
34 if (file_exists($colpath)) {
35 $colconf['value'] = $filetype != 'txt' ? '' :
36 file_get_contents($colpath);
38 if (file_exists($user['dir']) and !is_writable($user['dir'])) {
39 continue; # locked parent directory
41 if (isset($colconf['value']) and !is_writable($colpath)) {
42 continue; # locked column file
44 $colconf['target'] = $colpath; # editing allowed
50 'value' => $user['name'],
52 'pattern' => "[a-z0-9-]+",
56 if (isset($user['pass'])) {
58 'label' => 'wachtwoord',
60 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
61 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
62 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
71 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
72 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
76 foreach ($_POST as $col => $val) {
77 if (!isset($cols[$col])) {
80 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
83 $cols[$col]['value'] = $val; # update form value
84 if (empty($cols[$col]['target'])) {
85 $colwarn[$col] = "Kan niet worden aangepast.";
88 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
89 $colwarn[$col] = "Fout bij opslaan.";
93 foreach ($_FILES as $col => $val) {
94 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
97 switch ($val['error']) {
100 case UPLOAD_ERR_NO_FILE:
101 continue 2; # current
103 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
106 if (empty($cols[$col]['target'])) {
107 $colwarn[$col] = "Kan niet worden aangepast.";
110 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
111 $colwarn[$col] = "Fout bij opslaan.";
113 foreach (@glob('thumb/*/') as $thumbres) {
114 # attempt to remove old derivations
115 @unlink($thumbres.'/'.$cols[$col]['target']);
117 $cols[$col]['value'] = '';
120 if (!empty($_POST['newpass'])) {
121 require_once('login/pass.inc.php');
122 if ($error = passform($user, $_POST)) {
123 $colwarn['newpass'] = $error;
128 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
131 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
136 <form method="post" enctype="multipart/form-data">
139 foreach ($cols as $col => &$colconf) {
141 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
142 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
143 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
145 200, $colconf['target'], filemtime($colconf['target'])
149 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
150 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
151 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
156 if (isset($colconf['input'])) {
157 print $colconf['input'];
161 'type' => @$colconf['type'] ?: 'text',
164 'value' => htmlspecialchars(@$colconf['value']),
165 'placeholder' => "Niet ingesteld",
166 'readonly' => empty($colconf['target']),
167 'pattern' => @$colconf['pattern'] ?: FALSE,
169 if (@$colconf['type'] == 'file') {
170 $attrs['accept'] = "image/jpeg";
174 foreach ($attrs as $attr => $attrval) {
175 if ($attrval === FALSE) {
179 if ($attrval !== TRUE) {
180 printf('="%s"', $attrval);
185 if (!empty($colconf['explain'])) {
186 printf(' <span>(%s)</span>', $colconf['explain']);
193 if ($error = @$colwarn[$col]) {
194 print " <span class=warn>$error</span>\n";
200 <p><input type="submit" value="Opslaan" /></p>