'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
] + $cols;
+if (isset($user['pass'])) {
+ $cols['newpass'] = [
+ 'label' => 'wachtwoord',
+ 'input' => <<<'EOT'
+ <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
+ <input type="password" id="newpass" name="newpass" value="" placeholder="Nieuw wachtwoord" />
+ <input type="password" name="passconf" value="" placeholder="Nogmaals" />
+EOT
+ ,
+ 'hide' => 'pass',
+ ];
+}
+
$colwarn = [];
if ($_POST) {
if (!file_exists($user['dir']) and !@mkdir($user['dir'])) {
if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
$colwarn[$col] = "Fout bij opslaan.";
}
+ foreach (@glob('thumb/*/') as $thumbres) {
+ # attempt to remove old derivations
+ @unlink($thumbres.'/'.$cols[$col]['target']);
+ }
$cols[$col]['value'] = '';
}
if (!empty($_POST['newpass'])) {
require_once('login/pass.inc.php');
if ($error = passform($user, $_POST)) {
- $colwarn['pass'] = $error;
+ $colwarn['newpass'] = $error;
}
}
Geef een e-mailadres op waarmee we u kunnen bereiken indien nodig.
Wij zullen dit adres nooit vrij- of doorgeven.
</p>
+ <ul class="grid">
<?php
foreach ($cols as $col => &$colconf) {
print "\t";
- printf('<label for="%s">%s:</label> ', $col, ucfirst($colconf['label']));
+ printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
- printf('<img src="/%s" /><br />', $colconf['target']);
+ printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
+ $colconf['target'],
+ 200, $colconf['target'], filemtime($colconf['target'])
+ );
}
- print "<input";
- if (empty($colconf['target'])) print ' readonly';
- printf(' type="%s" name="%s" id="%1$s" value="%s"',
- @$colconf['type'] ?: 'text',
- $col,
- htmlspecialchars(@$colconf['value'])
- );
- if (@$colconf['type'] == 'file') {
- printf(' accept="%s"', 'image/jpeg');
+
+ if ($hide = @$colconf['hide'] and empty($_POST[$col])) {
+ printf('<a onclick="%s">Wijzigen</a><span id="%s" hidden>',
+ "document.getElementById('$hide').removeAttribute('hidden'); this.remove()",
+ $hide
+ );
}
- print ' placeholder="Niet ingesteld"';
- print " />";
- if ($error = @$colwarn[$col]) {
- print " <span class=warn>$error</span>\n";
+ if (isset($colconf['input'])) {
+ print $colconf['input'];
}
- print "<br />\n";
-}
+ else {
+ $attrs = [
+ 'type' => @$colconf['type'] ?: 'text',
+ 'name' => $col,
+ 'id' => $col,
+ 'value' => htmlspecialchars(@$colconf['value']),
+ 'placeholder' => "Niet ingesteld",
+ 'readonly' => empty($colconf['target']),
+ ];
+ if (@$colconf['type'] == 'file') {
+ $attrs['accept'] = "image/jpeg";
+ }
-if (isset($user['pass'])) {
- if ($hide = empty($_POST['newpass'])) {
-?>
- <p><a onclick="document.getElementById('pass').removeAttribute('hidden'); this.remove()">Wachtwoord wijzigen</a></p>
-<?php
+ print '<input';
+ foreach ($attrs as $attr => $attrval) {
+ if ($attrval === FALSE) {
+ continue;
+ }
+ print ' ' . $attr;
+ if ($attrval !== TRUE) {
+ printf('="%s"', $attrval);
+ }
+ }
+ print ' />';
}
-?>
- <div id="pass"<?php if ($hide) print ' hidden'; ?>>
- <label for="newpass">Wachtwoord:</label>
- <input type="password" name="oldpass" value="" placeholder="Huidig wachtwoord" />
- <input type="password" name="newpass" value="" placeholder="Nieuw wachtwoord" />
- <input type="password" name="passconf" value="" placeholder="Nogmaals" />
-<?php
- if ($error = @$colwarn['pass']) {
+
+ if ($hide) {
+ print '</span>';
+ }
+
+ if ($error = @$colwarn[$col]) {
print " <span class=warn>$error</span>\n";
}
-?>
- </div>
-<?php
+ print "</li>\n";
}
?>
- <input type="submit" value="Opslaan" />
+ </ul>
+ <p><input type="submit" value="Opslaan" /></p>
</form>