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',
40 'filename' => 'profile/.tags',
44 foreach ($cols as $col => &$colconf) {
45 if (!isset($colconf['filename'])) {
46 continue; # exceptional storage
49 if (isset($colconf['values'])) {
50 if (!file_exists($colconf['filename'])) {
55 foreach (glob($colconf['filename'] . '/*') as $tag) {
56 $tagname = pathinfo($tag, PATHINFO_BASENAME);
57 $target = "$tag/{$user['name']}";
58 $val = file_exists($target);
59 $tags[$tagname] = ['value' => $val];
60 if (empty($User['admin'])) {
63 if (!is_writable($tag)) {
64 continue; # locked tag directory
66 if ($val and !is_writable($target)) {
67 continue; # existing file locked
69 $tags[$tagname]['target'] = $target;
73 $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
74 $colpath = $user['dir'] . '/' . $colconf['filename'];
75 if (file_exists($colpath)) {
76 $colconf['value'] = $filetype != 'txt' ? '' :
77 file_get_contents($colpath);
79 if (file_exists($user['dir']) and !is_writable($user['dir'])) {
80 continue; # locked parent directory
82 if (isset($colconf['value']) and !is_writable($colpath)) {
83 continue; # locked column file
85 $colconf['target'] = $colpath; # editing allowed
91 'value' => $user['name'],
93 'pattern' => "[a-z0-9-]+",
98 if (isset($user['pass'])) {
100 'label' => 'wachtwoord',
102 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
103 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
104 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
113 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
114 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
118 foreach ($_POST as $col => $val) {
119 if (!isset($cols[$col])) {
122 if (isset($cols[$col]['values'])) {
124 foreach ($val as $optcol => $optval) {
125 $option = &$cols[$col]['values'][$optcol];
126 if (!isset($option['target'])) {
127 $optok = FALSE; # forbidden
129 if ($option['value'] === !empty($optval)) {
130 continue; # unaltered
132 elseif (empty($optval)) {
133 $optok = @unlink($option['target']);
136 # link option target to current user dir
137 $optok = @symlink("../../{$user['name']}", $option['target']);
139 $option['value'] = $optval; # update form value
141 $optwarn[$optcol] = TRUE;
145 $colwarn[$col] = "Wijziging niet opgeslagen voor "
146 . implode(', ', array_keys($optwarn));
151 if (isset($cols[$col]['filter'])) {
152 list ($targetstr, $inputstr) = $cols[$col]['filter'];
153 $val = str_replace($inputstr, $targetstr, $val);
155 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
156 continue; # unaltered
158 $cols[$col]['value'] = $val; # update form value
159 if (empty($cols[$col]['target'])) {
160 if (empty($cols[$col]['input'])) {
161 $colwarn[$col] = "Kan niet worden aangepast.";
165 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
166 $colwarn[$col] = "Fout bij opslaan.";
170 foreach ($_FILES as $col => $val) {
171 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
174 switch ($val['error']) {
177 case UPLOAD_ERR_NO_FILE:
178 continue 2; # current
180 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
183 if (empty($cols[$col]['target'])) {
184 $colwarn[$col] = "Kan niet worden aangepast.";
187 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
188 $colwarn[$col] = "Fout bij opslaan.";
190 foreach (@glob('thumb/*/') as $thumbres) {
191 # attempt to remove old derivations
192 @unlink($thumbres.'/'.$cols[$col]['target']);
194 $cols[$col]['value'] = '';
197 if (!empty($_POST['newpass'])) {
198 require_once('login/pass.inc.php');
199 if ($error = passform($user, $_POST)) {
200 $colwarn['newpass'] = $error;
205 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
208 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
213 <form method="post" enctype="multipart/form-data">
216 foreach ($cols as $col => &$colconf) {
218 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
219 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
220 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
222 200, $colconf['target'], filemtime($colconf['target'])
226 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
227 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
228 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
233 if (isset($colconf['input'])) {
234 print $colconf['input'];
236 elseif (isset($colconf['values'])) {
237 foreach ($colconf['values'] as $tag => $val) {
240 '<input type="hidden" name="%1$s" value="" />' .
241 '<input type="checkbox" name="%s" value="1" id="%s"%s%s />' .
242 '<label for="%2$s"> %s</label>',
243 "tags[$tag]", "tag-$tag",
244 $val['value'] ? ' checked' : '',
245 isset($val['target']) ? '' : ' readonly',
251 if (isset($cols[$col]['filter'])) {
252 list ($targetstr, $inputstr) = $cols[$col]['filter'];
253 $colconf['value'] = str_replace($targetstr, $inputstr, $colconf['value']);
257 'type' => @$colconf['type'] ?: 'text',
260 'value' => htmlspecialchars(@$colconf['value']),
261 'placeholder' => "Niet ingesteld",
262 'readonly' => empty($colconf['target']),
263 'pattern' => @$colconf['pattern'] ?: FALSE,
264 'size' => @$colconf['size'] ?: FALSE,
266 if (@$colconf['type'] == 'file') {
267 $attrs['accept'] = "image/jpeg";
271 foreach ($attrs as $attr => $attrval) {
272 if ($attrval === FALSE) {
276 if ($attrval !== TRUE) {
277 printf('="%s"', $attrval);
283 if (!empty($colconf['explain'])) {
284 printf(' <span>(%s)</span>', $colconf['explain']);
291 if ($error = @$colwarn[$col]) {
292 print " <span class=warn>$error</span>\n";
298 <p><input type="submit" value="Opslaan" /></p>