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],
44 if (isset($user['pass'])) {
46 'label' => 'wachtwoord',
48 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
49 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
50 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
59 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
60 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
64 foreach ($_POST as $col => $val) {
65 if (!isset($cols[$col])) {
68 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
71 $cols[$col]['value'] = $val; # update form value
72 if (empty($cols[$col]['target'])) {
73 $colwarn[$col] = "Kan niet worden aangepast.";
76 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
77 $colwarn[$col] = "Fout bij opslaan.";
81 foreach ($_FILES as $col => $val) {
82 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
85 switch ($val['error']) {
88 case UPLOAD_ERR_NO_FILE:
91 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
94 if (empty($cols[$col]['target'])) {
95 $colwarn[$col] = "Kan niet worden aangepast.";
98 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
99 $colwarn[$col] = "Fout bij opslaan.";
101 foreach (@glob('thumb/*/') as $thumbres) {
102 # attempt to remove old derivations
103 @unlink($thumbres.'/'.$cols[$col]['target']);
105 $cols[$col]['value'] = '';
108 if (!empty($_POST['newpass'])) {
109 require_once('login/pass.inc.php');
110 if ($error = passform($user, $_POST)) {
111 $colwarn['newpass'] = $error;
116 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
119 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
124 <form method="post" enctype="multipart/form-data">
126 Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
127 Wij zullen dit adres nooit vrij- of doorgeven.
131 foreach ($cols as $col => &$colconf) {
133 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
134 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
135 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
137 200, $colconf['target'], filemtime($colconf['target'])
141 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
142 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
143 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
148 if (isset($colconf['input'])) {
149 print $colconf['input'];
153 'type' => @$colconf['type'] ?: 'text',
156 'value' => htmlspecialchars(@$colconf['value']),
157 'placeholder' => "Niet ingesteld",
158 'readonly' => empty($colconf['target']),
160 if (@$colconf['type'] == 'file') {
161 $attrs['accept'] = "image/jpeg";
165 foreach ($attrs as $attr => $attrval) {
166 if ($attrval === FALSE) {
170 if ($attrval !== TRUE) {
171 printf('="%s"', $attrval);
181 if ($error = @$colwarn[$col]) {
182 print " <span class=warn>$error</span>\n";
188 <p><input type="submit" value="Opslaan" /></p>