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;
78 foreach ($tags as $tag => $val) {
81 '<input type="hidden" name="tags[%1$s]" value="" />' .
82 '<input type="checkbox" name="tags[%s]" value="1"%s%s /> %s',
84 $val['value'] ? ' checked' : '',
85 isset($val['target']) ? '' : ' readonly',
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]['value']) and $cols[$col]['value'] === $val) {
123 continue; # unaltered
125 $cols[$col]['value'] = $val; # update form value
126 if (empty($cols[$col]['target'])) {
127 $colwarn[$col] = "Kan niet worden aangepast.";
130 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
131 $colwarn[$col] = "Fout bij opslaan.";
135 if (isset($cols['tags']) and !empty($_POST['tags'])) {
137 foreach ($_POST['tags'] as $col => $val) {
138 $tag = $cols['tags']['values'][$col];
139 if (!isset($tag['target'])) {
140 $tagok[$col] = 'forbidden';
142 if ($tag['value'] === !empty($val)) {
143 $tagok[$col] = NULL; # unaltered
145 elseif (empty($val)) {
146 $tagok[$col] = !@unlink($tag['target']);
149 $tagok[$col] = !@symlink("../../{$user['name']}", $tag['target']);
152 if ($tagok = array_filter($tagok)) {
153 $colwarn['tags'] = "Wijziging niet opgeslagen voor "
154 . implode(', ', array_keys($tagok));
158 foreach ($_FILES as $col => $val) {
159 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
162 switch ($val['error']) {
165 case UPLOAD_ERR_NO_FILE:
166 continue 2; # current
168 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
171 if (empty($cols[$col]['target'])) {
172 $colwarn[$col] = "Kan niet worden aangepast.";
175 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
176 $colwarn[$col] = "Fout bij opslaan.";
178 foreach (@glob('thumb/*/') as $thumbres) {
179 # attempt to remove old derivations
180 @unlink($thumbres.'/'.$cols[$col]['target']);
182 $cols[$col]['value'] = '';
185 if (!empty($_POST['newpass'])) {
186 require_once('login/pass.inc.php');
187 if ($error = passform($user, $_POST)) {
188 $colwarn['newpass'] = $error;
193 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
196 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
201 <form method="post" enctype="multipart/form-data">
204 foreach ($cols as $col => &$colconf) {
206 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
207 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
208 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
210 200, $colconf['target'], filemtime($colconf['target'])
214 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
215 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
216 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
221 if (isset($colconf['input'])) {
222 print $colconf['input'];
226 'type' => @$colconf['type'] ?: 'text',
229 'value' => htmlspecialchars(@$colconf['value']),
230 'placeholder' => "Niet ingesteld",
231 'readonly' => empty($colconf['target']),
232 'pattern' => @$colconf['pattern'] ?: FALSE,
234 if (@$colconf['type'] == 'file') {
235 $attrs['accept'] = "image/jpeg";
239 foreach ($attrs as $attr => $attrval) {
240 if ($attrval === FALSE) {
244 if ($attrval !== TRUE) {
245 printf('="%s"', $attrval);
250 if (!empty($colconf['explain'])) {
251 printf(' <span>(%s)</span>', $colconf['explain']);
258 if ($error = @$colwarn[$col]) {
259 print " <span class=warn>$error</span>\n";
265 <p><input type="submit" value="Opslaan" /></p>