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 $tagdir = 'profile/.tags';
57 if (file_exists($tagdir)) {
59 foreach (glob("$tagdir/*") as $tag) {
60 $tagname = pathinfo($tag, PATHINFO_BASENAME);
61 $target = "$tag/{$user['name']}";
62 $val = file_exists($target);
63 $tags[$tagname] = ['value' => $val];
64 if (empty($User['admin'])) {
67 if (!is_writable($tag)) {
68 continue; # locked tag directory
70 if ($val and !is_writable($target)) {
71 continue; # existing file locked
73 $tags[$tagname]['target'] = $target;
84 if (isset($user['pass'])) {
86 'label' => 'wachtwoord',
88 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
89 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
90 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
99 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
100 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
104 foreach ($_POST as $col => $val) {
105 if (!isset($cols[$col])) {
108 if (isset($cols[$col]['values'])) {
110 foreach ($val as $optcol => $optval) {
111 $option = &$cols[$col]['values'][$optcol];
112 if (!isset($option['target'])) {
113 $optok = FALSE; # forbidden
115 if ($option['value'] === !empty($optval)) {
116 continue; # unaltered
118 elseif (empty($optval)) {
119 $optok = @unlink($option['target']);
122 # link option target to current user dir
123 $optok = @symlink("../../{$user['name']}", $option['target']);
125 $option['value'] = $optval; # update form value
127 $optwarn[$optcol] = TRUE;
131 $colwarn[$col] = "Wijziging niet opgeslagen voor "
132 . implode(', ', array_keys($optwarn));
136 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
137 continue; # unaltered
139 $cols[$col]['value'] = $val; # update form value
140 if (empty($cols[$col]['target'])) {
141 if (empty($cols[$col]['input'])) {
142 $colwarn[$col] = "Kan niet worden aangepast.";
146 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
147 $colwarn[$col] = "Fout bij opslaan.";
151 foreach ($_FILES as $col => $val) {
152 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
155 switch ($val['error']) {
158 case UPLOAD_ERR_NO_FILE:
159 continue 2; # current
161 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
164 if (empty($cols[$col]['target'])) {
165 $colwarn[$col] = "Kan niet worden aangepast.";
168 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
169 $colwarn[$col] = "Fout bij opslaan.";
171 foreach (@glob('thumb/*/') as $thumbres) {
172 # attempt to remove old derivations
173 @unlink($thumbres.'/'.$cols[$col]['target']);
175 $cols[$col]['value'] = '';
178 if (!empty($_POST['newpass'])) {
179 require_once('login/pass.inc.php');
180 if ($error = passform($user, $_POST)) {
181 $colwarn['newpass'] = $error;
186 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
189 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
194 <form method="post" enctype="multipart/form-data">
197 foreach ($cols as $col => &$colconf) {
199 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
200 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
201 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
203 200, $colconf['target'], filemtime($colconf['target'])
207 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
208 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
209 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
214 if (isset($colconf['input'])) {
215 print $colconf['input'];
217 elseif (isset($colconf['values'])) {
218 foreach ($colconf['values'] as $tag => $val) {
221 '<input type="hidden" name="%1$s" value="" />' .
222 '<input type="checkbox" name="%s" value="1" id="%s"%s%s />' .
223 '<label for="%2$s"> %s</label>',
224 "tags[$tag]", "tag-$tag",
225 $val['value'] ? ' checked' : '',
226 isset($val['target']) ? '' : ' readonly',
233 'type' => @$colconf['type'] ?: 'text',
236 'value' => htmlspecialchars(@$colconf['value']),
237 'placeholder' => "Niet ingesteld",
238 'readonly' => empty($colconf['target']),
239 'pattern' => @$colconf['pattern'] ?: FALSE,
241 if (@$colconf['type'] == 'file') {
242 $attrs['accept'] = "image/jpeg";
246 foreach ($attrs as $attr => $attrval) {
247 if ($attrval === FALSE) {
251 if ($attrval !== TRUE) {
252 printf('="%s"', $attrval);
258 if (!empty($colconf['explain'])) {
259 printf(' <span>(%s)</span>', $colconf['explain']);
266 if ($error = @$colwarn[$col]) {
267 print " <span class=warn>$error</span>\n";
273 <p><input type="submit" value="Opslaan" /></p>