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",
16 'name' => ['label' => 'volledige naam'],
17 'email' => ['label' => 'e-mailadres', 'type' => 'email'],
19 'label' => 'portretfoto',
24 foreach ($cols as $col => &$colconf) {
25 $filetype = @$colconf['type'] == 'file' ? 'jpg' : 'txt';
26 $colpath = "{$user['dir']}/$col.$filetype";
27 if (file_exists($colpath)) {
28 $colconf['value'] = $filetype != 'txt' ? '' :
29 file_get_contents($colpath);
31 if (file_exists($user['dir']) and !is_writable($user['dir'])) {
32 continue; # locked parent directory
34 if (isset($colconf['value']) and !is_writable($colpath)) {
35 continue; # locked column file
37 $colconf['target'] = $colpath; # editing allowed
41 'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
46 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
47 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
51 foreach ($_POST as $col => $val) {
52 if (!isset($cols[$col])) {
55 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
58 $cols[$col]['value'] = $val; # update form value
59 if (empty($cols[$col]['target'])) {
60 $colwarn[$col] = "Kan niet worden aangepast.";
63 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
64 $colwarn[$col] = "Fout bij opslaan.";
68 foreach ($_FILES as $col => $val) {
69 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
72 switch ($val['error']) {
75 case UPLOAD_ERR_NO_FILE:
78 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
81 if (empty($cols[$col]['target'])) {
82 $colwarn[$col] = "Kan niet worden aangepast.";
85 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
86 $colwarn[$col] = "Fout bij opslaan.";
88 foreach (@glob('thumb/*/') as $thumbres) {
89 # attempt to remove old derivations
90 @unlink($thumbres.'/'.$cols[$col]['target']);
92 $cols[$col]['value'] = '';
95 if (!empty($_POST['newpass'])) {
96 require_once('login/pass.inc.php');
97 if ($error = passform($user, $_POST)) {
98 $colwarn['pass'] = $error;
103 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
106 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
111 <form method="post" enctype="multipart/form-data">
113 Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
114 Wij zullen dit adres nooit vrij- of doorgeven.
118 foreach ($cols as $col => &$colconf) {
120 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
121 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
122 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
124 200, $colconf['target'], filemtime($colconf['target'])
130 'type' => @$colconf['type'] ?: 'text',
133 'value' => htmlspecialchars(@$colconf['value']),
134 'placeholder' => "Niet ingesteld",
135 'readonly' => empty($colconf['target']),
137 if (@$colconf['type'] == 'file') {
138 $attrs['accept'] = "image/jpeg";
142 foreach ($attrs as $attr => $attrval) {
143 if ($attrval === FALSE) {
147 if ($attrval !== TRUE) {
148 printf('="%s"', $attrval);
154 if ($error = @$colwarn[$col]) {
155 print " <span class=warn>$error</span>\n";
160 if (isset($user['pass'])) {
162 <li><label for="newpass">Wachtwoord:</label>
164 if ($hide = empty($_POST['newpass'])) {
166 <a onclick="document.getElementById('pass').removeAttribute('hidden'); this.remove()">Wijzigen</a>
170 <span id="pass"<?php if ($hide) print ' hidden'; ?>>
171 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
172 <input type="password" name="newpass" value="" placeholder="Nieuw wachtwoord" />
173 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
175 if ($error = @$colwarn['pass']) {
176 print " <span class=warn>$error</span>\n";
184 <p><input type="submit" value="Opslaan" /></p>