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", '; '],
23 'filename' => 'name.txt',
26 'label' => 'e-mailadres',
28 'explain' => "Voor contact van of met deze site. Wij zullen dit nooit vrij- of doorgeven.",
30 'filename' => 'email.txt',
33 'label' => 'portretfoto',
35 'filename' => 'avatar.jpg',
39 foreach ($cols as $col => &$colconf) {
40 if (!isset($colconf['filename'])) {
41 continue; # exceptional storage
43 $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
44 $colpath = $user['dir'] . '/' . $colconf['filename'];
45 if (file_exists($colpath)) {
46 $colconf['value'] = $filetype != 'txt' ? '' :
47 file_get_contents($colpath);
49 if (file_exists($user['dir']) and !is_writable($user['dir'])) {
50 continue; # locked parent directory
52 if (isset($colconf['value']) and !is_writable($colpath)) {
53 continue; # locked column file
55 $colconf['target'] = $colpath; # editing allowed
61 'value' => $user['name'],
63 'pattern' => "[a-z0-9-]+",
68 $tagdir = 'profile/.tags';
69 if (file_exists($tagdir)) {
71 foreach (glob("$tagdir/*") as $tag) {
72 $tagname = pathinfo($tag, PATHINFO_BASENAME);
73 $target = "$tag/{$user['name']}";
74 $val = file_exists($target);
75 $tags[$tagname] = ['value' => $val];
76 if (empty($User['admin'])) {
79 if (!is_writable($tag)) {
80 continue; # locked tag directory
82 if ($val and !is_writable($target)) {
83 continue; # existing file locked
85 $tags[$tagname]['target'] = $target;
96 if (isset($user['pass'])) {
98 'label' => 'wachtwoord',
100 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
101 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
102 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
111 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
112 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
116 foreach ($_POST as $col => $val) {
117 if (!isset($cols[$col])) {
120 if (isset($cols[$col]['values'])) {
122 foreach ($val as $optcol => $optval) {
123 $option = &$cols[$col]['values'][$optcol];
124 if (!isset($option['target'])) {
125 $optok = FALSE; # forbidden
127 if ($option['value'] === !empty($optval)) {
128 continue; # unaltered
130 elseif (empty($optval)) {
131 $optok = @unlink($option['target']);
134 # link option target to current user dir
135 $optok = @symlink("../../{$user['name']}", $option['target']);
137 $option['value'] = $optval; # update form value
139 $optwarn[$optcol] = TRUE;
143 $colwarn[$col] = "Wijziging niet opgeslagen voor "
144 . implode(', ', array_keys($optwarn));
149 if (isset($cols[$col]['filter'])) {
150 list ($targetstr, $inputstr) = $cols[$col]['filter'];
151 $val = str_replace($inputstr, $targetstr, $val);
153 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
154 continue; # unaltered
156 $cols[$col]['value'] = $val; # update form value
157 if (empty($cols[$col]['target'])) {
158 if (empty($cols[$col]['input'])) {
159 $colwarn[$col] = "Kan niet worden aangepast.";
163 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
164 $colwarn[$col] = "Fout bij opslaan.";
168 foreach ($_FILES as $col => $val) {
169 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
172 switch ($val['error']) {
175 case UPLOAD_ERR_NO_FILE:
176 continue 2; # current
178 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
181 if (empty($cols[$col]['target'])) {
182 $colwarn[$col] = "Kan niet worden aangepast.";
185 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
186 $colwarn[$col] = "Fout bij opslaan.";
188 foreach (@glob('thumb/*/') as $thumbres) {
189 # attempt to remove old derivations
190 @unlink($thumbres.'/'.$cols[$col]['target']);
192 $cols[$col]['value'] = '';
195 if (!empty($_POST['newpass'])) {
196 require_once('login/pass.inc.php');
197 if ($error = passform($user, $_POST)) {
198 $colwarn['newpass'] = $error;
203 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
206 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
211 <form method="post" enctype="multipart/form-data">
214 foreach ($cols as $col => &$colconf) {
216 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
217 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
218 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
220 200, $colconf['target'], filemtime($colconf['target'])
224 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
225 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
226 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
231 if (isset($colconf['input'])) {
232 print $colconf['input'];
234 elseif (isset($colconf['values'])) {
235 foreach ($colconf['values'] as $tag => $val) {
238 '<input type="hidden" name="%1$s" value="" />' .
239 '<input type="checkbox" name="%s" value="1" id="%s"%s%s />' .
240 '<label for="%2$s"> %s</label>',
241 "tags[$tag]", "tag-$tag",
242 $val['value'] ? ' checked' : '',
243 isset($val['target']) ? '' : ' readonly',
249 if (isset($cols[$col]['filter'])) {
250 list ($targetstr, $inputstr) = $cols[$col]['filter'];
251 $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
255 'type' => @$colconf['type'] ?: 'text',
258 'value' => htmlspecialchars(@$colconf['value']),
259 'placeholder' => "Niet ingesteld",
260 'readonly' => empty($colconf['target']),
261 'pattern' => @$colconf['pattern'] ?: FALSE,
262 'size' => @$colconf['size'] ?: FALSE,
264 if (@$colconf['type'] == 'file') {
265 $attrs['accept'] = "image/jpeg";
269 foreach ($attrs as $attr => $attrval) {
270 if ($attrval === FALSE) {
274 if ($attrval !== TRUE) {
275 printf('="%s"', $attrval);
281 if (!empty($colconf['explain'])) {
282 printf(' <span>(%s)</span>', $colconf['explain']);
289 if ($error = @$colwarn[$col]) {
290 print " <span class=warn>$error</span>\n";
296 <p><input type="submit" value="Opslaan" /></p>