3 if (empty($user = &$User)) {
7 if (!empty($User['admin'])
8 and !empty($Place['user']) and $Place['user'] !== $User['name']) {
9 $username = strtolower($Place['user']);
12 'dir' => "profile/$username",
19 'label' => 'volledige naam',
20 'explain' => "Alleen zichtbaar voor andere leden.",
21 'filter' => ["\n", '; '],
25 'label' => 'e-mailadres',
27 'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
31 'label' => 'portretfoto',
36 foreach ($cols as $col => &$colconf) {
37 $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
38 $colpath = "{$user['dir']}/$col.$filetype";
39 if (file_exists($colpath)) {
40 $colconf['value'] = $filetype != 'txt' ? '' :
41 file_get_contents($colpath);
43 if (file_exists($user['dir']) and !is_writable($user['dir'])) {
44 continue; # locked parent directory
46 if (isset($colconf['value']) and !is_writable($colpath)) {
47 continue; # locked column file
49 $colconf['target'] = $colpath; # editing allowed
55 'value' => $user['name'],
57 'pattern' => "[a-z0-9-]+",
62 $tagdir = 'profile/.tags';
63 if (file_exists($tagdir)) {
65 foreach (glob("$tagdir/*") as $tag) {
66 $tagname = pathinfo($tag, PATHINFO_BASENAME);
67 $target = "$tag/{$user['name']}";
68 $val = file_exists($target);
69 $tags[$tagname] = ['value' => $val];
70 if (empty($User['admin'])) {
73 if (!is_writable($tag)) {
74 continue; # locked tag directory
76 if ($val and !is_writable($target)) {
77 continue; # existing file locked
79 $tags[$tagname]['target'] = $target;
90 if (isset($user['pass'])) {
92 'label' => 'wachtwoord',
94 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
95 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
96 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
105 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
106 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
110 foreach ($_POST as $col => $val) {
111 if (!isset($cols[$col])) {
114 if (isset($cols[$col]['values'])) {
116 foreach ($val as $optcol => $optval) {
117 $option = &$cols[$col]['values'][$optcol];
118 if (!isset($option['target'])) {
119 $optok = FALSE; # forbidden
121 if ($option['value'] === !empty($optval)) {
122 continue; # unaltered
124 elseif (empty($optval)) {
125 $optok = @unlink($option['target']);
128 # link option target to current user dir
129 $optok = @symlink("../../{$user['name']}", $option['target']);
131 $option['value'] = $optval; # update form value
133 $optwarn[$optcol] = TRUE;
137 $colwarn[$col] = "Wijziging niet opgeslagen voor "
138 . implode(', ', array_keys($optwarn));
143 if (isset($cols[$col]['filter'])) {
144 list ($targetstr, $inputstr) = $cols[$col]['filter'];
145 $val = str_replace($inputstr, $targetstr, $val);
147 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
148 continue; # unaltered
150 $cols[$col]['value'] = $val; # update form value
151 if (empty($cols[$col]['target'])) {
152 if (empty($cols[$col]['input'])) {
153 $colwarn[$col] = "Kan niet worden aangepast.";
157 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
158 $colwarn[$col] = "Fout bij opslaan.";
162 foreach ($_FILES as $col => $val) {
163 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
166 switch ($val['error']) {
169 case UPLOAD_ERR_NO_FILE:
170 continue 2; # current
172 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
175 if (empty($cols[$col]['target'])) {
176 $colwarn[$col] = "Kan niet worden aangepast.";
179 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
180 $colwarn[$col] = "Fout bij opslaan.";
182 foreach (@glob('thumb/*/') as $thumbres) {
183 # attempt to remove old derivations
184 @unlink($thumbres.'/'.$cols[$col]['target']);
186 $cols[$col]['value'] = '';
189 if (!empty($_POST['newpass'])) {
190 require_once('login/pass.inc.php');
191 if ($error = passform($user, $_POST)) {
192 $colwarn['newpass'] = $error;
197 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
200 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
205 <form method="post" enctype="multipart/form-data">
208 foreach ($cols as $col => &$colconf) {
210 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
211 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
212 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
214 200, $colconf['target'], filemtime($colconf['target'])
218 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
219 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
220 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
225 if (isset($colconf['input'])) {
226 print $colconf['input'];
228 elseif (isset($colconf['values'])) {
229 foreach ($colconf['values'] as $tag => $val) {
232 '<input type="hidden" name="%1$s" value="" />' .
233 '<input type="checkbox" name="%s" value="1" id="%s"%s%s />' .
234 '<label for="%2$s"> %s</label>',
235 "tags[$tag]", "tag-$tag",
236 $val['value'] ? ' checked' : '',
237 isset($val['target']) ? '' : ' readonly',
243 if (isset($cols[$col]['filter'])) {
244 list ($targetstr, $inputstr) = $cols[$col]['filter'];
245 $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
249 'type' => @$colconf['type'] ?: 'text',
252 'value' => htmlspecialchars(@$colconf['value']),
253 'placeholder' => "Niet ingesteld",
254 'readonly' => empty($colconf['target']),
255 'pattern' => @$colconf['pattern'] ?: FALSE,
256 'size' => @$colconf['size'] ?: FALSE,
258 if (@$colconf['type'] == 'file') {
259 $attrs['accept'] = "image/jpeg";
263 foreach ($attrs as $attr => $attrval) {
264 if ($attrval === FALSE) {
268 if ($attrval !== TRUE) {
269 printf('="%s"', $attrval);
275 if (!empty($colconf['explain'])) {
276 printf(' <span>(%s)</span>', $colconf['explain']);
283 if ($error = @$colwarn[$col]) {
284 print " <span class=warn>$error</span>\n";
290 <p><input type="submit" value="Opslaan" /></p>