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 $tags[$tagname] = file_exists($tagname);
67 foreach ($tags as $tag => $val) {
70 '<input type="hidden" name="tags[%1$s]" value="" />' .
71 '<input type="checkbox" name="tags[%s]" value="1"%s%s /> %s',
73 $val ? ' checked' : '',
86 if (isset($user['pass'])) {
88 'label' => 'wachtwoord',
90 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
91 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
92 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
101 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
102 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
106 foreach ($_POST as $col => $val) {
107 if (!isset($cols[$col])) {
110 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
111 continue; # unaltered
113 $cols[$col]['value'] = $val; # update form value
114 if (empty($cols[$col]['target'])) {
115 $colwarn[$col] = "Kan niet worden aangepast.";
118 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
119 $colwarn[$col] = "Fout bij opslaan.";
123 foreach ($_FILES as $col => $val) {
124 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
127 switch ($val['error']) {
130 case UPLOAD_ERR_NO_FILE:
131 continue 2; # current
133 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
136 if (empty($cols[$col]['target'])) {
137 $colwarn[$col] = "Kan niet worden aangepast.";
140 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
141 $colwarn[$col] = "Fout bij opslaan.";
143 foreach (@glob('thumb/*/') as $thumbres) {
144 # attempt to remove old derivations
145 @unlink($thumbres.'/'.$cols[$col]['target']);
147 $cols[$col]['value'] = '';
150 if (!empty($_POST['newpass'])) {
151 require_once('login/pass.inc.php');
152 if ($error = passform($user, $_POST)) {
153 $colwarn['newpass'] = $error;
158 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
161 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
166 <form method="post" enctype="multipart/form-data">
169 foreach ($cols as $col => &$colconf) {
171 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
172 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
173 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
175 200, $colconf['target'], filemtime($colconf['target'])
179 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
180 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
181 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
186 if (isset($colconf['input'])) {
187 print $colconf['input'];
191 'type' => @$colconf['type'] ?: 'text',
194 'value' => htmlspecialchars(@$colconf['value']),
195 'placeholder' => "Niet ingesteld",
196 'readonly' => empty($colconf['target']),
197 'pattern' => @$colconf['pattern'] ?: FALSE,
199 if (@$colconf['type'] == 'file') {
200 $attrs['accept'] = "image/jpeg";
204 foreach ($attrs as $attr => $attrval) {
205 if ($attrval === FALSE) {
209 if ($attrval !== TRUE) {
210 printf('="%s"', $attrval);
215 if (!empty($colconf['explain'])) {
216 printf(' <span>(%s)</span>', $colconf['explain']);
223 if ($error = @$colwarn[$col]) {
224 print " <span class=warn>$error</span>\n";
230 <p><input type="submit" value="Opslaan" /></p>