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
48 'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
51 if (isset($user['pass'])) {
53 'label' => 'wachtwoord',
55 <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
56 <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
57 <input type="password" name="passconf" value="" placeholder="Nogmaals" />
66 if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
67 print "<p class=warn>Fout bij het aanmaken van gebruikersprofiel voor <em>{$user['name']}</em>.</p>\n\n";
71 foreach ($_POST as $col => $val) {
72 if (!isset($cols[$col])) {
75 if (isset($cols[$col]['value']) and $cols[$col]['value'] === $val) {
78 $cols[$col]['value'] = $val; # update form value
79 if (empty($cols[$col]['target'])) {
80 $colwarn[$col] = "Kan niet worden aangepast.";
83 if (file_put_contents($cols[$col]['target'], $val) === FALSE) {
84 $colwarn[$col] = "Fout bij opslaan.";
88 foreach ($_FILES as $col => $val) {
89 if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') {
92 switch ($val['error']) {
95 case UPLOAD_ERR_NO_FILE:
98 $colwarn[$col] = "Afbeelding niet goed ontvangen.";
101 if (empty($cols[$col]['target'])) {
102 $colwarn[$col] = "Kan niet worden aangepast.";
105 if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
106 $colwarn[$col] = "Fout bij opslaan.";
108 foreach (@glob('thumb/*/') as $thumbres) {
109 # attempt to remove old derivations
110 @unlink($thumbres.'/'.$cols[$col]['target']);
112 $cols[$col]['value'] = '';
115 if (!empty($_POST['newpass'])) {
116 require_once('login/pass.inc.php');
117 if ($error = passform($user, $_POST)) {
118 $colwarn['newpass'] = $error;
123 print "<p class=warn>Instellingen zijn niet (volledig) opgeslagen. Probeer het later nog eens.</p>\n\n";
126 print "<p>Alle instellingen zijn opgeslagen.</p>\n\n";
131 <form method="post" enctype="multipart/form-data">
134 foreach ($cols as $col => &$colconf) {
136 printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
137 if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
138 printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
140 200, $colconf['target'], filemtime($colconf['target'])
144 if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
145 printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
146 "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
151 if (isset($colconf['input'])) {
152 print $colconf['input'];
156 'type' => @$colconf['type'] ?: 'text',
159 'value' => htmlspecialchars(@$colconf['value']),
160 'placeholder' => "Niet ingesteld",
161 'readonly' => empty($colconf['target']),
163 if (@$colconf['type'] == 'file') {
164 $attrs['accept'] = "image/jpeg";
168 foreach ($attrs as $attr => $attrval) {
169 if ($attrval === FALSE) {
173 if ($attrval !== TRUE) {
174 printf('="%s"', $attrval);
179 if (!empty($colconf['explain'])) {
180 printf(' <span>(%s)</span>', $colconf['explain']);
187 if ($error = @$colwarn[$col]) {
188 print " <span class=warn>$error</span>\n";
194 <p><input type="submit" value="Opslaan" /></p>