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 $colwarn[$col] = "Kan niet worden aangepast.";
144 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
145 $colwarn[$col] = "Fout bij opslaan.";
149 foreach ($_FILES as $col => $val) {
150 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
153 switch ($val['error']) {
156 case UPLOAD_ERR_NO_FILE:
157 continue 2; # current
159 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
162 if (empty($cols[$col]['target'])) {
163 $colwarn[$col] = "Kan niet worden aangepast.";
166 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
167 $colwarn[$col] = "Fout bij opslaan.";
169 foreach (@glob('thumb/*/') as $thumbres) {
170 # attempt to remove old derivations
171 @unlink($thumbres.'/'.$cols[$col]['target']);
173 $cols[$col]['value'] = '';
176 if (!empty($_POST['newpass'])) {
177 require_once('login/pass.inc.php');
178 if ($error = passform($user, $_POST)) {
179 $colwarn['newpass'] = $error;
184 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
187 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
192 <form method="post" enctype="multipart/form-data">
195 foreach ($cols as $col => &$colconf) {
197 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
198 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
199 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
201 200, $colconf['target'], filemtime($colconf['target'])
205 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
206 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
207 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
212 if (isset($colconf['input'])) {
213 print $colconf['input'];
215 elseif (isset($colconf['values'])) {
216 foreach ($colconf['values'] as $tag => $val) {
219 '<input type="hidden" name="tags[%1$s]" value="" />' .
220 '<input type="checkbox" name="tags[%s]" value="1"%s%s /> %s',
222 $val['value'] ? ' checked' : '',
223 isset($val['target']) ? '' : ' readonly',
230 'type' => @$colconf['type'] ?: 'text',
233 'value' => htmlspecialchars(@$colconf['value']),
234 'placeholder' => "Niet ingesteld",
235 'readonly' => empty($colconf['target']),
236 'pattern' => @$colconf['pattern'] ?: FALSE,
238 if (@$colconf['type'] == 'file') {
239 $attrs['accept'] = "image/jpeg";
243 foreach ($attrs as $attr => $attrval) {
244 if ($attrval === FALSE) {
248 if ($attrval !== TRUE) {
249 printf('="%s"', $attrval);
255 if (!empty($colconf['explain'])) {
256 printf(' <span>(%s)</span>', $colconf['explain']);
263 if ($error = @$colwarn[$col]) {
264 print " <span class=warn>$error</span>\n";
270 <p><input type="submit" value="Opslaan" /></p>